Feellgood
Classes | Public Member Functions | Private Attributes | List of all members
algebra::SparseMatrix Class Reference

Square sparse matrix. More...

#include <sparseMat.h>

Classes

struct  SparseVector
 

Public Member Functions

 SparseMatrix (const MatrixShape &shape)
 
void clear ()
 
void set (int i, int j, double val)
 
void add (int i, int j, double val)
 
void print (std::ostream &flux=std::cout) const
 
double operator() (const int i, const int j) const
 
template<typename T >
void mult (std::vector< T > const &X, std::vector< T > &Y)
 
template<typename T >
void build_diag_precond (std::vector< T > &D) const
 

Private Attributes

std::vector< SparseVectorrows
 

Detailed Description

Square sparse matrix.

This is the sparse matrix class, meant for efficiently computing matrix-vector products.

Constructor & Destructor Documentation

◆ SparseMatrix()

algebra::SparseMatrix::SparseMatrix ( const MatrixShape shape)
inline

Construct from a matrix shape. Initialize all stored values to zero.

Member Function Documentation

◆ add()

void algebra::SparseMatrix::add ( int  i,
int  j,
double  val 
)
inline

Add the provided value at position (i, j), which must belong to the shape. This method is thread-safe.

◆ build_diag_precond()

template<typename T >
void algebra::SparseMatrix::build_diag_precond ( std::vector< T > &  D) const
inline

Build a diagonal preconditioner D from this matrix.

◆ clear()

void algebra::SparseMatrix::clear ( )
inline

Zero-out all elements, while preserving the shape.

◆ mult()

template<typename T >
void algebra::SparseMatrix::mult ( std::vector< T > const &  X,
std::vector< T > &  Y 
)
inline

Y = this*X

◆ operator()()

double algebra::SparseMatrix::operator() ( const int  i,
const int  j 
) const
inline

Return the value at position (i, j).

◆ print()

void algebra::SparseMatrix::print ( std::ostream &  flux = std::cout) const
inline

Print to the provided stream.

◆ set()

void algebra::SparseMatrix::set ( int  i,
int  j,
double  val 
)
inline

Set the value at position (i, j), which must belong to the shape.

Member Data Documentation

◆ rows

std::vector<SparseVector> algebra::SparseMatrix::rows
private

Container for the matrix rows. Since SparseVector is not movable, this container cannot be resized.


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