xref: /aosp_15_r20/external/eigen/test/simplicial_cholesky.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 
test_simplicial_cholesky_T()12*bf2c3715SXin Li template<typename T, typename I_, int flag> void test_simplicial_cholesky_T()
13*bf2c3715SXin Li {
14*bf2c3715SXin Li   typedef SparseMatrix<T,flag,I_> SparseMatrixType;
15*bf2c3715SXin Li   SimplicialCholesky<SparseMatrixType, Lower> chol_colmajor_lower_amd;
16*bf2c3715SXin Li   SimplicialCholesky<SparseMatrixType, Upper> chol_colmajor_upper_amd;
17*bf2c3715SXin Li   SimplicialLLT<     SparseMatrixType, Lower> llt_colmajor_lower_amd;
18*bf2c3715SXin Li   SimplicialLLT<     SparseMatrixType, Upper> llt_colmajor_upper_amd;
19*bf2c3715SXin Li   SimplicialLDLT<    SparseMatrixType, Lower> ldlt_colmajor_lower_amd;
20*bf2c3715SXin Li   SimplicialLDLT<    SparseMatrixType, Upper> ldlt_colmajor_upper_amd;
21*bf2c3715SXin Li   SimplicialLDLT<    SparseMatrixType, Lower, NaturalOrdering<I_> > ldlt_colmajor_lower_nat;
22*bf2c3715SXin Li   SimplicialLDLT<    SparseMatrixType, Upper, NaturalOrdering<I_> > ldlt_colmajor_upper_nat;
23*bf2c3715SXin Li 
24*bf2c3715SXin Li   check_sparse_spd_solving(chol_colmajor_lower_amd);
25*bf2c3715SXin Li   check_sparse_spd_solving(chol_colmajor_upper_amd);
26*bf2c3715SXin Li   check_sparse_spd_solving(llt_colmajor_lower_amd);
27*bf2c3715SXin Li   check_sparse_spd_solving(llt_colmajor_upper_amd);
28*bf2c3715SXin Li   check_sparse_spd_solving(ldlt_colmajor_lower_amd);
29*bf2c3715SXin Li   check_sparse_spd_solving(ldlt_colmajor_upper_amd);
30*bf2c3715SXin Li 
31*bf2c3715SXin Li   check_sparse_spd_determinant(chol_colmajor_lower_amd);
32*bf2c3715SXin Li   check_sparse_spd_determinant(chol_colmajor_upper_amd);
33*bf2c3715SXin Li   check_sparse_spd_determinant(llt_colmajor_lower_amd);
34*bf2c3715SXin Li   check_sparse_spd_determinant(llt_colmajor_upper_amd);
35*bf2c3715SXin Li   check_sparse_spd_determinant(ldlt_colmajor_lower_amd);
36*bf2c3715SXin Li   check_sparse_spd_determinant(ldlt_colmajor_upper_amd);
37*bf2c3715SXin Li 
38*bf2c3715SXin Li   check_sparse_spd_solving(ldlt_colmajor_lower_nat, (std::min)(300,EIGEN_TEST_MAX_SIZE), 1000);
39*bf2c3715SXin Li   check_sparse_spd_solving(ldlt_colmajor_upper_nat, (std::min)(300,EIGEN_TEST_MAX_SIZE), 1000);
40*bf2c3715SXin Li }
41*bf2c3715SXin Li 
EIGEN_DECLARE_TEST(simplicial_cholesky)42*bf2c3715SXin Li EIGEN_DECLARE_TEST(simplicial_cholesky)
43*bf2c3715SXin Li {
44*bf2c3715SXin Li   CALL_SUBTEST_11(( test_simplicial_cholesky_T<double,               int, ColMajor>() ));
45*bf2c3715SXin Li   CALL_SUBTEST_12(( test_simplicial_cholesky_T<std::complex<double>, int, ColMajor>() ));
46*bf2c3715SXin Li   CALL_SUBTEST_13(( test_simplicial_cholesky_T<double,          long int, ColMajor>() ));
47*bf2c3715SXin Li   CALL_SUBTEST_21(( test_simplicial_cholesky_T<double,               int, RowMajor>() ));
48*bf2c3715SXin Li   CALL_SUBTEST_22(( test_simplicial_cholesky_T<std::complex<double>, int, RowMajor>() ));
49*bf2c3715SXin Li   CALL_SUBTEST_23(( test_simplicial_cholesky_T<double,          long int, RowMajor>() ));
50*bf2c3715SXin Li }
51