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

USE THIS ONE Compute the inverse of a general tridiagonal matrix. The algorithm does not rely on the determinant. More...

Public Types

using value_type = dg::get_value_type< ContainerType >
 

Public Member Functions

 TridiagInvDF ()
 Allocate nothing, Call construct method before usage. More...
 
 TridiagInvDF (const ContainerType &copyable)
 Construct from vector. More...
 
 TridiagInvDF (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::TridiagInvDF< ContainerType, DiaMatrix, CooMatrix >

USE THIS ONE Compute the inverse of a general tridiagonal matrix. The algorithm does not rely on the determinant.

Note
For some special cases division by zero occurs (can be fixed if necessary cf. 2nd paper) This is the algorihm of "On the inverses of general tridiagonal matrices" by Hou-Biao Li, Ting-Zhu Huang, Xing-Ping Liu, Hong Li Appears to be the same as the algorithm in "ON AN INVERSE FORMULA OF A TRIDIAGONAL MATRIX" by Tomoyuki Sugimoto
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::TridiagInvDF< ContainerType, DiaMatrix, CooMatrix >::value_type = dg::get_value_type<ContainerType>

value type of the ContainerType class

Constructor & Destructor Documentation

◆ TridiagInvDF() [1/3]

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

Allocate nothing, Call construct method before usage.

◆ TridiagInvDF() [2/3]

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

Construct from vector.

Parameters
copyablevector

◆ TridiagInvDF() [3/3]

template<class ContainerType , class DiaMatrix , class CooMatrix >
dg::mat::TridiagInvDF< ContainerType, DiaMatrix, CooMatrix >::TridiagInvDF ( 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::TridiagInvDF< 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::TridiagInvDF< 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::TridiagInvDF< 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::TridiagInvDF< 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: