incomplete_cholesky.cpp
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2015-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 // #define EIGEN_DONT_VECTORIZE
10 // #define EIGEN_MAX_ALIGN_BYTES 0
11 #include "sparse_solver.h"
12 #include <Eigen/IterativeLinearSolvers>
13 #include <unsupported/Eigen/IterativeSolvers>
14 
15 template<typename T, typename I_> void test_incomplete_cholesky_T()
16 {
17  typedef SparseMatrix<T,0,I_> SparseMatrixType;
23 
24 
25  CALL_SUBTEST( check_sparse_spd_solving(cg_illt_lower_amd) );
26  CALL_SUBTEST( check_sparse_spd_solving(cg_illt_lower_nat) );
27  CALL_SUBTEST( check_sparse_spd_solving(cg_illt_upper_amd) );
28  CALL_SUBTEST( check_sparse_spd_solving(cg_illt_upper_nat) );
29  CALL_SUBTEST( check_sparse_spd_solving(cg_illt_uplo_amd) );
30 }
31 
32 template<int>
33 void bug1150()
34 {
35  // regression for bug 1150
36  for(int N = 1; N<20; ++N)
37  {
38  Eigen::MatrixXd b( N, N );
39  b.setOnes();
40 
42  m.reserve(Eigen::VectorXi::Constant(N,4));
43  for( int i = 0; i < N; ++i )
44  {
45  m.insert( i, i ) = 1;
46  m.coeffRef( i, i / 2 ) = 2;
47  m.coeffRef( i, i / 3 ) = 2;
48  m.coeffRef( i, i / 4 ) = 2;
49  }
50 
52  A = m * m.transpose();
53 
57  VERIFY(solver.preconditioner().info() == Eigen::Success);
58  VERIFY(solver.info() == Eigen::Success);
59  }
60 }
61 
62 EIGEN_DECLARE_TEST(incomplete_cholesky)
63 {
64  CALL_SUBTEST_1(( test_incomplete_cholesky_T<double,int>() ));
65  CALL_SUBTEST_2(( test_incomplete_cholesky_T<std::complex<double>, int>() ));
66  CALL_SUBTEST_3(( test_incomplete_cholesky_T<double,long int>() ));
67 
68  CALL_SUBTEST_1(( bug1150<0>() ));
69 }
Matrix3f m
EIGEN_DECLARE_TEST(incomplete_cholesky)
Scalar * b
Definition: benchVecAdd.cpp:17
A versatible sparse matrix representation.
Definition: SparseMatrix.h:96
Modified Incomplete Cholesky with dual threshold.
#define CALL_SUBTEST_3(FUNC)
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
BiCGSTAB< SparseMatrix< double > > solver
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
#define N
Definition: gksort.c:12
void bug1150()
#define CALL_SUBTEST_1(FUNC)
void test_incomplete_cholesky_T()
TransposeReturnType transpose()
Scalar & insert(Index row, Index col)
Scalar & coeffRef(Index row, Index col)
Definition: SparseMatrix.h:208
#define CALL_SUBTEST(FUNC)
Definition: main.h:399
#define VERIFY(a)
Definition: main.h:380
void reserve(Index reserveSize)
Definition: SparseMatrix.h:264
#define CALL_SUBTEST_2(FUNC)
void check_sparse_spd_solving(Solver &solver, int maxSize=(std::min)(300, EIGEN_TEST_MAX_SIZE), int maxRealWorldSize=100000)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:22