22 #define MINDENSITY 0.0004 31 for (int _j=0; _j<NBTRIES; ++_j) { \ 33 for (int _k=0; _k<REPEAT; ++_k) { \ 42 dst.startFill(rows*cols*density);
45 for(
int i = 0;
i <
j;
i++)
47 Scalar v = (internal::random<float>(0,1) < density) ? internal::random<Scalar>() : 0;
51 dst.fill(j,j) = internal::random<Scalar>();
56 int main(
int argc,
char *argv[])
65 DenseVector
b = DenseVector::Random(cols);
66 DenseVector
x = DenseVector::Random(cols);
68 bool densedone =
false;
80 std::cout <<
"Eigen Dense\t" << density*100 <<
"%\n";
86 BENCH(x = m1.marked<UpperTriangular>().solveTriangular(b);)
87 std::cout <<
" colmajor^-1 * b:\t" << timer.
value() << endl;
90 BENCH(x = m2.marked<UpperTriangular>().solveTriangular(b);)
91 std::cout <<
" rowmajor^-1 * b:\t" << timer.
value() << endl;
98 std::cout <<
"Eigen sparse\t" << density*100 <<
"%\n";
101 BENCH(x = sm1.solveTriangular(b);)
102 std::cout <<
" colmajor^-1 * b:\t" << timer.
value() << endl;
105 BENCH(x = sm2.solveTriangular(b);)
106 std::cout <<
" rowmajor^-1 * b:\t" << timer.
value() << endl;
125 std::cout <<
"CSparse \t" << density*100 <<
"%\n";
127 eiToCSparse(sm1, m1);
129 BENCH(x = b;
if (!cs_lsolve (m1, x.data())){std::cerr <<
"cs_lsolve failed\n";
break;}; )
130 std::cout <<
" colmajor^-1 * b:\t" << timer.
value() << endl;
137 std::cout <<
"GMM++ sparse\t" << density*100 <<
"%\n";
139 gmm::csr_matrix<Scalar>
m2;
142 std::vector<Scalar> gmmX(cols), gmmB(cols);
147 BENCH(gmm::upper_tri_solve(m1, gmmX,
false);)
148 std::cout <<
" colmajor^-1 * b:\t" << timer.
value() << endl;
152 BENCH(gmm::upper_tri_solve(m2, gmmX,
false);)
154 std::cout <<
" rowmajor^-1 * b:\t" << timer.
value() << endl;
162 std::cout <<
"MTL4\t" << density*100 <<
"%\n";
167 mtl::dense_vector<Scalar>
x(rows, 1.0);
168 mtl::dense_vector<Scalar>
b(rows, 1.0);
170 BENCH(x = mtl::upper_trisolve(m1,b);)
171 std::cout <<
" colmajor^-1 * b:\t" << timer.
value() << endl;
174 BENCH(x = mtl::upper_trisolve(m2,b);)
175 std::cout <<
" rowmajor^-1 * b:\t" << timer.
value() << endl;
189 for (
int _j=0; _j<10; ++_j) {
190 Matrix4f
m = Matrix4f::Random();
191 Vector4f b = Vector4f::Random();
192 Vector4f x = Vector4f::Random();
194 for (
int _k=0; _k<1000000; ++_k) {
195 b = m.inverseProduct(b);
199 std::cout <<
"4x4 :\t" << timer.
value() << endl;
204 for (
int _j=0; _j<10; ++_j) {
205 Matrix4f
m = Matrix4f::Random();
206 Vector4f b = Vector4f::Random();
207 Vector4f x = Vector4f::Random();
209 for (
int _k=0; _k<1000000; ++_k) {
210 m.inverseProductInPlace(x);
214 std::cout <<
"4x4 IP :\t" << timer.
value() << endl;
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
void eiToMtl(const EigenSparseMatrix &src, MtlSparse &dst)
SparseMatrix< Scalar, UpperTriangular > EigenSparseTriMatrix
A versatible sparse matrix representation.
A matrix or vector expression mapping an existing array of data.
double value(int TIMER=CPU_TIMER) const
Matrix< Scalar, Dynamic, 1 > DenseVector
void eiToDense(const EigenSparseMatrix &src, DenseMatrix &dst)
mtl::compressed2D< Scalar, mtl::matrix::parameters< mtl::tag::col_major > > MtlSparse
Array< int, Dynamic, 1 > v
gmm::csc_matrix< Scalar > GmmSparse
int main(int argc, char *argv[])
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
void eiToGmm(const EigenSparseMatrix &src, GmmSparse &dst)
void fillMatrix(float density, int rows, int cols, EigenSparseTriMatrix &dst)
mtl::compressed2D< Scalar, mtl::matrix::parameters< mtl::tag::row_major > > MtlSparseRowMajor
SparseMatrix< Scalar, RowMajorBit|UpperTriangular > EigenSparseTriMatrixRow