14 #include <Eigen/Cholesky> 16 using namespace Eigen;
28 template <
typename MatrixType>
41 int repeats = (
REPEAT*1000)/(rows*rows);
47 SquareMatrixType covMat = a * a.adjoint();
52 int r = internal::random<int>(0,covMat.rows()-1);
53 int c = internal::random<int>(0,covMat.cols()-1);
57 for (
int k=0; k<repeats; ++k)
60 acc += cholnosqrt.
matrixL().coeff(r,c);
68 for (
int k=0; k<repeats; ++k)
71 acc += chol.
matrixL().coeff(r,c);
76 if (MatrixType::RowsAtCompileTime==
Dynamic)
79 std::cout <<
"fixed ";
80 std::cout << covMat.rows() <<
" \t" 81 << (timerNoSqrt.
best()) / repeats <<
"s " 82 <<
"(" << 1
e-9 * cost*repeats/timerNoSqrt.
best() <<
" GFLOPS)\t" 83 << (timerSqrt.
best()) / repeats <<
"s " 84 <<
"(" << 1
e-9 * cost*repeats/timerSqrt.
best() <<
" GFLOPS)\n";
88 if (MatrixType::RowsAtCompileTime==
Dynamic)
92 gsl_matrix* gslCovMat = gsl_matrix_alloc(covMat.rows(),covMat.cols());
93 gsl_matrix* gslCopy = gsl_matrix_alloc(covMat.rows(),covMat.cols());
95 eiToGsl(covMat, &gslCovMat);
99 for (
int k=0; k<repeats; ++k)
101 gsl_matrix_memcpy(gslCopy,gslCovMat);
102 gsl_linalg_cholesky_decomp(gslCopy);
103 acc += gsl_matrix_get(gslCopy,r,c);
111 gsl_matrix_free(gslCovMat);
120 int main(
int argc,
char* argv[])
122 const int dynsizes[] = {4,6,8,16,24,32,49,64,128,256,512,900,1500,0};
123 std::cout <<
"size LDLT LLT";
128 for (
int i=0; dynsizes[
i]>0; ++
i)
Robust Cholesky decomposition of a matrix with pivoting.
Namespace containing all symbols from the Eigen library.
__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.)
double value(int TIMER=CPU_TIMER) const
double best(int TIMER=CPU_TIMER) const
int main(int argc, char *argv[])
Traits::MatrixL matrixL() const
The matrix class, also used for vectors and row-vectors.
Traits::MatrixL matrixL() const