Feellgood
Classes | Typedefs | Enumerations | Functions
algebra Namespace Reference

Classes

class  iteration
 
class  w_sparseMat
 Write-mode sparse matrix. More...
 
class  r_sparseMat
 Read-mode square sparse matrix. More...
 

Typedefs

using MatrixShape = std::vector< std::set< int > >
 

Enumerations

enum  algoStatus { UNDEFINED = -1 , CONVERGED = 0 , ITER_OVERFLOW = 1 , CANNOT_CONVERGE = 2 }
 

Functions

template<typename T >
sq (const T x)
 
template<typename T >
void scaled (const T alpha, std::vector< T > &Y)
 
template<typename T >
void p_direct (const std::vector< T > &X, const std::vector< T > &Y, std::vector< T > &Z)
 
template<typename T >
void add (const std::vector< T > &X, std::vector< T > &Y)
 
template<typename T >
void sub (const std::vector< T > &X, std::vector< T > &Y)
 
template<typename T >
void scaled_add (const std::vector< T > &X, const T alpha, std::vector< T > &Y)
 
template<typename T >
void mult (r_sparseMat &A, std::vector< T > const &X, std::vector< T > &Y)
 
template<typename T >
void applyMask (const std::vector< int > &mask, std::vector< T > &X)
 
std::ostream & operator<< (std::ostream &flux, r_sparseMat const &m)
 
template<typename T >
bool check (std::vector< T > &v)
 
template<typename T >
dot (const std::vector< T > &X, const std::vector< T > &Y)
 
template<typename T >
norm (std::vector< T > &X)
 
template<typename T >
void bicg (iteration< T > &iter, r_sparseMat &A, std::vector< T > &x, const std::vector< T > &rhs)
 
template<typename T >
void bicg_dir (iteration< T > &iter, r_sparseMat &A, std::vector< T > &x, const std::vector< T > &rhs, const std::vector< T > &xd, const std::vector< int > &ld)
 
template<typename T >
void cg (iteration< T > &iter, r_sparseMat &A, std::vector< T > &x, const std::vector< T > &rhs)
 
template<typename T >
void cg_dir (iteration< T > &iter, r_sparseMat &A, std::vector< T > &x, const std::vector< T > &rhs, const std::vector< T > &xd, const std::vector< int > &ld)
 

Detailed Description

grab altogether sparse matrix, vector and dedicated functions, and various gradient conjugate algorithms

Typedef Documentation

◆ MatrixShape

using algebra::MatrixShape = typedef std::vector<std::set<int> >

The shape of a sparse matrix is the set of valid indices. Specifically, the shape element at index i is the set of j indices such that (i, j) is a valid index pair for the matrix.

Enumeration Type Documentation

◆ algoStatus

status of iterative algorithm UNDEFINED means no iteration done CONVERGED means algo succeeded after some iterations < MAXITER to achieve residu<TOL ITER_OVERFLOW means number of iterations has exceeded MAXITER CANNOT_CONVERGE means an algebric operation leads to nan (might happen while computing beta in bicg inner loop)

Function Documentation

◆ add()

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

Y += X

◆ applyMask()

template<typename T >
void algebra::applyMask ( const std::vector< int > &  mask,
std::vector< T > &  X 
)

apply a mask to vector X : all coefficients in vector mask are zeroed in X

◆ bicg()

template<typename T >
void algebra::bicg ( iteration< T > &  iter,
r_sparseMat A,
std::vector< T > &  x,
const std::vector< T > &  rhs 
)

solve A x = rhs. Algo is stabilized biconjugate gradient with diagonal preconditioner, vectors x and rhs must have the same size. The status of the convergence is returned in iter.status as well as total number of iterations and error

◆ bicg_dir()

template<typename T >
void algebra::bicg_dir ( iteration< T > &  iter,
r_sparseMat A,
std::vector< T > &  x,
const std::vector< T > &  rhs,
const std::vector< T > &  xd,
const std::vector< int > &  ld 
)

solve A x = rhs. Algo is directional stabilized biconjugate gradient (mask) with diagonal preconditioner with Dirichlet conditions, vectors x and rhs must have the same size. ld is a vector of indices where to apply zeros, xd the corresponding values. The status of the convergence is returned in iter.status as well as total number of iterations and error

◆ cg()

template<typename T >
void algebra::cg ( iteration< T > &  iter,
r_sparseMat A,
std::vector< T > &  x,
const std::vector< T > &  rhs 
)

solver for A x = rhs. Algo is conjugate gradient with diagonal preconditioner. vectors x and rhs must have the same size. The status of the convergence is returned in iter.status as well as total number of iterations and error

◆ cg_dir()

template<typename T >
void algebra::cg_dir ( iteration< T > &  iter,
r_sparseMat A,
std::vector< T > &  x,
const std::vector< T > &  rhs,
const std::vector< T > &  xd,
const std::vector< int > &  ld 
)

solver for A x = rhs. Algo is conjugate gradient with diagonal preconditioner with Dirichlet conditions (through masking technique) vectors x and rhs must have the same size. ld is a vector of indices where to apply zeros, xd the corresponding values. The status of the convergence is returned in iter.status as well as total number of iterations and error

◆ check()

template<typename T >
bool algebra::check ( std::vector< T > &  v)

return true if the given vector is free of NaNs

◆ dot()

template<typename T >
T algebra::dot ( const std::vector< T > &  X,
const std::vector< T > &  Y 
)

returns scalar product X.Y

◆ mult()

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

Y = A*X with r_sparseMat A

◆ norm()

template<typename T >
T algebra::norm ( std::vector< T > &  X)

euclidian norm of vector X

◆ operator<<()

std::ostream& algebra::operator<< ( std::ostream &  flux,
r_sparseMat const &  m 
)
inline

operator<< for r_sparseMat

◆ p_direct()

template<typename T >
void algebra::p_direct ( const std::vector< T > &  X,
const std::vector< T > &  Y,
std::vector< T > &  Z 
)

direct product (component to component): Z = X⊗Y

◆ scaled()

template<typename T >
void algebra::scaled ( const T  alpha,
std::vector< T > &  Y 
)

Y *= alpha

◆ scaled_add()

template<typename T >
void algebra::scaled_add ( const std::vector< T > &  X,
const T  alpha,
std::vector< T > &  Y 
)

Y += alpha*X

◆ sq()

template<typename T >
T algebra::sq ( const T  x)

returns x²

◆ sub()

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

Y -= X