IdentityMatrix Class Reference
[Basic matrices]

List of all members.

Public Member Functions

 IdentityMatrix ()
 IdentityMatrix (const unsigned int n)
void reinit (const unsigned int n)
unsigned int m () const
unsigned int n () const
template<class VECTOR1 , class VECTOR2 >
void vmult (VECTOR1 &out, const VECTOR2 &in) const
template<class VECTOR1 , class VECTOR2 >
void vmult_add (VECTOR1 &out, const VECTOR2 &in) const
template<class VECTOR1 , class VECTOR2 >
void Tvmult (VECTOR1 &out, const VECTOR2 &in) const
template<class VECTOR1 , class VECTOR2 >
void Tvmult_add (VECTOR1 &out, const VECTOR2 &in) const

Private Attributes

unsigned int size


Detailed Description

Implementation of a simple class representing the identity matrix of a given size, i.e. a matrix with entries $A_{ij}=\delta_{ij}$. While it has the most important ingredients of a matrix, in particular that one can ask for its size and perform matrix-vector products with it, a matrix of this type is really only useful in two contexts: preconditioning and initializing other matrices.

Initialization

The main usefulness of this class lies in its ability to initialize other matrix, like this:

   FullMatrix<double> identity (IdentityMatrix(10));
 

This creates a $10\times 10$ matrix with ones on the diagonal and zeros everywhere else. Most matrix types, in particular FullMatrix and SparseMatrix, have conversion constructors and assignment operators for IdentityMatrix, and can therefore be filled rather easily with identity matrices.

Preconditioning

No preconditioning at all is equivalent to preconditioning with preconditioning with the identity matrix. deal.II has a specialized class for this purpose, PreconditionIdentity, than can be used in a context as shown in the documentation of that class. The present class can be used in much the same way, although without any additional benefit:

  SolverControl           solver_control (1000, 1e-12);
  SolverCG<>              cg (solver_control);
  cg.solve (system_matrix, solution, system_rhs,
	    IdentityMatrix(solution.size()));
 

Author:
Wolfgang Bangerth, 2006

Constructor & Destructor Documentation

IdentityMatrix::IdentityMatrix (  ) 

Default constructor. Creates a zero-sized matrix that should be resized later on using the reinit() function.

IdentityMatrix::IdentityMatrix ( const unsigned int  n  ) 

Constructor. Creates a identity matrix of size n.


Member Function Documentation

void IdentityMatrix::reinit ( const unsigned int  n  ) 

Resize the matrix to be of size n by n.

unsigned int IdentityMatrix::m (  )  const

Number of rows of this matrix. For the present matrix, the number of rows and columns are equal, of course.

unsigned int IdentityMatrix::n (  )  const

Number of columns of this matrix. For the present matrix, the number of rows and columns are equal, of course.

template<class VECTOR1 , class VECTOR2 >
void IdentityMatrix::vmult ( VECTOR1 &  out,
const VECTOR2 &  in 
) const [inline]

Matrix-vector multiplication. For the present case, this of course amounts to simply copying the input vector to the output vector.

template<class VECTOR1 , class VECTOR2 >
void IdentityMatrix::vmult_add ( VECTOR1 &  out,
const VECTOR2 &  in 
) const [inline]

Matrix-vector multiplication with addition to the output vector. For the present case, this of course amounts to simply adding the input vector to the output vector.

template<class VECTOR1 , class VECTOR2 >
void IdentityMatrix::Tvmult ( VECTOR1 &  out,
const VECTOR2 &  in 
) const [inline]

Matrix-vector multiplication with the transpose matrix. For the present case, this of course amounts to simply copying the input vector to the output vector.

template<class VECTOR1 , class VECTOR2 >
void IdentityMatrix::Tvmult_add ( VECTOR1 &  out,
const VECTOR2 &  in 
) const [inline]

Matrix-vector multiplication with the transpose matrix, with addition to the output vector. For the present case, this of course amounts to simply adding the input vector to the output vector.


Member Data Documentation

Number of rows and columns of this matrix.


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

deal.II documentation generated on Sat Aug 15 16:52:03 2009 by doxygen 1.5.9