#include #include #include using namespace std; using namespace Eigen; USING_PART_OF_NAMESPACE_EIGEN #ifndef SIZE #define SIZE 1024 #endif #ifndef DENSITY #define DENSITY 0.01 #endif #ifndef SCALAR #define SCALAR double #endif typedef SCALAR Scalar; typedef Matrix DenseMatrix; typedef SparseMatrix EigenSparseMatrix; void fillMatrix(float density, int rows, int cols, EigenSparseMatrix& dst) { dst.startFill(rows*cols*density); for(int j = 0; j < cols; j++) { for(int i = 0; i < rows; i++) { Scalar v = (ei_random(0,1) < density) ? ei_random() : 0; if (v!=0) dst.fill(i,j) = v; } } dst.endFill(); } void eiToDense(const EigenSparseMatrix& src, DenseMatrix& dst) { dst.setZero(); for (int j=0; j GmmSparse; typedef gmm::col_matrix< gmm::wsvector > GmmDynSparse; void eiToGmm(const EigenSparseMatrix& src, GmmSparse& dst) { GmmDynSparse tmp(src.rows(), src.cols()); for (int j=0; j typedef mtl::compressed2D > MtlSparse; typedef mtl::compressed2D > MtlSparseRowMajor; void eiToMtl(const EigenSparseMatrix& src, MtlSparse& dst) { mtl::matrix::inserter ins(dst); for (int j=0; j