Abstract class defining the problem-specific interface for the simplified solver interface to IterativeSolver.
More...
#include <IterativeSolver.h>
template<typename R, typename P = std::map<size_t, typename R::value_type>>
class molpro::linalg::itsolv::Problem< R, P >
Abstract class defining the problem-specific interface for the simplified solver interface to IterativeSolver.
- Template Parameters
-
R | the type of container for solutions and residuals |
- Examples
- ExampleProblem.h, and ExampleProblemDistrArray.h.
|
| Problem ()=default |
|
virtual | ~Problem ()=default |
|
virtual value_t | residual (const R ¶meters, R &residual) const |
| Calculate the residual vector. Used by non-linear solvers (NonLinearEquations, Optimize) only. More...
|
|
virtual void | action (const CVecRef< R > ¶meters, const VecRef< R > &action) const |
| Calculate the action of the kernel matrix on a set of parameters. Used by linear solvers, but not by the non-linear solvers (NonLinearEquations, Optimize). More...
|
|
virtual bool | diagonals (container_t &d) const |
| Optionally provide the diagonal elements of the underlying kernel. If implemented and returning true, the provided diagonals will be used by IterativeSolver for preconditioning (and therefore the precondition() function does not need to be implemented), and, in the case of linear problems, for selection of the P space. Otherwise, preconditioning will be done with precondition(), and any P space has to be provided manually. More...
|
|
virtual void | precondition (const VecRef< R > &residual, const std::vector< value_t > &shift) const |
| Apply preconditioning to a residual vector in order to predict a step towards the solution. More...
|
|
virtual void | precondition (const VecRef< R > &residual, const std::vector< value_t > &shift, const R &diagonals) const |
| Apply preconditioning to a residual vector in order to predict a step towards the solution. More...
|
|
virtual bool | RHS (R &RHS, unsigned int instance) const |
| Return the inhomogeneous part of a linear equation system. More...
|
|
virtual std::vector< double > | pp_action_matrix (const std::vector< P > &pparams) const |
| Calculate the kernel matrix in the P space. More...
|
|
virtual void | p_action (const std::vector< std::vector< value_t > > &p_coefficients, const CVecRef< P > &pparams, const VecRef< container_t > &actions) const |
| Calculate the action of the kernel matrix on a set of vectors in the P space. More...
|
|
virtual bool | test_parameters (unsigned int instance, R ¶meters) const |
| Provide values of R vectors for testing the problem class. For use in a non-linear solver, the first vector (instance=0) should be a reference point, and the remainder (instance>0) should be close to it, such that meaningful numerical differentation can be done to test the residual function. More...
|
|
◆ container_t
template<typename R , typename P = std::map<size_t, typename R::value_type>>
◆ value_t
template<typename R , typename P = std::map<size_t, typename R::value_type>>
◆ Problem()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
◆ ~Problem()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
◆ action()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
◆ diagonals()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Optionally provide the diagonal elements of the underlying kernel. If implemented and returning true, the provided diagonals will be used by IterativeSolver for preconditioning (and therefore the precondition() function does not need to be implemented), and, in the case of linear problems, for selection of the P space. Otherwise, preconditioning will be done with precondition(), and any P space has to be provided manually.
- Parameters
-
d | On exit, contains the diagonal elements |
- Returns
- Whether diagonals have been provided.
- Examples
- ExampleProblem.h, and ExampleProblemDistrArray.h.
◆ p_action()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Calculate the action of the kernel matrix on a set of vectors in the P space.
- Parameters
-
p_coefficients | The projection of the vectors onto to the P space |
pparams | Specification of the P space |
actions | On exit, the computed action has been added to the original contents |
- Examples
- ExampleProblemDistrArray.h.
◆ pp_action_matrix()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Calculate the kernel matrix in the P space.
- Parameters
-
pparams | Specification of the P space |
- Returns
- Examples
- ExampleProblemDistrArray.h.
◆ precondition() [1/2]
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Apply preconditioning to a residual vector in order to predict a step towards the solution.
- Parameters
-
residual | On entry, assumed to be the residual. On exit, the negative of the predicted step. |
shift | When called from LinearEigensystem, contains the corresponding current eigenvalue estimates for each of the parameter vectors in the set. All other solvers pass a vector of zeroes. |
◆ precondition() [2/2]
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Apply preconditioning to a residual vector in order to predict a step towards the solution.
- Parameters
-
residual | On entry, assumed to be the residual. On exit, the negative of the predicted step. |
shift | When called from LinearEigensystem, contains the corresponding current eigenvalue estimates for each of the parameter vectors in the set. All other solvers pass a vector of zeroes. |
diagonals | The diagonal elements of the underlying kernel |
◆ residual()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
◆ RHS()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Return the inhomogeneous part of a linear equation system.
- Parameters
-
RHS | On return, will contain the requested right-hand-side of equations if available. |
instance | Which RHS is required. If there are N sets of equations to solve, then 0,1,...N-1 number the instances. The solver will call this function repeatedly with instance=0,1,2,... until it receives a negative response. |
- Returns
- whether the requested RHS is available and has been provided
- Examples
- ExampleProblem.h.
◆ test_parameters()
template<typename R , typename P = std::map<size_t, typename R::value_type>>
Provide values of R vectors for testing the problem class. For use in a non-linear solver, the first vector (instance=0) should be a reference point, and the remainder (instance>0) should be close to it, such that meaningful numerical differentation can be done to test the residual function.
- Parameters
-
- Returns
- true if a vector has been provided