TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR > Class Template Reference

#include <tnt_iml.h>

Collaboration diagram for TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR >:
[legend]

List of all members.

Public Member Functions

 Diagonal_Preconditioner (int N, const SCALAR *V)
 Diagonal_Preconditioner (const Vector< SCALAR > &V)
Vector< SCALAR > operator() (const Vector< SCALAR > &b) const

Private Attributes

Vector< SCALAR > one_over_diag_


Detailed Description

template<class SCALAR>
class TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR >

Diagonal preconditioner object is used in iterative methods to approximate the original matrix A in the equation by its diagonals. It is one of the simplest preconditioners used in practice, and one of the eaisest to create. (One needs only a list of the matrix diagonals.)

Example:

		double Vals1 = { .... };
		complex<double> Vals2 = { .... };
		double Vals3 = { ... };

		Matrix<double> A(N, N, Vals1);
		Sparse_Matrix< complex<double> > S(M, M, nz, I, J, Vals2);

		DiagonalPreconditioner<double>  D1 (A.diag());
		DiagonalPreconditioner<complex> D2(S.diag());
		DiagonalPreconditioner<double> D3(N, Vals3);

		x = D1(b);    (solve diag(A) * x = b )
  

This is a funciton object which is invoked using operator(). That is, its use appears like a function call, f(x), where x is a vector. Preconditioners are read-only objects --their contents cannot be modified. If one of the diagonal elements of A is zero, then the results are undefined. (In some implementations, the reciprocals of the diagonals are kept to avoid costly floating point divisions. These may be created at time of object construction and result in floating point exceptions.

Definition at line 42 of file tnt_iml.h.


Constructor & Destructor Documentation

template<class SCALAR >
TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR >::Diagonal_Preconditioner ( int  N,
const SCALAR *  V 
) [inline]

Create a diagonal preconditioner from a C/C++ array of nonzero values.

Parameters:
N the length of vector
V the vector (C/C++ array) of values.

Definition at line 54 of file tnt_iml.h.

template<class SCALAR >
TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR >::Diagonal_Preconditioner ( const Vector< SCALAR > &  V  )  [inline]

Create a diagonal preconditioner from a TNT Vector of nonzero values.

Parameters:
V a vector of (nozero) diagonals.

Definition at line 66 of file tnt_iml.h.


Member Function Documentation

template<class SCALAR >
Vector<SCALAR> TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR >::operator() ( const Vector< SCALAR > &  b  )  const [inline]

Apply diagonal preconditioner, i.e. solve for x in D*x = b.

Parameters:
b a vector of right-hand values (must be same size of D.)
Returns:
x the solution of D*x=b.

Definition at line 80 of file tnt_iml.h.


Member Data Documentation

template<class SCALAR >
Vector<SCALAR> TNT::Linear_Algebra::Diagonal_Preconditioner< SCALAR >::one_over_diag_ [private]

Definition at line 92 of file tnt_iml.h.


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

Generated on Fri Feb 6 13:30:19 2009 for CorAL by  doxygen 1.5.8