13 #include <Eigen/Cholesky> 15 using namespace Eigen;
27 template <
typename MatrixType>
40 int repeats = (
REPEAT*1000)/(rows*rows);
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)
70 acc += chol.
matrixL().coeff(r,c);
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)
Robust Cholesky decomposition of a matrix with pivoting.
double value(int TIMER=CPU_TIMER) const
Namespace containing all symbols from the Eigen library.
Traits::MatrixL matrixL() const
double best(int TIMER=CPU_TIMER) const
__attribute__((noinline)) void benchLLT(const MatrixType &m)
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Traits::MatrixL matrixL() const
int main(int argc, char *argv[])
The matrix class, also used for vectors and row-vectors.