solverbase.h
Go to the documentation of this file.
1 #ifndef TEST_SOLVERBASE_H
2 #define TEST_SOLVERBASE_H
3 
4 template<typename DstType, typename RhsType, typename MatrixType, typename SolverType>
5 void check_solverbase(const MatrixType& matrix, const SolverType& solver, Index rows, Index cols, Index cols2)
6 {
7  // solve
8  DstType m2 = DstType::Random(cols,cols2);
9  RhsType m3 = matrix*m2;
10  DstType solver_solution = DstType::Random(cols,cols2);
11  solver._solve_impl(m3, solver_solution);
12  VERIFY_IS_APPROX(m3, matrix*solver_solution);
13  solver_solution = DstType::Random(cols,cols2);
14  solver_solution = solver.solve(m3);
15  VERIFY_IS_APPROX(m3, matrix*solver_solution);
16  // test solve with transposed
17  m3 = RhsType::Random(rows,cols2);
18  m2 = matrix.transpose()*m3;
19  RhsType solver_solution2 = RhsType::Random(rows,cols2);
20  solver.template _solve_impl_transposed<false>(m2, solver_solution2);
21  VERIFY_IS_APPROX(m2, matrix.transpose()*solver_solution2);
22  solver_solution2 = RhsType::Random(rows,cols2);
23  solver_solution2 = solver.transpose().solve(m2);
24  VERIFY_IS_APPROX(m2, matrix.transpose()*solver_solution2);
25  // test solve with conjugate transposed
26  m3 = RhsType::Random(rows,cols2);
27  m2 = matrix.adjoint()*m3;
28  solver_solution2 = RhsType::Random(rows,cols2);
29  solver.template _solve_impl_transposed<true>(m2, solver_solution2);
30  VERIFY_IS_APPROX(m2, matrix.adjoint()*solver_solution2);
31  solver_solution2 = RhsType::Random(rows,cols2);
32  solver_solution2 = solver.adjoint().solve(m2);
33  VERIFY_IS_APPROX(m2, matrix.adjoint()*solver_solution2);
34 }
35 
36 #endif // TEST_SOLVERBASE_H
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
solver
BiCGSTAB< SparseMatrix< double > > solver
Definition: BiCGSTAB_simple.cpp:5
check_solverbase
void check_solverbase(const MatrixType &matrix, const SolverType &solver, Index rows, Index cols, Index cols2)
Definition: solverbase.h:5
m2
MatrixType m2(n_dims)
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: gtsam/3rdparty/Eigen/blas/common.h:110
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:15
m3
static const DiscreteKey m3(M(3), 2)
cols
int cols
Definition: Tutorial_commainit_02.cpp:1
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:29