SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize > Class Template Reference

Derivation for tri-diagonal block matrix type. More...

`#include <SurgSim/Math/LinearSolveAndInverse.h>`

Inheritance diagram for SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >:

## Public Member Functions

void | setMatrix (const Matrix &matrix) override
| Set the linear solver matrix. More...
Vector | solve (const Vector &b) override
| Solve the linear system (matrix.x=b) using the matrix provided by the latest setMatrix call. More...
Matrix | getInverse () override
Public Member Functions inherited from SurgSim::Math::LinearSolveAndInverse
virtual | ~LinearSolveAndInverse ()

## Protected Member Functions

void | inverseTriDiagonalBlock (const SurgSim::Math::Matrix &A, SurgSim::Math::Matrix *inv, bool isSymmetric=false)
| Computes the inverse matrix. More...

## Protected Attributes

Matrix | m_inverse
| Member variable to hold the inverse matrix in case only the solving is requested. More...

## Private Types

typedef Eigen::Matrix< Matrix::Scalar, BlockSize, BlockSize, Matrix::Options > | Block

## Private Member Functions

const Eigen::Block< const Matrix, BlockSize, BlockSize > | minusAi (const SurgSim::Math::Matrix &A, size_t i) const
| Gets a lower-diagonal block element (named -Ai in the algorithm) More...
const Eigen::Block< const Matrix, BlockSize, BlockSize > | Bi (const SurgSim::Math::Matrix &A, size_t i) const
| Gets a diagonal block element (named Bi in the algorithm) More...
const Eigen::Block< const Matrix, BlockSize, BlockSize > | minusCi (const SurgSim::Math::Matrix &A, size_t i) const
| Gets a upper-diagonal block element (named -Ci in the algorithm) More...

## Private Attributes

std::vector< Block > | m_Di
std::vector< Block > | m_Ei
std::vector< Block > | m_Bi_AiDiminus1_inv

## Detailed Description

### template<size_t BlockSize>
class SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >

Derivation for tri-diagonal block matrix type.

Template Parameters

  BlockSize | Define the block size of the tri-diagonal block matrix

## Member Typedef Documentation

## Block

template<size_t BlockSize>

typedef Eigen::Matrix<Matrix::Scalar, BlockSize, BlockSize, Matrix::Options> SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::Block

private

## Member Function Documentation

## Bi()

template<size_t BlockSize>

const Eigen::Block< const Matrix, BlockSize, BlockSize > SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::Bi | ( | const SurgSim::Math::Matrix & | A,
|  | size_t | i
| ) |  | const

private

Gets a diagonal block element (named Bi in the algorithm)

Parameters

  A | The matrix on which to retrieve the diagonal block element
  i | The line index on which to retrieve the diagonal block element

Returns
  The diagonal block element requested (i.e. block (i, i))

## getInverse()

template<size_t BlockSize>

Matrix SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::getInverse | ( |  | ) |

override virtual

Returns
  The linear system's inverse matrix, i.e. the inverse of the matrix provided on the last setMatrix call

Implements SurgSim::Math::LinearSolveAndInverse.

## inverseTriDiagonalBlock()

template<size_t BlockSize>

void SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::inverseTriDiagonalBlock | ( | const SurgSim::Math::Matrix & | A,
|  | SurgSim::Math::Matrix * | inv,
|  | bool | isSymmetric = `false`
| ) |  |

protected

Computes the inverse matrix.

Parameters

  | A | The matrix to inverse
  [out] | inv | The inverse matrix
  | isSymmetric | True if the matrix is symmetric, False otherwise

Note
  isSymmetric is only indicative and helps optimizing the computation when the matrix is symmetric.
  On the other side, if the flag is true and the matrix is not symmetric, the result will be wrong.
  Assert on inverse matrix pointer (inv), on the matrix being square and on
  proper size matching between the matrix size and the blockSize

## minusAi()

template<size_t BlockSize>

const Eigen::Block< const Matrix, BlockSize, BlockSize > SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::minusAi | ( | const SurgSim::Math::Matrix & | A,
|  | size_t | i
| ) |  | const

private

Gets a lower-diagonal block element (named -Ai in the algorithm)

Parameters

  A | The matrix on which to retrieve the lower-diagonal block element
  i | The line index on which to retrieve the lower-diagonal block element

Returns
  The lower-diagonal block element requested (i.e. block (i, i-1))

## minusCi()

template<size_t BlockSize>

const Eigen::Block< const Matrix, BlockSize, BlockSize > SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::minusCi | ( | const SurgSim::Math::Matrix & | A,
|  | size_t | i
| ) |  | const

private

Gets a upper-diagonal block element (named -Ci in the algorithm)

Parameters

  A | The matrix on which to retrieve the upper-diagonal block element
  i | The line index on which to retrieve the upper-diagonal block element

Returns
  The upper-diagonal block element requested (i.e. block (i, i+1))

## setMatrix()

template<size_t BlockSize>

void SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::setMatrix | ( | const Matrix & | matrix | ) |

override virtual

Set the linear solver matrix.

Parameters

  matrix | the new matrix to solve/inverse for

Implements SurgSim::Math::LinearSolveAndInverse.

Reimplemented in SurgSim::Math::LinearSolveAndInverseSymmetricTriDiagonalBlockMatrix< BlockSize >.

## solve()

template<size_t BlockSize>

Vector SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::solve | ( | const Vector & | b | ) |

override virtual

Solve the linear system (matrix.x=b) using the matrix provided by the latest setMatrix call.

Parameters

  b | The rhs vector

Returns
  The solution vector

Implements SurgSim::Math::LinearSolveAndInverse.

## Member Data Documentation

## m_Bi_AiDiminus1_inv

template<size_t BlockSize>

std::vector<Block> SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::m_Bi_AiDiminus1_inv

private

Intermediate block matrices, helpful to construct the inverse matrix

## m_Di

template<size_t BlockSize>

std::vector<Block> SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::m_Di

private

Intermediate block matrices, helpful to construct the inverse matrix

## m_Ei

template<size_t BlockSize>

std::vector<Block> SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::m_Ei

private

Intermediate block matrices, helpful to construct the inverse matrix

## m_inverse

template<size_t BlockSize>

Matrix SurgSim::Math::LinearSolveAndInverseTriDiagonalBlockMatrix< BlockSize >::m_inverse

protected

Member variable to hold the inverse matrix in case only the solving is requested.

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

- SurgSim/Math/LinearSolveAndInverse.h
- SurgSim/Math/LinearSolveAndInverse-inl.h