xref: /aosp_15_r20/external/eigen/test/lscg.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
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_lscg_T()13*bf2c3715SXin Li template<typename T> void test_lscg_T()
14*bf2c3715SXin Li {
15*bf2c3715SXin Li   LeastSquaresConjugateGradient<SparseMatrix<T> > lscg_colmajor_diag;
16*bf2c3715SXin Li   LeastSquaresConjugateGradient<SparseMatrix<T>, IdentityPreconditioner> lscg_colmajor_I;
17*bf2c3715SXin Li   LeastSquaresConjugateGradient<SparseMatrix<T,RowMajor> > lscg_rowmajor_diag;
18*bf2c3715SXin Li   LeastSquaresConjugateGradient<SparseMatrix<T,RowMajor>, IdentityPreconditioner> lscg_rowmajor_I;
19*bf2c3715SXin Li 
20*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_square_solving(lscg_colmajor_diag)  );
21*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_square_solving(lscg_colmajor_I)     );
22*bf2c3715SXin Li 
23*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_colmajor_diag)  );
24*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_colmajor_I)     );
25*bf2c3715SXin Li 
26*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_square_solving(lscg_rowmajor_diag)  );
27*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_square_solving(lscg_rowmajor_I)     );
28*bf2c3715SXin Li 
29*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_diag)  );
30*bf2c3715SXin Li   CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_I)     );
31*bf2c3715SXin Li }
32*bf2c3715SXin Li 
EIGEN_DECLARE_TEST(lscg)33*bf2c3715SXin Li EIGEN_DECLARE_TEST(lscg)
34*bf2c3715SXin Li {
35*bf2c3715SXin Li   CALL_SUBTEST_1(test_lscg_T<double>());
36*bf2c3715SXin Li   CALL_SUBTEST_2(test_lscg_T<std::complex<double> >());
37*bf2c3715SXin Li }
38