diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-10-13 15:53:27 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-10-13 15:53:27 +0000 |
commit | 765219aa5180c40be86a380524db691a0fd5861b (patch) | |
tree | b3d2cab1eb2c43780a8da9a2e418e1adfd0e7cc3 /bench | |
parent | e2bd8623f88c3e7aa1c4a2eaa5dc7ab351219a33 (diff) |
Big API change in Cholesky module:
* rename Cholesky to LLT
* rename CholeskyWithoutSquareRoot to LDLT
* rename MatrixBase::cholesky() to llt()
* rename MatrixBase::choleskyNoSqrt() to ldlt()
* make {LLT,LDLT}::solve() API consistent with other modules
Note that we are going to keep a source compatibility untill the next beta release.
E.g., the "old" Cholesky* classes, etc are still available for some time.
To be clear, Eigen beta2 should be (hopefully) source compatible with beta1,
and so beta2 will contain all the deprecated API of beta1. Those features marked
as deprecated will be removed in beta3 (or in the final 2.0 if there is no beta 3 !).
Also includes various updated in sparse Cholesky.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/BenchSparseUtil.h | 2 | ||||
-rw-r--r-- | bench/benchCholesky.cpp | 32 | ||||
-rw-r--r-- | bench/sparse_product.cpp | 50 |
3 files changed, 49 insertions, 35 deletions
diff --git a/bench/BenchSparseUtil.h b/bench/BenchSparseUtil.h index 2c24c29e6..35c9a5263 100644 --- a/bench/BenchSparseUtil.h +++ b/bench/BenchSparseUtil.h @@ -16,7 +16,7 @@ USING_PART_OF_NAMESPACE_EIGEN #endif #ifndef SCALAR -#define SCALAR float +#define SCALAR double #endif typedef SCALAR Scalar; diff --git a/bench/benchCholesky.cpp b/bench/benchCholesky.cpp index f64b61b71..e998d8536 100644 --- a/bench/benchCholesky.cpp +++ b/bench/benchCholesky.cpp @@ -1,5 +1,5 @@ -// g++ -DNDEBUG -O3 -I.. benchCholesky.cpp -o benchCholesky && ./benchCholesky +// g++ -DNDEBUG -O3 -I.. benchLLT.cpp -o benchLLT && ./benchLLT // options: // -DBENCH_GSL -lgsl /usr/lib/libcblas.so.3 // -DEIGEN_DONT_VECTORIZE @@ -9,7 +9,7 @@ // -DSCALAR=double #include <Eigen/Array> -#include <Eigen/Cholesky> +#include <Eigen/LLT> #include <bench/BenchUtil.h> using namespace Eigen; @@ -24,7 +24,7 @@ using namespace Eigen; typedef float Scalar; template <typename MatrixType> -__attribute__ ((noinline)) void benchCholesky(const MatrixType& m) +__attribute__ ((noinline)) void benchLLT(const MatrixType& m) { int rows = m.rows(); int cols = m.cols(); @@ -54,7 +54,7 @@ __attribute__ ((noinline)) void benchCholesky(const MatrixType& m) timerNoSqrt.start(); for (int k=0; k<repeats; ++k) { - CholeskyWithoutSquareRoot<SquareMatrixType> cholnosqrt(covMat); + LDLT<SquareMatrixType> cholnosqrt(covMat); acc += cholnosqrt.matrixL().coeff(r,c); } timerNoSqrt.stop(); @@ -65,7 +65,7 @@ __attribute__ ((noinline)) void benchCholesky(const MatrixType& m) timerSqrt.start(); for (int k=0; k<repeats; ++k) { - Cholesky<SquareMatrixType> chol(covMat); + LLT<SquareMatrixType> chol(covMat); acc += chol.matrixL().coeff(r,c); } timerSqrt.stop(); @@ -124,17 +124,17 @@ int main(int argc, char* argv[]) std::cout << "\n"; for (uint i=0; dynsizes[i]>0; ++i) - benchCholesky(Matrix<Scalar,Dynamic,Dynamic>(dynsizes[i],dynsizes[i])); - -// benchCholesky(Matrix<Scalar,2,2>()); -// benchCholesky(Matrix<Scalar,3,3>()); -// benchCholesky(Matrix<Scalar,4,4>()); -// benchCholesky(Matrix<Scalar,5,5>()); -// benchCholesky(Matrix<Scalar,6,6>()); -// benchCholesky(Matrix<Scalar,7,7>()); -// benchCholesky(Matrix<Scalar,8,8>()); -// benchCholesky(Matrix<Scalar,12,12>()); -// benchCholesky(Matrix<Scalar,16,16>()); + benchLLT(Matrix<Scalar,Dynamic,Dynamic>(dynsizes[i],dynsizes[i])); + +// benchLLT(Matrix<Scalar,2,2>()); +// benchLLT(Matrix<Scalar,3,3>()); +// benchLLT(Matrix<Scalar,4,4>()); +// benchLLT(Matrix<Scalar,5,5>()); +// benchLLT(Matrix<Scalar,6,6>()); +// benchLLT(Matrix<Scalar,7,7>()); +// benchLLT(Matrix<Scalar,8,8>()); +// benchLLT(Matrix<Scalar,12,12>()); +// benchLLT(Matrix<Scalar,16,16>()); return 0; } diff --git a/bench/sparse_product.cpp b/bench/sparse_product.cpp index 846301fa5..edeb08c5d 100644 --- a/bench/sparse_product.cpp +++ b/bench/sparse_product.cpp @@ -21,6 +21,18 @@ #define MINDENSITY 0.0004 #endif +#ifndef NBTRIES +#define NBTRIES 10 +#endif + +#define BENCH(X) \ + timer.reset(); \ + for (int _j=0; _j<NBTRIES; ++_j) { \ + timer.start(); \ + for (int _k=0; _k<REPEAT; ++_k) { \ + X \ + } timer.stop(); } + int main(int argc, char *argv[]) { int rows = SIZE; @@ -77,32 +89,34 @@ int main(int argc, char *argv[]) { std::cout << "Eigen sparse\t" << density*100 << "%\n"; - timer.reset(); - timer.start(); - for (int k=0; k<REPEAT; ++k) - sm3 = sm1 * sm2; - timer.stop(); +// timer.reset(); +// timer.start(); + BENCH(for (int k=0; k<REPEAT; ++k) sm3 = sm1 * sm2;) +// timer.stop(); std::cout << " a * b:\t" << timer.value() << endl; timer.reset(); timer.start(); - for (int k=0; k<REPEAT; ++k) - sm3 = sm1.transpose() * sm2; - timer.stop(); +// std::cerr << "transpose...\n"; +// EigenSparseMatrix sm4 = sm1.transpose(); +// std::cout << sm4.nonZeros() << " == " << sm1.nonZeros() << "\n"; +// exit(1); +// std::cerr << "transpose OK\n"; +// std::cout << sm1 << "\n\n" << sm1.transpose() << "\n\n" << sm4.transpose() << "\n\n"; + BENCH(for (int k=0; k<REPEAT; ++k) sm3 = sm1.transpose() * sm2;) +// timer.stop(); std::cout << " a' * b:\t" << timer.value() << endl; - timer.reset(); - timer.start(); - for (int k=0; k<REPEAT; ++k) - sm3 = sm1.transpose() * sm2.transpose(); - timer.stop(); +// timer.reset(); +// timer.start(); + BENCH( for (int k=0; k<REPEAT; ++k) sm3 = sm1.transpose() * sm2.transpose(); ) +// timer.stop(); std::cout << " a' * b':\t" << timer.value() << endl; - timer.reset(); - timer.start(); - for (int k=0; k<REPEAT; ++k) - sm3 = sm1 * sm2.transpose(); - timer.stop(); +// timer.reset(); +// timer.start(); + BENCH( for (int k=0; k<REPEAT; ++k) sm3 = sm1 * sm2.transpose(); ) +// timer.stop(); std::cout << " a * b' :\t" << timer.value() << endl; } |