deal.II version GIT relicensing-1989-gd7a2c90e4e 2024-10-14 01:50:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
IdentityMatrix Class Reference

#include <deal.II/lac/identity_matrix.h>

Public Types

using size_type = types::global_dof_index
 

Public Member Functions

 IdentityMatrix ()
 
 IdentityMatrix (const size_type n)
 
void reinit (const size_type n)
 
size_type m () const
 
size_type n () const
 
template<typename OutVectorType , typename InVectorType >
void vmult (OutVectorType &out, const InVectorType &in) const
 
template<typename OutVectorType , typename InVectorType >
void vmult_add (OutVectorType &out, const InVectorType &in) const
 
template<typename OutVectorType , typename InVectorType >
void Tvmult (OutVectorType &out, const InVectorType &in) const
 
template<typename OutVectorType , typename InVectorType >
void Tvmult_add (OutVectorType &out, const InVectorType &in) const
 

Private Attributes

size_type 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:

std_cxx20::type_identity< T > identity

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()));

Definition at line 68 of file identity_matrix.h.

Member Typedef Documentation

◆ size_type

Declare type for container size.

Definition at line 74 of file identity_matrix.h.

Constructor & Destructor Documentation

◆ IdentityMatrix() [1/2]

IdentityMatrix::IdentityMatrix ( )

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

◆ IdentityMatrix() [2/2]

IdentityMatrix::IdentityMatrix ( const size_type  n)
explicit

Constructor. Creates a identity matrix of size n.

Member Function Documentation

◆ reinit()

void IdentityMatrix::reinit ( const size_type  n)

Resize the matrix to be of size n by n.

◆ m()

size_type IdentityMatrix::m ( ) const

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

◆ n()

size_type IdentityMatrix::n ( ) const

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

◆ vmult()

template<typename OutVectorType , typename InVectorType >
void IdentityMatrix::vmult ( OutVectorType &  out,
const InVectorType &  in 
) const

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

◆ vmult_add()

template<typename OutVectorType , typename InVectorType >
void IdentityMatrix::vmult_add ( OutVectorType &  out,
const InVectorType &  in 
) const

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.

◆ Tvmult()

template<typename OutVectorType , typename InVectorType >
void IdentityMatrix::Tvmult ( OutVectorType &  out,
const InVectorType &  in 
) const

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.

◆ Tvmult_add()

template<typename OutVectorType , typename InVectorType >
void IdentityMatrix::Tvmult_add ( OutVectorType &  out,
const InVectorType &  in 
) const

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

◆ size

size_type IdentityMatrix::size
private

Number of rows and columns of this matrix.

Definition at line 147 of file identity_matrix.h.


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