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 
33 {
34  CALL_SUBTEST_1(( test_incomplete_cholesky_T<double,int>() ));
35  CALL_SUBTEST_2(( test_incomplete_cholesky_T<std::complex<double>, int>() ));
36  CALL_SUBTEST_3(( test_incomplete_cholesky_T<double,long int>() ));
37 
38 #ifdef EIGEN_TEST_PART_1
39  // regression for bug 1150
40  for(int N = 1; N<20; ++N)
41  {
42  Eigen::MatrixXd b( N, N );
43  b.setOnes();
44 
46  m.reserve(Eigen::VectorXi::Constant(N,4));
47  for( int i = 0; i < N; ++i )
48  {
49  m.insert( i, i ) = 1;
50  m.coeffRef( i, i / 2 ) = 2;
51  m.coeffRef( i, i / 3 ) = 2;
52  m.coeffRef( i, i / 4 ) = 2;
53  }
54 
56  A = m * m.transpose();
57 
61  VERIFY(solver.preconditioner().info() == Eigen::Success);
62  VERIFY(solver.info() == Eigen::Success);
63  }
64 #endif
65 }
Matrix3f m
Scalar * b
Definition: benchVecAdd.cpp:17
A versatible sparse matrix representation.
Definition: SparseMatrix.h:96
Modified Incomplete Cholesky with dual threshold.
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
BiCGSTAB< SparseMatrix< double > > solver
Matrix< SCALARA, Dynamic, Dynamic > A
Definition: bench_gemm.cpp:35
#define N
Definition: gksort.c:12
void test_incomplete_cholesky()
void test_incomplete_cholesky_T()
TransposeReturnType transpose()
Scalar & insert(Index row, Index col)
Scalar & coeffRef(Index row, Index col)
Definition: SparseMatrix.h:206
#define CALL_SUBTEST(FUNC)
Definition: main.h:342
void check_sparse_spd_solving(Solver &solver, int maxSize=300, int maxRealWorldSize=100000)
#define VERIFY(a)
Definition: main.h:325
void reserve(Index reserveSize)
Definition: SparseMatrix.h:262


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:13