16 #include <bench/BenchTimer.h> 17 #include <unsupported/Eigen/SVD> 20 using namespace Eigen;
30 #define NUMBER_SAMPLE 2 33 template<
typename MatrixType>
36 MatrixType m = MatrixType::Random(a.rows(), a.cols());
37 BenchTimer timerJacobi;
42 cout <<
" Only compute Singular Values" <<endl;
46 for (
int i=0; i<
REPEAT; ++i)
53 for (
int i=0; i<
REPEAT; ++i)
60 cout <<
"Sample " << k <<
" : " << REPEAT <<
" computations : Jacobi : " << fixed << timerJacobi.value() <<
"s ";
61 cout <<
" || " <<
" BDC : " << timerBDC.value() <<
"s " <<endl <<endl;
63 if (timerBDC.value() >= timerJacobi.value())
64 cout <<
"KO : BDC is " << timerJacobi.value() / timerBDC.value() <<
" times faster than Jacobi" <<endl;
66 cout <<
"OK : BDC is " << timerJacobi.value() / timerBDC.value() <<
" times faster than Jacobi" <<endl;
69 cout <<
" =================" <<endl;
70 std::cout<< std::endl;
73 cout <<
" Computes rotaion matrix" <<endl;
77 for (
int i=0; i<
REPEAT; ++i)
84 for (
int i=0; i<
REPEAT; ++i)
91 cout <<
"Sample " << k <<
" : " << REPEAT <<
" computations : Jacobi : " << fixed << timerJacobi.value() <<
"s ";
92 cout <<
" || " <<
" BDC : " << timerBDC.value() <<
"s " <<endl <<endl;
94 if (timerBDC.value() >= timerJacobi.value())
95 cout <<
"KO : BDC is " << timerJacobi.value() / timerBDC.value() <<
" times faster than Jacobi" <<endl;
97 cout <<
"OK : BDC is " << timerJacobi.value() / timerBDC.value() <<
" times faster than Jacobi" <<endl;
100 std::cout<< std::endl;
105 int main(
int argc,
char* argv[])
107 std::cout<< std::endl;
109 std::cout<<
"On a (Dynamic, Dynamic) (6, 6) Matrix" <<std::endl;
112 std::cout<<
"On a (Dynamic, Dynamic) (32, 32) Matrix" <<std::endl;
113 bench_svd<Matrix<double,Dynamic,Dynamic> >(Matrix<double,Dynamic,Dynamic>(32, 32));
118 std::cout<<
"On a (Dynamic, Dynamic) (160, 160) Matrix" <<std::endl;
119 bench_svd<Matrix<double,Dynamic,Dynamic> >(Matrix<double,Dynamic,Dynamic>(160, 160));
121 std::cout<<
"--------------------------------------------------------------------"<< std::endl;
void bench_svd(const MatrixType &a=MatrixType())
int main(int argc, char *argv[])
class Bidiagonal Divide and Conquer SVD
Two-sided Jacobi SVD decomposition of a rectangular matrix.
The matrix class, also used for vectors and row-vectors.