minres.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) 2012 Giacomo Po <gpo@ucla.edu>
5 // Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <cmath>
11 
12 #include "../../test/sparse_solver.h"
13 #include <Eigen/IterativeSolvers>
14 
15 template<typename T> void test_minres_T()
16 {
17  // Identity preconditioner
18  MINRES<SparseMatrix<T>, Lower, IdentityPreconditioner > minres_colmajor_lower_I;
19  MINRES<SparseMatrix<T>, Upper, IdentityPreconditioner > minres_colmajor_upper_I;
20 
21  // Diagonal preconditioner
22  MINRES<SparseMatrix<T>, Lower, DiagonalPreconditioner<T> > minres_colmajor_lower_diag;
23  MINRES<SparseMatrix<T>, Upper, DiagonalPreconditioner<T> > minres_colmajor_upper_diag;
24  MINRES<SparseMatrix<T>, Lower|Upper, DiagonalPreconditioner<T> > minres_colmajor_uplo_diag;
25 
26  // call tests for SPD matrix
27  CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_lower_I) );
28  CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_upper_I) );
29 
30  CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_lower_diag) );
31  CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_upper_diag) );
32  CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_uplo_diag) );
33 
34  // TO DO: symmetric semi-definite matrix
35  // TO DO: symmetric indefinite matrix
36 
37 }
38 
40 {
41  CALL_SUBTEST_1(test_minres_T<double>());
42 // CALL_SUBTEST_2(test_minres_T<std::compex<double> >());
43 
44 }
A preconditioner based on the digonal entries.
#define CALL_SUBTEST_1(FUNC)
A minimal residual solver for sparse symmetric problems.
Definition: MINRES.h:143
#define CALL_SUBTEST(FUNC)
Definition: main.h:399
A naive preconditioner which approximates any matrix as the identity matrix.
void test_minres_T()
Definition: minres.cpp:15
EIGEN_DECLARE_TEST(minres)
Definition: minres.cpp:39
EIGEN_DONT_INLINE void minres(const MatrixType &mat, const Rhs &rhs, Dest &x, const Preconditioner &precond, Index &iters, typename Dest::RealScalar &tol_error)
Definition: MINRES.h:32
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:55