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

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

#include <num_collect/linear/parallel_symmetric_successive_over_relaxation.h>

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

 parallel_symmetric_successive_over_relaxation ()
 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) -> parallel_symmetric_successive_over_relaxation &
 Set the relaxation coefficient.
 
auto residual_rate () const noexcept -> scalar_type
 Get the rate of the last residual.
 
auto run_parallel (bool val) -> parallel_symmetric_successive_over_relaxation &
 Set whether to run in parallel.
 
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< parallel_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) -> parallel_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) -> parallel_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< parallel_symmetric_successive_over_relaxation< Matrix >, Right >
 Solve a linear equation.
 
auto solve_with_guess (const Right &right, const Solution &solution) const -> Eigen::SolveWithGuess< parallel_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) -> parallel_symmetric_successive_over_relaxation< Matrix > &
 Set the tolerance of rate of residual.
 
- Public Member Functions inherited from num_collect::logging::logging_mixin
 logging_mixin (log_tag_view tag)
 Constructor.
 
template<typename Child >
void configure_child_algorithm_logger_if_exists (Child &child)
 Configure a logger of a child algorithm if exists.
 
auto logger () const noexcept -> const num_collect::logging::logger &
 Access to the logger.
 
auto logger () noexcept -> num_collect::logging::logger &
 Access to the logger.
 

Private Member Functions

template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void iterate_no_parallel (const matrix_type &coeff_ref, const Right &right, Solution &solution) const
 Iterate once in single thread.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void iterate_parallel (const matrix_type &coeff_ref, const Right &right, Solution &solution) const
 Iterate once in parallel.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void process_row_backward (const matrix_type &coeff_ref, const Right &right, Solution &solution, index_type i, index_type end_row, const scalar_type &prev_sol_coeff) const
 Process a row in the backward update.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
auto process_row_forward (const matrix_type &coeff_ref, const Right &right, Solution &solution, index_type i, index_type start_row, const scalar_type &prev_sol_coeff) const -> scalar_type
 Process a row in the forward update.
 

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.
 
bool run_parallel_ {true}
 Whether to run in parallel.
 

Additional Inherited Members

- Protected Types inherited from num_collect::linear::iterative_solver_base< parallel_symmetric_successive_over_relaxation< Matrix > >
using Base
 Base class.
 
- Protected Member Functions inherited from num_collect::linear::iterative_solver_base< parallel_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::parallel_symmetric_successive_over_relaxation< Matrix >

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

Template Parameters
MatrixType of the matrix.

Definition at line 72 of file parallel_symmetric_successive_over_relaxation.h.

Member Typedef Documentation

◆ base_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::parallel_symmetric_successive_over_relaxation< Matrix >::base_type

◆ vector_type

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

Type of vectors.

Definition at line 95 of file parallel_symmetric_successive_over_relaxation.h.

Constructor & Destructor Documentation

◆ parallel_symmetric_successive_over_relaxation()

template<base::concepts::sparse_matrix Matrix>
num_collect::linear::parallel_symmetric_successive_over_relaxation< Matrix >::parallel_symmetric_successive_over_relaxation ( )
inline

Constructor.

Definition at line 100 of file parallel_symmetric_successive_over_relaxation.h.

Member Function Documentation

◆ compute()

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

Prepare to solve.

Parameters
[in]coeffCoefficient matrix.

Definition at line 109 of file parallel_symmetric_successive_over_relaxation.h.

◆ iterate_no_parallel()

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::parallel_symmetric_successive_over_relaxation< Matrix >::iterate_no_parallel ( const matrix_type & coeff_ref,
const Right & right,
Solution & solution ) const
inlineprivate

Iterate once in single thread.

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 284 of file parallel_symmetric_successive_over_relaxation.h.

◆ iterate_parallel()

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::parallel_symmetric_successive_over_relaxation< Matrix >::iterate_parallel ( const matrix_type & coeff_ref,
const Right & right,
Solution & solution ) const
inlineprivate

Iterate once in parallel.

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 229 of file parallel_symmetric_successive_over_relaxation.h.

◆ iterations()

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

◆ process_row_backward()

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::parallel_symmetric_successive_over_relaxation< Matrix >::process_row_backward ( const matrix_type & coeff_ref,
const Right & right,
Solution & solution,
index_type i,
index_type end_row,
const scalar_type & prev_sol_coeff ) const
inlineprivate

Process a row in the backward update.

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.
[in]iIndex of the row.
[in]end_rowIndex of the pat-the-last row in this thread.
[in]prev_sol_coeffCoefficient for the previous solution.

Definition at line 353 of file parallel_symmetric_successive_over_relaxation.h.

◆ process_row_forward()

template<base::concepts::sparse_matrix Matrix>
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
auto num_collect::linear::parallel_symmetric_successive_over_relaxation< Matrix >::process_row_forward ( const matrix_type & coeff_ref,
const Right & right,
Solution & solution,
index_type i,
index_type start_row,
const scalar_type & prev_sol_coeff ) const -> scalar_type
inlineprivate

Process a row in the forward update.

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.
[in]iIndex of the row.
[in]start_rowIndex of the first row in this thread.
[in]prev_sol_coeffCoefficient for the previous solution.
Returns
Residual of this row.

Definition at line 319 of file parallel_symmetric_successive_over_relaxation.h.

◆ relaxation_coeff()

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

Set the relaxation coefficient.

Parameters
[in]valRelaxation coefficient.
Returns
This.

Definition at line 194 of file parallel_symmetric_successive_over_relaxation.h.

◆ residual_rate()

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

◆ run_parallel()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::parallel_symmetric_successive_over_relaxation< Matrix >::run_parallel ( bool val) -> parallel_symmetric_successive_over_relaxation&
inline

Set whether to run in parallel.

Note
Default value is set in compute function.
Parameters
[in]valWhether to run in parallel.
Returns
This.

Definition at line 211 of file parallel_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::parallel_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 131 of file parallel_symmetric_successive_over_relaxation.h.

Member Data Documentation

◆ diag_

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

Diagonal coefficients.

Definition at line 386 of file parallel_symmetric_successive_over_relaxation.h.

◆ intermidiate_solution_

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

Intermidiate solution vector.

Definition at line 392 of file parallel_symmetric_successive_over_relaxation.h.

◆ inv_diag_

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

Inverse of diagonal coefficients.

Definition at line 389 of file parallel_symmetric_successive_over_relaxation.h.

◆ iterations_

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

Number of iterations.

Definition at line 374 of file parallel_symmetric_successive_over_relaxation.h.

◆ relaxation_coeff_

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

Relaxation coefficient.

Definition at line 383 of file parallel_symmetric_successive_over_relaxation.h.

◆ residual_

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

Last residual.

Definition at line 377 of file parallel_symmetric_successive_over_relaxation.h.

◆ residual_rate_

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

Rate of last residual.

Definition at line 380 of file parallel_symmetric_successive_over_relaxation.h.

◆ run_parallel_

template<base::concepts::sparse_matrix Matrix>
bool num_collect::linear::parallel_symmetric_successive_over_relaxation< Matrix >::run_parallel_ {true}
private

Whether to run in parallel.

Definition at line 371 of file parallel_symmetric_successive_over_relaxation.h.


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