CUSP
Loading...
Searching...
No Matches
cusp::precond::diagonal< ValueType, MemorySpace > Class Template Reference

#include <diagonal.h>

Inheritance diagram for cusp::precond::diagonal< ValueType, MemorySpace >:
cusp::linear_operator< ValueType, MemorySpace, IndexType >

Public Methods

template<typename MatrixType >
 diagonal (const MatrixType &A)
 
template<typename VectorType1 , typename VectorType2 >
void operator() (const VectorType1 &x, VectorType2 &y) const
 
- Public Methods inherited from cusp::linear_operator< ValueType, MemorySpace, IndexType >
 linear_operator (void)
 
 linear_operator (IndexType num_rows, IndexType num_cols)
 
 linear_operator (IndexType num_rows, IndexType num_cols, IndexType num_entries)
 

Detailed description

template<typename ValueType, typename MemorySpace>
class cusp::precond::diagonal< ValueType, MemorySpace >

Diagonal preconditioner (aka Jacobi preconditioner)

Template Parameters
ValueTypeType used for matrix values (e.g. float or double).
MemorySpaceA memory space (e.g. cusp::host_memory or cusp::device_memory)
Overview
Given a matrix A to precondition, the diagonal preconditioner simply extracts the main diagonal D of a A and implements y = D^-1 x when applied to a vector x.

Diagonal preconditioning is very inexpensive to use, but has limited effectiveness. However, if the matrix A has poorly scaled rows then diagonal preconditioning can substantially reduce the number of solver iterations required to reach convergence.

Example
The following code snippet demonstrates how to use a diagonal preconditioner to solve a linear system.
int main(void)
{
// allocate storage for solution (x) and right hand side (b)
// setup preconditioner
// solve
return 0;
}
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
Definition array1d.h:99
Deprecated default monitor.
Definition monitor.h:312
Implements standard convergence criteria and reporting for iterative solvers.
Definition monitor.h:102
Diagonal preconditioner (aka Jacobi preconditioner)
Definition diagonal.h:86
Diagonal preconditioner.
void bicgstab(const LinearOperator &A, VectorType1 &x, const VectorType2 &b, Monitor &monitor, Preconditioner &M)
Biconjugate Gradient Stabilized method.

Definition at line 85 of file diagonal.h.

Constructor & Destructor Documentation

◆ diagonal()

template<typename ValueType , typename MemorySpace >
template<typename MatrixType >
cusp::precond::diagonal< ValueType, MemorySpace >::diagonal ( const MatrixType &  A)

construct a diagonal preconditioner

Parameters
Amatrix to precondition
Template Parameters
MatrixTypematrix

Member Function Documentation

◆ operator()()

template<typename ValueType , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void cusp::precond::diagonal< ValueType, MemorySpace >::operator() ( const VectorType1 &  x,
VectorType2 &  y 
) const

apply the preconditioner to vector x and store the result in y

Parameters
xinput vector
youtput vector
Template Parameters
VectorType1vector
VectorType2vector