Clang-format tests, examples, libraries, benchmarks, etc.

This commit is contained in:
Antonio Sánchez
2023-12-05 21:22:55 +00:00
committed by Rasmus Munk Larsen
parent 3252ecc7a4
commit 46e9cdb7fe
876 changed files with 33453 additions and 37795 deletions

View File

@@ -30,47 +30,49 @@
#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(); }
#define BENCH(X) \
timer.reset(); \
for (int _j = 0; _j < NBTRIES; ++_j) { \
timer.start(); \
for (int _k = 0; _k < REPEAT; ++_k) { \
X \
} \
timer.stop(); \
}
typedef Matrix<Scalar,Dynamic,1> VectorX;
typedef Matrix<Scalar, Dynamic, 1> VectorX;
#include <Eigen/LU>
template<int Backend>
void doEigen(const char* name, const EigenSparseMatrix& sm1, const VectorX& b, VectorX& x, int flags = 0)
{
template <int Backend>
void doEigen(const char* name, const EigenSparseMatrix& sm1, const VectorX& b, VectorX& x, int flags = 0) {
std::cout << name << "..." << std::flush;
BenchTimer timer; timer.start();
SparseLU<EigenSparseMatrix,Backend> lu(sm1, flags);
BenchTimer timer;
timer.start();
SparseLU<EigenSparseMatrix, Backend> lu(sm1, flags);
timer.stop();
if (lu.succeeded())
std::cout << ":\t" << timer.value() << endl;
else
{
else {
std::cout << ":\t FAILED" << endl;
return;
}
bool ok;
timer.reset(); timer.start();
ok = lu.solve(b,&x);
timer.reset();
timer.start();
ok = lu.solve(b, &x);
timer.stop();
if (ok)
std::cout << " solve:\t" << timer.value() << endl;
else
std::cout << " solve:\t" << " FAILED" << endl;
std::cout << " solve:\t"
<< " FAILED" << endl;
//std::cout << x.transpose() << "\n";
// std::cout << x.transpose() << "\n";
}
int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
int rows = SIZE;
int cols = SIZE;
float density = DENSITY;
@@ -81,19 +83,18 @@ int main(int argc, char *argv[])
bool densedone = false;
//for (float density = DENSITY; density>=MINDENSITY; density*=0.5)
// float density = 0.5;
// for (float density = DENSITY; density>=MINDENSITY; density*=0.5)
// float density = 0.5;
{
EigenSparseMatrix sm1(rows, cols);
fillMatrix(density, rows, cols, sm1);
// dense matrices
#ifdef DENSEMATRIX
if (!densedone)
{
// dense matrices
#ifdef DENSEMATRIX
if (!densedone) {
densedone = true;
std::cout << "Eigen Dense\t" << density*100 << "%\n";
DenseMatrix m1(rows,cols);
std::cout << "Eigen Dense\t" << density * 100 << "%\n";
DenseMatrix m1(rows, cols);
eiToDense(sm1, m1);
BenchTimer timer;
@@ -104,29 +105,27 @@ int main(int argc, char *argv[])
timer.reset();
timer.start();
lu.solve(b,&x);
lu.solve(b, &x);
timer.stop();
std::cout << " solve:\t" << timer.value() << endl;
// std::cout << b.transpose() << "\n";
// std::cout << x.transpose() << "\n";
// std::cout << b.transpose() << "\n";
// std::cout << x.transpose() << "\n";
}
#endif
#endif
#ifdef EIGEN_UMFPACK_SUPPORT
#ifdef EIGEN_UMFPACK_SUPPORT
x.setZero();
doEigen<Eigen::UmfPack>("Eigen/UmfPack (auto)", sm1, b, x, 0);
#endif
#endif
#ifdef EIGEN_SUPERLU_SUPPORT
#ifdef EIGEN_SUPERLU_SUPPORT
x.setZero();
doEigen<Eigen::SuperLU>("Eigen/SuperLU (nat)", sm1, b, x, Eigen::NaturalOrdering);
// doEigen<Eigen::SuperLU>("Eigen/SuperLU (MD AT+A)", sm1, b, x, Eigen::MinimumDegree_AT_PLUS_A);
// doEigen<Eigen::SuperLU>("Eigen/SuperLU (MD ATA)", sm1, b, x, Eigen::MinimumDegree_ATA);
// doEigen<Eigen::SuperLU>("Eigen/SuperLU (MD AT+A)", sm1, b, x, Eigen::MinimumDegree_AT_PLUS_A);
// doEigen<Eigen::SuperLU>("Eigen/SuperLU (MD ATA)", sm1, b, x, Eigen::MinimumDegree_ATA);
doEigen<Eigen::SuperLU>("Eigen/SuperLU (COLAMD)", sm1, b, x, Eigen::ColApproxMinimumDegree);
#endif
#endif
}
return 0;
}