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

@@ -10,55 +10,50 @@
#include "sparse.h"
#include <Eigen/SPQRSupport>
template<typename MatrixType,typename DenseMat>
int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 300)
{
template <typename MatrixType, typename DenseMat>
int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 300) {
eigen_assert(maxRows >= maxCols);
typedef typename MatrixType::Scalar Scalar;
int rows = internal::random<int>(1,maxRows);
int cols = internal::random<int>(1,rows);
double density = (std::max)(8./(rows*cols), 0.01);
A.resize(rows,cols);
dA.resize(rows,cols);
initSparse<Scalar>(density, dA, A,ForceNonZeroDiag);
int rows = internal::random<int>(1, maxRows);
int cols = internal::random<int>(1, rows);
double density = (std::max)(8. / (rows * cols), 0.01);
A.resize(rows, cols);
dA.resize(rows, cols);
initSparse<Scalar>(density, dA, A, ForceNonZeroDiag);
A.makeCompressed();
return rows;
}
template<typename Scalar> void test_spqr_scalar()
{
typedef SparseMatrix<Scalar,ColMajor> MatrixType;
template <typename Scalar>
void test_spqr_scalar() {
typedef SparseMatrix<Scalar, ColMajor> MatrixType;
MatrixType A;
Matrix<Scalar,Dynamic,Dynamic> dA;
typedef Matrix<Scalar,Dynamic,1> DenseVector;
DenseVector refX,x,b;
SPQR<MatrixType> solver;
generate_sparse_rectangular_problem(A,dA);
Matrix<Scalar, Dynamic, Dynamic> dA;
typedef Matrix<Scalar, Dynamic, 1> DenseVector;
DenseVector refX, x, b;
SPQR<MatrixType> solver;
generate_sparse_rectangular_problem(A, dA);
Index m = A.rows();
b = DenseVector::Random(m);
solver.compute(A);
if (solver.info() != Success)
{
if (solver.info() != Success) {
std::cerr << "sparse QR factorization failed\n";
exit(0);
return;
}
x = solver.solve(b);
if (solver.info() != Success)
{
if (solver.info() != Success) {
std::cerr << "sparse QR factorization failed\n";
exit(0);
return;
}
//Compare with a dense solver
}
// Compare with a dense solver
refX = dA.colPivHouseholderQr().solve(b);
VERIFY(x.isApprox(refX,test_precision<Scalar>()));
VERIFY(x.isApprox(refX, test_precision<Scalar>()));
}
EIGEN_DECLARE_TEST(spqr_support)
{
EIGEN_DECLARE_TEST(spqr_support) {
CALL_SUBTEST_1(test_spqr_scalar<double>());
CALL_SUBTEST_2(test_spqr_scalar<std::complex<double> >());
}