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

Class to perform conjugate gradient (CG) method [7] for linear operators. More...

#include <num_collect/linear/impl/operator_conjugate_gradient.h>

+ Inheritance diagram for num_collect::linear::impl::operator_conjugate_gradient< Vector >:
+ Collaboration diagram for num_collect::linear::impl::operator_conjugate_gradient< Vector >:

Public Types

using scalar_type = typename vector_type::Scalar
 Type of scalars.
 
using vector_type = Vector
 Type of vectors.
 

Public Member Functions

 operator_conjugate_gradient ()
 Constructor.
 
auto iterations () -> index_type
 Get the number of iterations.
 
template<base::concepts::invocable< const vector_type &, vector_type & > CoeffFunction>
void solve (CoeffFunction &&coeff_function, const vector_type &rhs, vector_type &solution)
 Solve.
 
auto tolerance_rate (const scalar_type &val) -> operator_conjugate_gradient &
 Set the rate of tolerances.
 
- 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 Attributes

index_type iterations_ {}
 Number of iterations.
 
index_type max_iterations_ {default_max_iterations}
 Maximum number of iterations.
 
vector_type residual_ {}
 Residual vector.
 
scalar_type tolerance_rate_ {default_tolerance_rate}
 Rate of tolerance.
 
Intermidiate variables.
vector_type previous_residual_ {}
 
vector_type p_ {}
 
vector_type coeff_p_ {}
 

Static Private Attributes

static constexpr index_type default_max_iterations = 1000
 Default maximum number of iterations.
 
static constexpr scalar_type default_tolerance_rate
 Default rate of tolerance.
 

Detailed Description

template<base::concepts::dense_vector Vector>
class num_collect::linear::impl::operator_conjugate_gradient< Vector >

Class to perform conjugate gradient (CG) method [7] for linear operators.

Template Parameters
VectorType of vectors.

Definition at line 46 of file operator_conjugate_gradient.h.

Member Typedef Documentation

◆ scalar_type

template<base::concepts::dense_vector Vector>
using num_collect::linear::impl::operator_conjugate_gradient< Vector >::scalar_type = typename vector_type::Scalar

Type of scalars.

Definition at line 52 of file operator_conjugate_gradient.h.

◆ vector_type

template<base::concepts::dense_vector Vector>
using num_collect::linear::impl::operator_conjugate_gradient< Vector >::vector_type = Vector

Type of vectors.

Definition at line 49 of file operator_conjugate_gradient.h.

Constructor & Destructor Documentation

◆ operator_conjugate_gradient()

template<base::concepts::dense_vector Vector>
num_collect::linear::impl::operator_conjugate_gradient< Vector >::operator_conjugate_gradient ( )
inline

Constructor.

Definition at line 57 of file operator_conjugate_gradient.h.

Member Function Documentation

◆ iterations()

template<base::concepts::dense_vector Vector>
auto num_collect::linear::impl::operator_conjugate_gradient< Vector >::iterations ( ) -> index_type
inline

Get the number of iterations.

Returns
Number of iterations.

Definition at line 134 of file operator_conjugate_gradient.h.

◆ solve()

template<base::concepts::dense_vector Vector>
template<base::concepts::invocable< const vector_type &, vector_type & > CoeffFunction>
void num_collect::linear::impl::operator_conjugate_gradient< Vector >::solve ( CoeffFunction && coeff_function,
const vector_type & rhs,
vector_type & solution )
inline

Solve.

coeff_function is assumed to have a signature like:

void coeff_function(const vector_type& target, vector_type& result);
Template Parameters
CoeffFunctionType of the function to multiply coefficient matrix.
Parameters
[in]coeff_functionFunction to multiply coefficient matrix.
[in]rhsRight-hand-side vector.
[in,out]solutionSolution. (Given vector is used as the initial solution.)

Definition at line 78 of file operator_conjugate_gradient.h.

◆ tolerance_rate()

template<base::concepts::dense_vector Vector>
auto num_collect::linear::impl::operator_conjugate_gradient< Vector >::tolerance_rate ( const scalar_type & val) -> operator_conjugate_gradient&
inline

Set the rate of tolerances.

Parameters
[in]valValue.
Returns
This.

Definition at line 123 of file operator_conjugate_gradient.h.

Member Data Documentation

◆ coeff_p_

template<base::concepts::dense_vector Vector>
vector_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::coeff_p_ {}
private

Intermediate variable.

Definition at line 163 of file operator_conjugate_gradient.h.

◆ default_max_iterations

template<base::concepts::dense_vector Vector>
index_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::default_max_iterations = 1000
staticconstexprprivate

Default maximum number of iterations.

Definition at line 141 of file operator_conjugate_gradient.h.

◆ default_tolerance_rate

template<base::concepts::dense_vector Vector>
scalar_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::default_tolerance_rate
staticconstexprprivate
Initial value:
=
Eigen::NumTraits<scalar_type>::dummy_precision()

Default rate of tolerance.

Definition at line 147 of file operator_conjugate_gradient.h.

◆ iterations_

template<base::concepts::dense_vector Vector>
index_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::iterations_ {}
private

Number of iterations.

Definition at line 138 of file operator_conjugate_gradient.h.

◆ max_iterations_

template<base::concepts::dense_vector Vector>
index_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::max_iterations_ {default_max_iterations}
private

Maximum number of iterations.

Definition at line 144 of file operator_conjugate_gradient.h.

◆ p_

template<base::concepts::dense_vector Vector>
vector_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::p_ {}
private

Intermediate variable.

Definition at line 162 of file operator_conjugate_gradient.h.

◆ previous_residual_

template<base::concepts::dense_vector Vector>
vector_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::previous_residual_ {}
private

Intermediate variable.

Definition at line 161 of file operator_conjugate_gradient.h.

◆ residual_

template<base::concepts::dense_vector Vector>
vector_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::residual_ {}
private

Residual vector.

Definition at line 154 of file operator_conjugate_gradient.h.

◆ tolerance_rate_

template<base::concepts::dense_vector Vector>
scalar_type num_collect::linear::impl::operator_conjugate_gradient< Vector >::tolerance_rate_ {default_tolerance_rate}
private

Rate of tolerance.

Definition at line 151 of file operator_conjugate_gradient.h.


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