incomplete_cholesky.cpp File Reference
#include "sparse_solver.h"
#include <Eigen/IterativeLinearSolvers>

Functions

template<typename T , typename I_ >
void test_incomplete_cholesky_T ()
 
template<int >
void bug1150 ()
 
void test_non_spd ()
 
 EIGEN_DECLARE_TEST (incomplete_cholesky)
 

Function Documentation

◆ bug1150()

template<int >
void bug1150 ( )
31  {
32  // regression for bug 1150
33  for (int N = 1; N < 20; ++N) {
34  Eigen::MatrixXd b(N, N);
35  b.setOnes();
36 
38  m.reserve(Eigen::VectorXi::Constant(N, 4));
39  for (int i = 0; i < N; ++i) {
40  m.insert(i, i) = 1;
41  m.coeffRef(i, i / 2) = 2;
42  m.coeffRef(i, i / 3) = 2;
43  m.coeffRef(i, i / 4) = 2;
44  }
45 
47  A = m * m.transpose();
48 
51  solver(A);
52  VERIFY(solver.preconditioner().info() == Eigen::Success);
53  VERIFY(solver.info() == Eigen::Success);
54  }
55 }
BiCGSTAB< SparseMatrix< double > > solver
Definition: BiCGSTAB_simple.cpp:5
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition: ConjugateGradient.h:152
Modified Incomplete Cholesky with dual threshold.
Definition: IncompleteCholesky.h:51
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
@ N
Definition: constructor.cpp:22
@ Lower
Definition: Constants.h:211
@ Upper
Definition: Constants.h:213
@ Success
Definition: Constants.h:440
int * m
Definition: level2_cplx_impl.h:294
#define VERIFY(a)
Definition: main.h:362

References b, i, Eigen::Lower, m, N, solver, Eigen::Success, Eigen::Upper, and VERIFY.

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( incomplete_cholesky  )
74  {
75  CALL_SUBTEST_1((test_incomplete_cholesky_T<double, int>()));
76  CALL_SUBTEST_2((test_incomplete_cholesky_T<std::complex<double>, int>()));
77  CALL_SUBTEST_3((test_incomplete_cholesky_T<double, long int>()));
78 
79  CALL_SUBTEST_4((bug1150<0>()));
81 }
void test_incomplete_cholesky_T()
Definition: incomplete_cholesky.cpp:15
void test_non_spd()
Definition: incomplete_cholesky.cpp:57
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22

References CALL_SUBTEST_1, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, test_incomplete_cholesky_T(), and test_non_spd().

◆ test_incomplete_cholesky_T()

template<typename T , typename I_ >
void test_incomplete_cholesky_T ( )
15  {
16  typedef SparseMatrix<T, 0, I_> SparseMatrixType;
22 
23  CALL_SUBTEST(check_sparse_spd_solving(cg_illt_lower_amd));
24  CALL_SUBTEST(check_sparse_spd_solving(cg_illt_lower_nat));
25  CALL_SUBTEST(check_sparse_spd_solving(cg_illt_upper_amd));
26  CALL_SUBTEST(check_sparse_spd_solving(cg_illt_upper_nat));
27  CALL_SUBTEST(check_sparse_spd_solving(cg_illt_uplo_amd));
28 }
#define CALL_SUBTEST(FUNC)
Definition: main.h:382
void check_sparse_spd_solving(Solver &solver, int maxSize=(std::min)(300, EIGEN_TEST_MAX_SIZE), int maxRealWorldSize=100000)
Definition: sparse_solver.h:392

References CALL_SUBTEST, and check_sparse_spd_solving().

Referenced by EIGEN_DECLARE_TEST().

◆ test_non_spd()

void test_non_spd ( )
57  {
59  A.insert(0, 0) = 0;
60  A.insert(1, 1) = 3;
61 
63 
64  // Recover original matrix.
65  Eigen::MatrixXd M = solver.permutationP().transpose() *
66  (solver.scalingS().asDiagonal().inverse() *
67  (solver.matrixL() * solver.matrixL().transpose() -
68  solver.shift() * Eigen::MatrixXd::Identity(A.rows(), A.cols())) *
69  solver.scalingS().asDiagonal().inverse()) *
70  solver.permutationP();
71  VERIFY_IS_APPROX(A.toDense(), M);
72 }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:192
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13

References Eigen::PlainObjectBase< Derived >::cols(), Eigen::PlainObjectBase< Derived >::rows(), solver, and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().