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

Class to solve linear equations using symmetric successive over-relaxation [7]. More...

#include <num_collect/linear/symmetric_successive_over_relaxation.h>

+ Inheritance diagram for num_collect::linear::symmetric_successive_over_relaxation< Matrix >:
+ Collaboration diagram for num_collect::linear::symmetric_successive_over_relaxation< 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< symmetric_successive_over_relaxation< 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

 symmetric_successive_over_relaxation ()=default
 Constructor.
 
void compute (const matrix_type &coeff)
 Prepare to solve.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto relaxation_coeff (const scalar_type &val) -> symmetric_successive_over_relaxation &
 Set the relaxation coefficient.
 
auto residual_rate () const noexcept -> index_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< symmetric_successive_over_relaxation< 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) -> symmetric_successive_over_relaxation< 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) -> symmetric_successive_over_relaxation< 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< symmetric_successive_over_relaxation< Matrix >, Right >
 Solve a linear equation.
 
auto solve_with_guess (const Right &right, const Solution &solution) const -> Eigen::SolveWithGuess< symmetric_successive_over_relaxation< 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) -> symmetric_successive_over_relaxation< 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 intermidiate_solution_ {}
 Intermidiate solution vector.
 
vector_type inv_diag_ {}
 Inverse of diagonal coefficients.
 
index_type iterations_ {}
 Number of iterations.
 
scalar_type relaxation_coeff_ {static_cast<scalar_type>(1)}
 Relaxation coefficient.
 
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< symmetric_successive_over_relaxation< Matrix > >
using Base
 Base class.
 
- Protected Member Functions inherited from num_collect::linear::iterative_solver_base< symmetric_successive_over_relaxation< Matrix > >
auto coeff () const noexcept -> const matrix_type &
 Get the coefficient matrix.
 

Detailed Description

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

Class to solve linear equations using symmetric successive over-relaxation [7].

Template Parameters
MatrixType of the matrix.

Definition at line 62 of file symmetric_successive_over_relaxation.h.

Member Typedef Documentation

◆ base_type

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

Type of the base class.

Definition at line 71 of file symmetric_successive_over_relaxation.h.

◆ vector_type

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

Type of vectors.

Definition at line 84 of file symmetric_successive_over_relaxation.h.

Member Function Documentation

◆ compute()

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

Prepare to solve.

Parameters
[in]coeffCoefficient matrix.

Definition at line 96 of file symmetric_successive_over_relaxation.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::symmetric_successive_over_relaxation< 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 196 of file symmetric_successive_over_relaxation.h.

◆ iterations()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::symmetric_successive_over_relaxation< 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 154 of file symmetric_successive_over_relaxation.h.

◆ relaxation_coeff()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::symmetric_successive_over_relaxation< Matrix >::relaxation_coeff ( const scalar_type & val) -> symmetric_successive_over_relaxation&
inline

Set the relaxation coefficient.

Parameters
[in]valRelaxation coefficient.
Returns
This.

Definition at line 175 of file symmetric_successive_over_relaxation.h.

◆ residual_rate()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::symmetric_successive_over_relaxation< Matrix >::residual_rate ( ) const -> index_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 165 of file symmetric_successive_over_relaxation.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::symmetric_successive_over_relaxation< 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 symmetric_successive_over_relaxation.h.

Member Data Documentation

◆ diag_

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

Diagonal coefficients.

Definition at line 252 of file symmetric_successive_over_relaxation.h.

◆ intermidiate_solution_

template<base::concepts::sparse_matrix Matrix>
vector_type num_collect::linear::symmetric_successive_over_relaxation< Matrix >::intermidiate_solution_ {}
mutableprivate

Intermidiate solution vector.

Definition at line 258 of file symmetric_successive_over_relaxation.h.

◆ inv_diag_

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

Inverse of diagonal coefficients.

Definition at line 255 of file symmetric_successive_over_relaxation.h.

◆ iterations_

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

Number of iterations.

Definition at line 240 of file symmetric_successive_over_relaxation.h.

◆ relaxation_coeff_

template<base::concepts::sparse_matrix Matrix>
scalar_type num_collect::linear::symmetric_successive_over_relaxation< Matrix >::relaxation_coeff_ {static_cast<scalar_type>(1)}
private

Relaxation coefficient.

Definition at line 249 of file symmetric_successive_over_relaxation.h.

◆ residual_

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

Last residual.

Definition at line 243 of file symmetric_successive_over_relaxation.h.

◆ residual_rate_

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

Rate of last residual.

Definition at line 246 of file symmetric_successive_over_relaxation.h.


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