1*bf2c3715SXin Li // This file is part of Eigen, a lightweight C++ template library
2*bf2c3715SXin Li // for linear algebra.
3*bf2c3715SXin Li //
4*bf2c3715SXin Li // Copyright (C) 2011 Gael Guennebaud <[email protected]>
5*bf2c3715SXin Li //
6*bf2c3715SXin Li // This Source Code Form is subject to the terms of the Mozilla
7*bf2c3715SXin Li // Public License v. 2.0. If a copy of the MPL was not distributed
8*bf2c3715SXin Li // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9*bf2c3715SXin Li
10*bf2c3715SXin Li #include "sparse_solver.h"
11*bf2c3715SXin Li #include <Eigen/IterativeLinearSolvers>
12*bf2c3715SXin Li
test_conjugate_gradient_T()13*bf2c3715SXin Li template<typename T, typename I_> void test_conjugate_gradient_T()
14*bf2c3715SXin Li {
15*bf2c3715SXin Li typedef SparseMatrix<T,0,I_> SparseMatrixType;
16*bf2c3715SXin Li ConjugateGradient<SparseMatrixType, Lower > cg_colmajor_lower_diag;
17*bf2c3715SXin Li ConjugateGradient<SparseMatrixType, Upper > cg_colmajor_upper_diag;
18*bf2c3715SXin Li ConjugateGradient<SparseMatrixType, Lower|Upper> cg_colmajor_loup_diag;
19*bf2c3715SXin Li ConjugateGradient<SparseMatrixType, Lower, IdentityPreconditioner> cg_colmajor_lower_I;
20*bf2c3715SXin Li ConjugateGradient<SparseMatrixType, Upper, IdentityPreconditioner> cg_colmajor_upper_I;
21*bf2c3715SXin Li
22*bf2c3715SXin Li CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_diag) );
23*bf2c3715SXin Li CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_diag) );
24*bf2c3715SXin Li CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_loup_diag) );
25*bf2c3715SXin Li CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_I) );
26*bf2c3715SXin Li CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_I) );
27*bf2c3715SXin Li }
28*bf2c3715SXin Li
EIGEN_DECLARE_TEST(conjugate_gradient)29*bf2c3715SXin Li EIGEN_DECLARE_TEST(conjugate_gradient)
30*bf2c3715SXin Li {
31*bf2c3715SXin Li CALL_SUBTEST_1(( test_conjugate_gradient_T<double,int>() ));
32*bf2c3715SXin Li CALL_SUBTEST_2(( test_conjugate_gradient_T<std::complex<double>, int>() ));
33*bf2c3715SXin Li CALL_SUBTEST_3(( test_conjugate_gradient_T<double,long int>() ));
34*bf2c3715SXin Li }
35