PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::LinearSystemSolver< T > Class Template Reference

Basic linear solver (LU factorisation) for a small dense matrix of the system. More...

#include <ptems/linearalgebra.hpp>

Public Member Functions

 LinearSystemSolver (std::size_t size)
 Create solver for a linear system of form \(Ax-b\), where the matrix is stored as a dense matrix. More...
 
std::size_t size () const
 Gets the size of the linear system. More...
 
T & operator() (std::size_t i, std::size_t j)
 Gets mutable reference to the specified entry of the matrix \(A\). More...
 
std::vector< T > & Solve (std::vector< T > &rhs)
 Solves the linear system \(Ax-b\). More...
 

Detailed Description

template<typename T>
class ptems::LinearSystemSolver< T >

Basic linear solver (LU factorisation) for a small dense matrix of the system.

Solves the linear system \(Ax-b\) for \(A\in T^{n\times n}\), \(b,xA\in T^n\)

Warning
The matrix is stored as a a dense matrix. As such, this class should only be used for smallish matrices.
Template Parameters
TThe type of the entries of the linear system

Constructor & Destructor Documentation

◆ LinearSystemSolver()

template<typename T >
ptems::LinearSystemSolver< T >::LinearSystemSolver ( std::size_t  size)
inline

Create solver for a linear system of form \(Ax-b\), where the matrix is stored as a dense matrix.

Parameters
sizeDimension of the linear system

Member Function Documentation

◆ operator()()

template<typename T >
T& ptems::LinearSystemSolver< T >::operator() ( std::size_t  i,
std::size_t  j 
)
inline

Gets mutable reference to the specified entry of the matrix \(A\).

Note
This method can only be called before Solve() is called
Exceptions
std::out_of_rangeIf the row or column index is greater or equal to size()
std::logic_errorIf Solve() has been called already
Parameters
iThe row index of the entry to get
jThe column index of the entry to get
Returns
Mutable reference to the matrix entry

◆ size()

template<typename T >
std::size_t ptems::LinearSystemSolver< T >::size ( ) const
inline

Gets the size of the linear system.

◆ Solve()

template<typename T >
std::vector<T>& ptems::LinearSystemSolver< T >::Solve ( std::vector< T > &  rhs)
inline

Solves the linear system \(Ax-b\).

Exceptions
std::invalid_argumentIf rhs.size() != size()
Warning
LU factorisation is performed the first time Solve() is called, and the result is cached, overriding the original matrix. As such, the matrix entries cannot be changed after calling Solve().
Parameters
rhsThe mutable vector containing \(b\) which is updated with \(x\) on return
Returns
Reference to rhs

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