numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::linear::iterative_solver_base< Derived > Class Template Reference

Base class of iterative solvers. More...

#include <num_collect/linear/iterative_solver_base.h>

+ Inheritance diagram for num_collect::linear::iterative_solver_base< Derived >:
+ Collaboration diagram for num_collect::linear::iterative_solver_base< Derived >:

Public Types

enum  { ColsAtCompileTime = MatrixType::ColsAtCompileTime , MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }
 
using matrix_type = MatrixType
 Type of matrices.
 
using MatrixType
 Type of matrices. (For Eigen library.)
 
using real_scalar_type = RealScalar
 Type of real scalars.
 
using RealScalar = typename MatrixType::RealScalar
 Type of real scalars. (For Eigen library.)
 
using Scalar = typename MatrixType::Scalar
 Type of scalars. (For Eigen library.)
 
using scalar_type = Scalar
 Type of scalars.
 
using storage_index_type = StorageIndex
 Type of indices in storages.
 
using StorageIndex = typename MatrixType::StorageIndex
 Type of indices in storages. (For Eigen library.)
 

Public Member Functions

 iterative_solver_base ()
 Constructor.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void _solve_impl (const Right &right, Solution &solution) const
 Internal function to solve for a right-hand-side vector.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void _solve_with_guess_impl (const Right &right, Solution &solution) const
 Internal function to solve for a right-hand-side vector.
 
auto cols () const noexcept -> Eigen::Index
 Get the number of columns.
 
auto compute (const matrix_type &coeff) -> Derived &
 Initialize this solver using a coefficient matrix.
 
auto max_iterations () const noexcept -> index_type
 Get the maximum number of iterations.
 
auto max_iterations (index_type val) -> Derived &
 Set the maximum number of iterations.
 
auto rows () const noexcept -> Eigen::Index
 Get the number of rows.
 
template<base::concepts::dense_vector_of< scalar_type > Right>
auto solve (const Right &right) const -> Eigen::Solve< Derived, Right >
 Solve a linear equation.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
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.
 
auto tolerance () const noexcept -> real_scalar_type
 Get the tolerance of rate of residual.
 
auto tolerance (const real_scalar_type &val) -> Derived &
 Set the tolerance of rate of residual.
 

Protected Types

using Base = Eigen::SparseSolverBase<Derived>
 Base class.
 

Protected Member Functions

auto coeff () const noexcept -> const matrix_type &
 Get the coefficient matrix.
 

Private Attributes

const matrix_typecoeff_ {nullptr}
 Coefficient matrix.
 
index_type max_iterations_ {default_max_iterations}
 Maximum number of iterations.
 
real_scalar_type tolerance_ {default_tolerance}
 Tolerance of rate of residual.
 

Static Private Attributes

static constexpr index_type default_max_iterations = 10000
 Default maximum number of iterations.
 
static constexpr auto default_tolerance
 Default tolerance of rate of residual.
 

Detailed Description

template<typename Derived>
class num_collect::linear::iterative_solver_base< Derived >

Base class of iterative solvers.

Template Parameters
DerivedDerived class.

Definition at line 53 of file iterative_solver_base.h.

Member Typedef Documentation

◆ Base

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::Base = Eigen::SparseSolverBase<Derived>
protected

Base class.

Definition at line 56 of file iterative_solver_base.h.

◆ matrix_type

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::matrix_type = MatrixType

Type of matrices.

Definition at line 71 of file iterative_solver_base.h.

◆ MatrixType

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::MatrixType
Initial value:
typename impl::iterative_solver_traits<Derived>::matrix_type

Type of matrices. (For Eigen library.)

Definition at line 61 of file iterative_solver_base.h.

◆ real_scalar_type

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::real_scalar_type = RealScalar

Type of real scalars.

Definition at line 77 of file iterative_solver_base.h.

◆ RealScalar

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::RealScalar = typename MatrixType::RealScalar

Type of real scalars. (For Eigen library.)

Definition at line 68 of file iterative_solver_base.h.

◆ Scalar

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::Scalar = typename MatrixType::Scalar

Type of scalars. (For Eigen library.)

Definition at line 64 of file iterative_solver_base.h.

◆ scalar_type

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::scalar_type = Scalar

Type of scalars.

Definition at line 73 of file iterative_solver_base.h.

◆ storage_index_type

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::storage_index_type = StorageIndex

Type of indices in storages.

Definition at line 75 of file iterative_solver_base.h.

◆ StorageIndex

template<typename Derived >
using num_collect::linear::iterative_solver_base< Derived >::StorageIndex = typename MatrixType::StorageIndex

Type of indices in storages. (For Eigen library.)

Definition at line 66 of file iterative_solver_base.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
ColsAtCompileTime 

Number of columns at compile time. (For Eigen library.)

MaxColsAtCompileTime 

Maximum number of columns at compile time. (For Eigen library.)

Definition at line 79 of file iterative_solver_base.h.

Constructor & Destructor Documentation

◆ iterative_solver_base()

template<typename Derived >
num_collect::linear::iterative_solver_base< Derived >::iterative_solver_base ( )
inline

Constructor.

Definition at line 91 of file iterative_solver_base.h.

Member Function Documentation

◆ _solve_impl()

template<typename Derived >
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void num_collect::linear::iterative_solver_base< Derived >::_solve_impl ( const Right & right,
Solution & solution ) const
inline

Internal function to solve for a right-hand-side vector.

Template Parameters
RightType of the right-hand-side vector.
SolutionType of the solution vector.
Parameters
[in]rightRight-hand-side vector.
[in,out]solutionSolution vector.

Definition at line 212 of file iterative_solver_base.h.

◆ _solve_with_guess_impl()

template<typename Derived >
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void num_collect::linear::iterative_solver_base< Derived >::_solve_with_guess_impl ( const Right & right,
Solution & solution ) const
inline

Internal function to solve for a right-hand-side vector.

Template Parameters
RightType of the right-hand-side vector.
SolutionType of the solution vector.
Parameters
[in]rightRight-hand-side vector.
[in,out]solutionSolution vector.

Definition at line 230 of file iterative_solver_base.h.

◆ coeff()

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::coeff ( ) const -> const matrix_type&
inlinenodiscardprotectednoexcept

Get the coefficient matrix.

Returns
Coefficient matrix.

Definition at line 243 of file iterative_solver_base.h.

◆ cols()

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::cols ( ) const -> Eigen::Index
inlinenodiscardnoexcept

Get the number of columns.

Returns
Number of columns.

Definition at line 121 of file iterative_solver_base.h.

◆ compute()

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::compute ( const matrix_type & coeff) -> Derived&
inline

Initialize this solver using a coefficient matrix.

Note
This function will save the pointer to the argument.
Parameters
[in]coeffCoefficient matrix.
Returns
This.

Definition at line 101 of file iterative_solver_base.h.

◆ max_iterations() [1/2]

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::max_iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the maximum number of iterations.

Returns
Maximum number of iterations.

Definition at line 152 of file iterative_solver_base.h.

◆ max_iterations() [2/2]

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::max_iterations ( index_type val) -> Derived&
inline

Set the maximum number of iterations.

Parameters
[in]valMaximum number of iterations.
Returns
This.

Definition at line 162 of file iterative_solver_base.h.

◆ rows()

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::rows ( ) const -> Eigen::Index
inlinenodiscardnoexcept

Get the number of rows.

Returns
Number of rows.

Definition at line 112 of file iterative_solver_base.h.

◆ solve()

template<typename Derived >
template<base::concepts::dense_vector_of< scalar_type > Right>
auto num_collect::linear::iterative_solver_base< Derived >::solve ( const Right & right) const -> Eigen::Solve<Derived, Right>
inlinenodiscard

Solve a linear equation.

Template Parameters
RightType of the right-hand-side vector.
Parameters
[in]rightRight-hand-side vector.
Returns
Expression to solve the linear equation.

Definition at line 177 of file iterative_solver_base.h.

◆ solve_with_guess()

template<typename Derived >
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
auto num_collect::linear::iterative_solver_base< Derived >::solve_with_guess ( const Right & right,
const Solution & solution ) const -> Eigen::SolveWithGuess<Derived, Right, Solution>
inlinenodiscard

Solve a linear equation with a guess of the solution.

Template Parameters
RightType of the right-hand-side vector.
SolutionType of the solution vector.
Parameters
[in]rightRight-hand-side vector.
[in]solutionSolution vector.
Returns
Expression to solve the linear equation.

Definition at line 194 of file iterative_solver_base.h.

◆ tolerance() [1/2]

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::tolerance ( ) const -> real_scalar_type
inlinenodiscardnoexcept

Get the tolerance of rate of residual.

Returns
Tolerance of rate of residual.

Definition at line 130 of file iterative_solver_base.h.

◆ tolerance() [2/2]

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::tolerance ( const real_scalar_type & val) -> Derived&
inline

Set the tolerance of rate of residual.

Parameters
[in]valTolerance of rate of residual.
Returns
This.

Definition at line 140 of file iterative_solver_base.h.

Member Data Documentation

◆ coeff_

template<typename Derived >
const matrix_type* num_collect::linear::iterative_solver_base< Derived >::coeff_ {nullptr}
private

Coefficient matrix.

Definition at line 263 of file iterative_solver_base.h.

◆ default_max_iterations

template<typename Derived >
index_type num_collect::linear::iterative_solver_base< Derived >::default_max_iterations = 10000
staticconstexprprivate

Default maximum number of iterations.

Definition at line 250 of file iterative_solver_base.h.

◆ default_tolerance

template<typename Derived >
auto num_collect::linear::iterative_solver_base< Derived >::default_tolerance
staticconstexprprivate
Initial value:
=
Eigen::NumTraits<real_scalar_type>::dummy_precision()

Default tolerance of rate of residual.

Definition at line 256 of file iterative_solver_base.h.

◆ max_iterations_

template<typename Derived >
index_type num_collect::linear::iterative_solver_base< Derived >::max_iterations_ {default_max_iterations}
private

Maximum number of iterations.

Definition at line 253 of file iterative_solver_base.h.

◆ tolerance_

template<typename Derived >
real_scalar_type num_collect::linear::iterative_solver_base< Derived >::tolerance_ {default_tolerance}
private

Tolerance of rate of residual.

Definition at line 260 of file iterative_solver_base.h.


The documentation for this class was generated from the following file: