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

Class to solve linear equations using Gauss-Seidel iteration [7]. More...

#include <num_collect/linear/gauss_seidel_iterative_solver.h>

+ Inheritance diagram for num_collect::linear::gauss_seidel_iterative_solver< Matrix >:
+ Collaboration diagram for num_collect::linear::gauss_seidel_iterative_solver< Matrix >:

Public Types

using base_type
 Type of the base class.
 
using vector_type = Eigen::VectorX<scalar_type>
 Type of vectors.
 
- Public Types inherited from num_collect::linear::iterative_solver_base< gauss_seidel_iterative_solver< Matrix > >
enum  
 
using matrix_type
 Type of matrices.
 
using MatrixType
 Type of matrices. (For Eigen library.)
 
using real_scalar_type
 Type of real scalars.
 
using RealScalar
 Type of real scalars. (For Eigen library.)
 
using Scalar
 Type of scalars. (For Eigen library.)
 
using scalar_type
 Type of scalars.
 
using storage_index_type
 Type of indices in storages.
 
using StorageIndex
 Type of indices in storages. (For Eigen library.)
 

Public Member Functions

 gauss_seidel_iterative_solver ()=default
 Constructor.
 
void compute (const matrix_type &coeff)
 Prepare to solve.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto residual_rate () const noexcept -> scalar_type
 Get the rate of the last residual.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void solve_vector_in_place (const Right &right, Solution &solution) const
 Iterate repeatedly until stop criterion is satisfied for a vector.
 
- Public Member Functions inherited from num_collect::linear::iterative_solver_base< gauss_seidel_iterative_solver< Matrix > >
 iterative_solver_base ()
 Constructor.
 
void _solve_impl (const Right &right, Solution &solution) const
 Internal function to solve for a right-hand-side vector.
 
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) -> gauss_seidel_iterative_solver< Matrix > &
 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) -> gauss_seidel_iterative_solver< Matrix > &
 Set the maximum number of iterations.
 
auto rows () const noexcept -> Eigen::Index
 Get the number of rows.
 
auto solve (const Right &right) const -> Eigen::Solve< gauss_seidel_iterative_solver< Matrix >, Right >
 Solve a linear equation.
 
auto solve_with_guess (const Right &right, const Solution &solution) const -> Eigen::SolveWithGuess< gauss_seidel_iterative_solver< Matrix >, 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) -> gauss_seidel_iterative_solver< Matrix > &
 Set the tolerance of rate of residual.
 

Private Member Functions

template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void iterate (const matrix_type &coeff_ref, const Right &right, Solution &solution) const
 Iterate once.
 

Private Attributes

vector_type diag_ {}
 Diagonal coefficients.
 
vector_type inv_diag_ {}
 Inverse of diagonal coefficients.
 
index_type iterations_ {}
 Number of iterations.
 
scalar_type residual_ {}
 Last residual.
 
scalar_type residual_rate_ {}
 Rate of last residual.
 

Additional Inherited Members

- Protected Types inherited from num_collect::linear::iterative_solver_base< gauss_seidel_iterative_solver< Matrix > >
using Base
 Base class.
 
- Protected Member Functions inherited from num_collect::linear::iterative_solver_base< gauss_seidel_iterative_solver< Matrix > >
auto coeff () const noexcept -> const matrix_type &
 Get the coefficient matrix.
 

Detailed Description

template<base::concepts::sparse_matrix Matrix>
class num_collect::linear::gauss_seidel_iterative_solver< Matrix >

Class to solve linear equations using Gauss-Seidel iteration [7].

Template Parameters
MatrixType of the matrix.

Definition at line 64 of file gauss_seidel_iterative_solver.h.

Member Typedef Documentation

◆ base_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::gauss_seidel_iterative_solver< Matrix >::base_type
Initial value:
iterative_solver_base<gauss_seidel_iterative_solver<Matrix>>

Type of the base class.

Definition at line 72 of file gauss_seidel_iterative_solver.h.

◆ vector_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::gauss_seidel_iterative_solver< Matrix >::vector_type = Eigen::VectorX<scalar_type>

Type of vectors.

Definition at line 85 of file gauss_seidel_iterative_solver.h.

Member Function Documentation

◆ compute()

template<base::concepts::sparse_matrix Matrix>
void num_collect::linear::gauss_seidel_iterative_solver< Matrix >::compute ( const matrix_type & coeff)
inline

Prepare to solve.

Parameters
[in]coeffCoefficient matrix.

Definition at line 97 of file gauss_seidel_iterative_solver.h.

◆ iterate()

template<base::concepts::sparse_matrix Matrix>
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void num_collect::linear::gauss_seidel_iterative_solver< Matrix >::iterate ( const matrix_type & coeff_ref,
const Right & right,
Solution & solution ) const
inlineprivate

Iterate once.

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

Definition at line 176 of file gauss_seidel_iterative_solver.h.

◆ iterations()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::gauss_seidel_iterative_solver< Matrix >::iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of iterations.

Note
This value won't be updated in iterate function.
Returns
Number of iterations.

Definition at line 149 of file gauss_seidel_iterative_solver.h.

◆ residual_rate()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::gauss_seidel_iterative_solver< Matrix >::residual_rate ( ) const -> scalar_type
inlinenodiscardnoexcept

Get the rate of the last residual.

Note
This value won't be updated in iterate function.
Returns
Rate of the last residual.

Definition at line 160 of file gauss_seidel_iterative_solver.h.

◆ solve_vector_in_place()

template<base::concepts::sparse_matrix Matrix>
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void num_collect::linear::gauss_seidel_iterative_solver< Matrix >::solve_vector_in_place ( const Right & right,
Solution & solution ) const
inline

Iterate repeatedly until stop criterion is satisfied for a 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 116 of file gauss_seidel_iterative_solver.h.

Member Data Documentation

◆ diag_

template<base::concepts::sparse_matrix Matrix>
vector_type num_collect::linear::gauss_seidel_iterative_solver< Matrix >::diag_ {}
private

Diagonal coefficients.

Definition at line 204 of file gauss_seidel_iterative_solver.h.

◆ inv_diag_

template<base::concepts::sparse_matrix Matrix>
vector_type num_collect::linear::gauss_seidel_iterative_solver< Matrix >::inv_diag_ {}
private

Inverse of diagonal coefficients.

Definition at line 207 of file gauss_seidel_iterative_solver.h.

◆ iterations_

template<base::concepts::sparse_matrix Matrix>
index_type num_collect::linear::gauss_seidel_iterative_solver< Matrix >::iterations_ {}
mutableprivate

Number of iterations.

Definition at line 195 of file gauss_seidel_iterative_solver.h.

◆ residual_

template<base::concepts::sparse_matrix Matrix>
scalar_type num_collect::linear::gauss_seidel_iterative_solver< Matrix >::residual_ {}
mutableprivate

Last residual.

Definition at line 198 of file gauss_seidel_iterative_solver.h.

◆ residual_rate_

template<base::concepts::sparse_matrix Matrix>
scalar_type num_collect::linear::gauss_seidel_iterative_solver< Matrix >::residual_rate_ {}
mutableprivate

Rate of last residual.

Definition at line 201 of file gauss_seidel_iterative_solver.h.


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