|
Feellgood
|
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 > | |
| 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 > | |
| T | dot (const std::vector< T > &X, const std::vector< T > &Y) |
| template<typename T > | |
| 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 > | |
| T | bicg_dir (iteration< T > &iter, r_sparseMat &A, std::vector< T > &x, const std::vector< T > &rhs, 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) |
grab altogether sparse matrix, vector and dedicated functions, and various gradient conjugate algorithms
| 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.
| enum algebra::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)
| void algebra::add | ( | const std::vector< T > & | X, |
| std::vector< T > & | Y | ||
| ) |
Y += X
| 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
| 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
| T algebra::bicg_dir | ( | iteration< T > & | iter, |
| r_sparseMat & | A, | ||
| std::vector< T > & | x, | ||
| const std::vector< T > & | rhs, | ||
| const std::vector< int > & | ld | ||
| ) |
directional stabilized biconjugate gradient (mask is ld) with diagonal preconditioner, returns residu iter is an iteration object the linear system to solve is A x = rhs ld is a mask: a list of indices that will be zeroed when using applyMask(ld, vector)
| 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 | ||
| ) |
directional stabilized biconjugate gradient (mask) with diagonal preconditioner with Dirichlet conditions, returns residu iter is an iteration object the linear system to solve is A x = rhs ld is a mask: a list of indices that will be zeroed when using applyMask(ld, vector) xd is a vector containing some values on the nodes where Dirichlet applies
| 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
| 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
| bool algebra::check | ( | std::vector< T > & | v | ) |
return true if the given vector is free of NaNs
| T algebra::dot | ( | const std::vector< T > & | X, |
| const std::vector< T > & | Y | ||
| ) |
returns scalar product X.Y
| void algebra::mult | ( | r_sparseMat & | A, |
| std::vector< T > const & | X, | ||
| std::vector< T > & | Y | ||
| ) |
Y = A*X with r_sparseMat A
| T algebra::norm | ( | std::vector< T > & | X | ) |
euclidian norm of vector X
|
inline |
operator<< for r_sparseMat
| void algebra::p_direct | ( | const std::vector< T > & | X, |
| const std::vector< T > & | Y, | ||
| std::vector< T > & | Z | ||
| ) |
direct product (component to component or Hadamard product)
| void algebra::scaled | ( | const T | alpha, |
| std::vector< T > & | Y | ||
| ) |
Y *= alpha
| void algebra::scaled_add | ( | const std::vector< T > & | X, |
| const T | alpha, | ||
| std::vector< T > & | Y | ||
| ) |
Y += alpha*X
| T algebra::sq | ( | const T | x | ) |
returns x²
| void algebra::sub | ( | const std::vector< T > & | X, |
| std::vector< T > & | Y | ||
| ) |
Y -= X