spqr_support.cpp File Reference
#include "sparse.h"
#include <Eigen/SPQRSupport>

Macros

#define EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS
 

Functions

template<typename MatrixType , typename DenseMat >
int generate_sparse_rectangular_problem (MatrixType &A, DenseMat &dA, int maxRows=300, int maxCols=300)
 
template<typename Scalar >
void test_spqr_scalar ()
 
 EIGEN_DECLARE_TEST (spqr_support)
 

Macro Definition Documentation

◆ EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS

#define EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( spqr_support  )
56  {
57  CALL_SUBTEST_1(test_spqr_scalar<double>());
58  CALL_SUBTEST_2(test_spqr_scalar<std::complex<double> >());
59 }
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
void test_spqr_scalar()
Definition: spqr_support.cpp:29

References CALL_SUBTEST_1, CALL_SUBTEST_2, and test_spqr_scalar().

◆ generate_sparse_rectangular_problem()

template<typename MatrixType , typename DenseMat >
int generate_sparse_rectangular_problem ( MatrixType A,
DenseMat &  dA,
int  maxRows = 300,
int  maxCols = 300 
)
14  {
15  eigen_assert(maxRows >= maxCols);
16  typedef typename MatrixType::Scalar Scalar;
17  int rows = internal::random<int>(1, maxRows);
18  int cols = internal::random<int>(1, rows);
19  double density = (std::max)(8. / (rows * cols), 0.01);
20 
21  A.resize(rows, cols);
22  dA.resize(rows, cols);
23  initSparse<Scalar>(density, dA, A, ForceNonZeroDiag);
24  A.makeCompressed();
25  return rows;
26 }
#define eigen_assert(x)
Definition: Macros.h:910
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:294
#define max(a, b)
Definition: datatypes.h:23
density
Definition: UniformPSDSelfTest.py:19
@ ForceNonZeroDiag
Definition: sparse.h:32

References cols, UniformPSDSelfTest::density, eigen_assert, ForceNonZeroDiag, max, Eigen::PlainObjectBase< Derived >::resize(), and rows.

Referenced by test_spqr_scalar().

◆ test_spqr_scalar()

template<typename Scalar >
void test_spqr_scalar ( )
29  {
31  MatrixType A;
34  DenseVector refX, x, b;
37 
38  Index m = A.rows();
39  b = DenseVector::Random(m);
40  solver.compute(A);
41  if (solver.info() != Success) {
42  std::cerr << "sparse QR factorization failed\n";
43  exit(0);
44  return;
45  }
46  x = solver.solve(b);
47  if (solver.info() != Success) {
48  std::cerr << "sparse QR factorization failed\n";
49  exit(0);
50  return;
51  }
52  // Compare with a dense solver
53  refX = dA.colPivHouseholderQr().solve(b);
54  VERIFY(x.isApprox(refX, test_precision<Scalar>()));
55 }
Matrix< Scalar, Dynamic, 1 > DenseVector
Definition: BenchSparseUtil.h:24
BiCGSTAB< SparseMatrix< double > > solver
Definition: BiCGSTAB_simple.cpp:5
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
Sparse QR factorization based on SuiteSparseQR library.
Definition: SuiteSparseQRSupport.h:67
@ Success
Definition: Constants.h:440
int * m
Definition: level2_cplx_impl.h:294
#define VERIFY(a)
Definition: main.h:362
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
list x
Definition: plotDoE.py:28
int generate_sparse_rectangular_problem(MatrixType &A, DenseMat &dA, int maxRows=300, int maxCols=300)
Definition: spqr_support.cpp:14

References b, generate_sparse_rectangular_problem(), m, Eigen::PlainObjectBase< Derived >::rows(), solver, Eigen::Success, VERIFY, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().