SPH
Public Types | Public Member Functions | List of all members
SparseMatrix Class Reference

Sparse representation of matrix of arbitrary dimension. More...

#include <SparseMatrix.h>

Public Types

enum class  Solver { LU , CG , LSCG , BICGSTAB }
 Solvers of sparse systems. More...
 

Public Member Functions

 SparseMatrix ()
 
 SparseMatrix (const Size rows, const Size cols)
 Constructs square n x m empty matrix. More...
 
 ~SparseMatrix ()
 
void resize (const Size rows, const Size cols)
 Changes the size of the matrix, removing all previous entries. More...
 
void insert (const Size i, const Size j, const Float value)
 Adds a values to given element of the matrix. More...
 
Expected< Array< Float > > solve (const Array< Float > &values, const Solver solver, const Float tolerance=0.)
 

Detailed Description

Sparse representation of matrix of arbitrary dimension.

Definition at line 16 of file SparseMatrix.h.

Member Enumeration Documentation

◆ Solver

enum SparseMatrix::Solver
strong

Solvers of sparse systems.

Enumerator
LU 

LU factorization, precise but very slow for large problems.

CG 

Conjugate gradient, approximative (iterative) solver, can only be used for symmetric positive-definite matrices!

LSCG 

Least-square conjugate gradient, can be used for any matrix.

BICGSTAB 

Stabilized bi-conjugate gradient method, can be used for any square matrix.

Definition at line 38 of file SparseMatrix.h.

Constructor & Destructor Documentation

◆ SparseMatrix() [1/2]

SparseMatrix::SparseMatrix ( )

◆ SparseMatrix() [2/2]

SparseMatrix::SparseMatrix ( const Size  rows,
const Size  cols 
)

Constructs square n x m empty matrix.

◆ ~SparseMatrix()

SparseMatrix::~SparseMatrix ( )

Member Function Documentation

◆ insert()

void SparseMatrix::insert ( const Size  i,
const Size  j,
const Float  value 
)

Adds a values to given element of the matrix.

If there is already a nonzero element, both values are summed up.

◆ resize()

void SparseMatrix::resize ( const Size  rows,
const Size  cols 
)

Changes the size of the matrix, removing all previous entries.

◆ solve()

Expected<Array<Float> > SparseMatrix::solve ( const Array< Float > &  values,
const Solver  solver,
const Float  tolerance = 0. 
)

Solvers an equation Ax = b, where A is the sparse matrix and b is given array of values.

Parameters
valuesArray of values b. The size of the array must be the same as the size of the matrix.
solverSolver used to solve the system of equations
toleranceThreshold used by the stopping criterion, only used by iterative solvers.
Returns
Solution vector or error message

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