13 #include <Eigen/Cholesky>
15 using namespace Eigen;
27 template <
typename MatrixType>
46 SquareMatrixType covMat =
a *
a.adjoint();
51 int r = internal::random<int>(0,covMat.rows()-1);
52 int c = internal::random<int>(0,covMat.cols()-1);
56 for (
int k=0; k<repeats; ++k)
59 acc += cholnosqrt.
matrixL().coeff(r,
c);
67 for (
int k=0; k<repeats; ++k)
75 if (MatrixType::RowsAtCompileTime==
Dynamic)
78 std::cout <<
"fixed ";
79 std::cout << covMat.rows() <<
" \t"
80 << (timerNoSqrt.
best()) / repeats <<
"s "
81 <<
"(" << 1
e-9 * cost*repeats/timerNoSqrt.
best() <<
" GFLOPS)\t"
82 << (timerSqrt.
best()) / repeats <<
"s "
83 <<
"(" << 1
e-9 * cost*repeats/timerSqrt.
best() <<
" GFLOPS)\n";
87 if (MatrixType::RowsAtCompileTime==
Dynamic)
91 gsl_matrix* gslCovMat = gsl_matrix_alloc(covMat.rows(),covMat.cols());
92 gsl_matrix* gslCopy = gsl_matrix_alloc(covMat.rows(),covMat.cols());
94 eiToGsl(covMat, &gslCovMat);
98 for (
int k=0; k<repeats; ++k)
100 gsl_matrix_memcpy(gslCopy,gslCovMat);
101 gsl_linalg_cholesky_decomp(gslCopy);
102 acc += gsl_matrix_get(gslCopy,r,
c);
110 gsl_matrix_free(gslCovMat);
119 int main(
int argc,
char* argv[])
121 const int dynsizes[] = {4,6,8,16,24,32,49,64,128,256,512,900,1500,0};
122 std::cout <<
"size LDLT LLT";
127 for (
int i=0; dynsizes[
i]>0; ++
i)