Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | List of all members
cusp::precond::diagonal< ValueType, MemorySpace > Class Template Reference

Detailed description

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

Diagonal preconditoner (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)
cusp::default_monitor<float> monitor(b, 100, 1e-6);
// setup preconditioner
// solve
cusp::krylov::bicgstab(A, x, b, monitor, M);
return 0;
}
Examples:
diagonal.cu.

Definition at line 85 of file diagonal.h.

#include <diagonal.h>

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

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 >
 linear_operator (void)
 
 linear_operator (intnum_rows, intnum_cols)
 
 linear_operator (intnum_rows, intnum_cols, intnum_entries)
 

Constructor & Destructor Documentation

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

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
youput vector
Template Parameters
VectorType1vector
VectorType2vector