Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
gtsam
3rdparty
Eigen
test
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;
18
ConjugateGradient<SparseMatrixType, Lower, IncompleteCholesky<T, Lower, AMDOrdering<I>
> > cg_illt_lower_amd;
19
ConjugateGradient<SparseMatrixType, Lower, IncompleteCholesky<T, Lower, NaturalOrdering<I>
> > cg_illt_lower_nat;
20
ConjugateGradient<SparseMatrixType, Upper, IncompleteCholesky<T, Upper, AMDOrdering<I>
> > cg_illt_upper_amd;
21
ConjugateGradient<SparseMatrixType, Upper, IncompleteCholesky<T, Upper, NaturalOrdering<I>
> > cg_illt_upper_nat;
22
ConjugateGradient<SparseMatrixType, Upper|Lower, IncompleteCholesky<T, Lower, AMDOrdering<I>
> > cg_illt_uplo_amd;
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
void
test_incomplete_cholesky
()
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
45
Eigen::SparseMatrix<double>
m
(
N
,
N
);
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
55
Eigen::SparseMatrix<double>
A
;
56
A = m * m.
transpose
();
57
58
Eigen::ConjugateGradient<Eigen::SparseMatrix<double>
,
59
Eigen::Lower
|
Eigen::Upper
,
60
Eigen::IncompleteCholesky<double>
>
solver
( A );
61
VERIFY
(solver.preconditioner().info() ==
Eigen::Success
);
62
VERIFY
(solver.info() ==
Eigen::Success
);
63
}
64
#endif
65
}
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
b
Scalar * b
Definition:
benchVecAdd.cpp:17
Eigen::SparseMatrix
A versatible sparse matrix representation.
Definition:
SparseMatrix.h:96
Eigen::IncompleteCholesky
Modified Incomplete Cholesky with dual threshold.
Definition:
IncompleteCholesky.h:51
Eigen::ConjugateGradient
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition:
ConjugateGradient.h:97
solver
BiCGSTAB< SparseMatrix< double > > solver
Definition:
BiCGSTAB_simple.cpp:5
A
Matrix< SCALARA, Dynamic, Dynamic > A
Definition:
bench_gemm.cpp:35
N
#define N
Definition:
gksort.c:12
test_incomplete_cholesky
void test_incomplete_cholesky()
Definition:
incomplete_cholesky.cpp:32
Eigen::Lower
Definition:
Constants.h:204
test_incomplete_cholesky_T
void test_incomplete_cholesky_T()
Definition:
incomplete_cholesky.cpp:15
Eigen::SparseMatrixBase::transpose
TransposeReturnType transpose()
Definition:
SparseMatrixBase.h:349
Eigen::SparseMatrix::insert
Scalar & insert(Index row, Index col)
Definition:
SparseMatrix.h:1129
Eigen::Upper
Definition:
Constants.h:206
Eigen::Success
Definition:
Constants.h:432
Eigen::SparseMatrix::coeffRef
Scalar & coeffRef(Index row, Index col)
Definition:
SparseMatrix.h:206
CALL_SUBTEST
#define CALL_SUBTEST(FUNC)
Definition:
main.h:342
check_sparse_spd_solving
void check_sparse_spd_solving(Solver &solver, int maxSize=300, int maxRealWorldSize=100000)
Definition:
sparse_solver.h:269
VERIFY
#define VERIFY(a)
Definition:
main.h:325
sparse_solver.h
Eigen::SparseMatrix::reserve
void reserve(Index reserveSize)
Definition:
SparseMatrix.h:262
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:13