23#include <Eigen/IterativeLinearSolvers>
24#include <Eigen/SparseCore>
42template <
typename Solver,
typename =
void>
52template <
typename Derived>
56 using Base = Eigen::SparseSolverBase<Derived>;
57 using Base::m_isInitialized;
64 using Scalar =
typename MatrixType::Scalar;
103 m_isInitialized =
true;
112 [[nodiscard]]
auto rows() const noexcept ->
Eigen::Index {
113 return coeff().rows();
121 [[nodiscard]]
auto cols() const noexcept ->
Eigen::Index {
122 return coeff().cols();
142 "Tolerance of rate of residual must be positive value.");
164 "Maximum number of iterations must be a positive integer.");
176 template <base::concepts::dense_vector_of<scalar_type> Right>
177 [[nodiscard]]
auto solve(
const Right& right)
const
178 -> Eigen::Solve<Derived, Right> {
180 return Eigen::Solve<Derived, Right>(derived(), right);
192 template <base::concepts::dense_vector_of<scalar_type> Right,
193 base::concepts::dense_vector_of<scalar_type> Solution>
195 const Right& right,
const Solution& solution)
const
196 -> Eigen::SolveWithGuess<Derived, Right, Solution> {
198 return Eigen::SolveWithGuess<Derived, Right, Solution>(
199 derived(), right, solution);
210 template <base::concepts::dense_vector_of<scalar_type> Right,
211 base::concepts::dense_vector_of<scalar_type> Solution>
214 const Right& right, Solution& solution)
const {
217 derived()._solve_with_guess_impl(right, solution);
228 template <base::concepts::dense_vector_of<scalar_type> Right,
229 base::concepts::dense_vector_of<scalar_type> Solution>
232 const Right& right, Solution& solution)
const {
234 derived().solve_vector_in_place(right, solution);
257 Eigen::NumTraits<real_scalar_type>::dummy_precision();
Definition of assertion macros.
#define NUM_COLLECT_ASSERT(CONDITION)
Macro to check whether a condition is satisfied.
Base class of iterative solvers.
typename MatrixType::RealScalar RealScalar
Type of real scalars. (For Eigen library.)
StorageIndex storage_index_type
Type of indices in storages.
index_type max_iterations_
Maximum number of iterations.
static constexpr index_type default_max_iterations
Default maximum number of iterations.
typename impl::iterative_solver_traits< Derived >::matrix_type MatrixType
Type of matrices. (For Eigen library.)
auto coeff() const noexcept -> const matrix_type &
Get the coefficient matrix.
@ MaxColsAtCompileTime
Maximum number of columns at compile time. (For Eigen library.)
@ ColsAtCompileTime
Number of columns at compile time. (For Eigen library.)
MatrixType matrix_type
Type of matrices.
Scalar scalar_type
Type of scalars.
Eigen::SparseSolverBase< Derived > Base
Base class.
auto max_iterations(index_type val) -> Derived &
Set the maximum number of iterations.
auto solve_with_guess(const Right &right, const Solution &solution) const -> Eigen::SolveWithGuess< Derived, Right, Solution >
Solve a linear equation with a guess of the solution.
const matrix_type * coeff_
Coefficient matrix.
auto solve(const Right &right) const -> Eigen::Solve< Derived, Right >
Solve a linear equation.
typename MatrixType::StorageIndex StorageIndex
Type of indices in storages. (For Eigen library.)
auto cols() const noexcept -> Eigen::Index
Get the number of columns.
void _solve_impl(const Right &right, Solution &solution) const
Internal function to solve for a right-hand-side vector.
iterative_solver_base()
Constructor.
auto tolerance() const noexcept -> real_scalar_type
Get the tolerance of rate of residual.
static constexpr auto default_tolerance
Default tolerance of rate of residual.
auto tolerance(const real_scalar_type &val) -> Derived &
Set the tolerance of rate of residual.
typename MatrixType::Scalar Scalar
Type of scalars. (For Eigen library.)
auto rows() const noexcept -> Eigen::Index
Get the number of rows.
real_scalar_type tolerance_
Tolerance of rate of residual.
RealScalar real_scalar_type
Type of real scalars.
auto compute(const matrix_type &coeff) -> Derived &
Initialize this solver using a coefficient matrix.
void _solve_with_guess_impl(const Right &right, Solution &solution) const
Internal function to solve for a right-hand-side vector.
auto max_iterations() const noexcept -> index_type
Get the maximum number of iterations.
Definition of dense_vector_of concept.
Definition of exceptions.
Definition of index_type type.
Definition of macros for logging.
Namespace of Eigen library.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of solvers of linear equations.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Traits of iterative solvers.