Extension: Matrix functions
#include "dg/matrix/matrix.h"
dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix > Class Template Reference

Compute the inverse of a general tridiagonal matrix. More...

Public Types

using value_type = dg::get_value_type< ContainerType >
 

Public Member Functions

 TridiagInvD ()
 Allocate nothing, Call construct method before usage. More...
 
 TridiagInvD (const ContainerType &copyable)
 Construct from vector. More...
 
 TridiagInvD (unsigned size)
 Construct from size of vector. More...
 
void resize (unsigned new_size)
 Resize inverse tridiagonal matrix and helper vectors. More...
 
void operator() (const DiaMatrix &T, CooMatrix &Tinv)
 Compute the inverse of a tridiagonal matrix T. More...
 
CooMatrix operator() (const DiaMatrix &T)
 Compute the inverse of a tridiagonal matrix T. More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 >
void operator() (const ContainerType0 &a, const ContainerType1 &b, const ContainerType2 &c, CooMatrix &Tinv)
 Compute the inverse of a tridiagonal matrix with diagonal vectors a,b,c. More...
 

Detailed Description

template<class ContainerType, class DiaMatrix, class CooMatrix>
class dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >

Compute the inverse of a general tridiagonal matrix.

Attention
If roughly the matrix size m>150 the algorithm is unstable. However, it performs extremely fast if it stays below this value. This is the algorihm of "Inversion of a Tridiagonal Jacobi Matrix" by Riaz A. Usmani
Template Parameters
ContainerTypethrust::host_vector<value_type> or similar shared memory host vector
CooMatrixcusp::coo_matrix<int, value_type, cusp::host_memory>;
DiaMatrixcusp::dia_matrix<int, value_type, cusp::host_memory>;

Member Typedef Documentation

◆ value_type

template<class ContainerType , class DiaMatrix , class CooMatrix >
using dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::value_type = dg::get_value_type<ContainerType>

value type of the ContainerType class

Constructor & Destructor Documentation

◆ TridiagInvD() [1/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::TridiagInvD ( )
inline

Allocate nothing, Call construct method before usage.

◆ TridiagInvD() [2/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::TridiagInvD ( const ContainerType &  copyable)
inline

Construct from vector.

Parameters
copyablevector

◆ TridiagInvD() [3/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::TridiagInvD ( unsigned  size)
inline

Construct from size of vector.

Parameters
sizesize of vector

Member Function Documentation

◆ operator()() [1/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
template<class ContainerType0 , class ContainerType1 , class ContainerType2 >
void dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::operator() ( const ContainerType0 &  a,
const ContainerType1 &  b,
const ContainerType2 &  c,
CooMatrix &  Tinv 
)
inline

Compute the inverse of a tridiagonal matrix with diagonal vectors a,b,c.

The diagonal vectors are given as in the cusp dia_matrix format

Parameters
a"0" diagonal vector (index 0 is on row 0)
b"+1" diagonal vector (index 0 is on row 0, last index outside)
c"-1" diagonal vector (index 0 is on row 0, outside of matrix)
Tinvthe inverse of the tridiagonal matrix (coordinate format) gets resized if necessary

◆ operator()() [2/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
CooMatrix dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::operator() ( const DiaMatrix &  T)
inline

Compute the inverse of a tridiagonal matrix T.

Parameters
Ttridiagonal matrix
Returns
the inverse of the tridiagonal matrix (coordinate format)

◆ operator()() [3/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
void dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::operator() ( const DiaMatrix &  T,
CooMatrix &  Tinv 
)
inline

Compute the inverse of a tridiagonal matrix T.

Parameters
Ttridiagonal matrix
Tinvthe inverse of the tridiagonal matrix (coordinate format) gets resized if necessary

◆ resize()

template<class ContainerType , class DiaMatrix , class CooMatrix >
void dg::mat::TridiagInvD< ContainerType, DiaMatrix, CooMatrix >::resize ( unsigned  new_size)
inline

Resize inverse tridiagonal matrix and helper vectors.

Parameters
new_sizenew size of square matrix

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