Public Types | |
typedef void(MATRIX::* | function_ptr )(VECTOR &, const VECTOR &) const |
Public Member Functions | |
PreconditionUseMatrix (const MATRIX &M, const function_ptr method) | |
void | vmult (VECTOR &dst, const VECTOR &src) const |
Private Attributes | |
const MATRIX & | matrix |
const function_ptr | precondition |
Preconditioner using a matrix-builtin function. This class forms a preconditioner suitable for the LAC solver classes. Since many preconditioning methods are based on matrix entries, these have to be implemented as member functions of the underlying matrix implementation. This class now is intended to allow easy access to these member functions from LAC solver classes.
It seems that all builtin preconditioners have a relaxation parameter, so please use PreconditionRelaxation for these.
You will usually not want to create a named object of this type, although possible. The most common use is like this:
SolverGMRES<SparseMatrix<double>, Vector<double> > gmres(control,memory,500); gmres.solve (matrix, solution, right_hand_side, PreconditionUseMatrix<SparseMatrix<double>,Vector<double> > (matrix,&SparseMatrix<double>::template precondition_Jacobi<double>));
This creates an unnamed object to be passed as the fourth parameter to the solver function of the SolverGMRES class. It assumes that the SparseMatrix class has a function precondition_Jacobi
taking two vectors (source and destination) as parameters (Actually, there is no function like that, the existing function takes a third parameter, denoting the relaxation parameter; this example is therefore only meant to illustrate the general idea).
Note that due to the default template parameters, the above example could be written shorter as follows:
... gmres.solve (matrix, solution, right_hand_side, PreconditionUseMatrix<> (matrix,&SparseMatrix<double>::template precondition_Jacobi<double>));
typedef void( MATRIX::* PreconditionUseMatrix< MATRIX, VECTOR >::function_ptr)(VECTOR &, const VECTOR &) const |
Type of the preconditioning function of the matrix.
PreconditionUseMatrix< MATRIX, VECTOR >::PreconditionUseMatrix | ( | const MATRIX & | M, | |
const function_ptr | method | |||
) |
Constructor. This constructor stores a reference to the matrix object for later use and selects a preconditioning method, which must be a member function of that matrix.
void PreconditionUseMatrix< MATRIX, VECTOR >::vmult | ( | VECTOR & | dst, | |
const VECTOR & | src | |||
) | const |
Execute preconditioning. Calls the function passed to the constructor of this object with the two arguments given here.
const MATRIX& PreconditionUseMatrix< MATRIX, VECTOR >::matrix [private] |
Pointer to the matrix in use.
const function_ptr PreconditionUseMatrix< MATRIX, VECTOR >::precondition [private] |
Pointer to the preconditioning function.