NGSolve  4.9
Classes | Typedefs | Functions
ngbla Namespace Reference

Basic Linear Algebra. More...

Classes

class  FlatSymBandMatrix
 A symmetric band-matrix. More...
class  SymBandMatrix
 A symmetric band-matrix with memory management. More...
class  FlatBandCholeskyFactors
 Cholesky factors of a band matrix. More...
class  BandCholeskyFactors
 Cholesky factors of a band matrix. More...
class  FlatCholeskyFactors
 The Cholesky-factorization of a symmetric dense matrix. More...
class  CholeskyFactors
class  mat_traits
 Trait to obtain vector and scalar types for given matrix types. More...
class  mat_traits< Mat< 1, 1, int > >
class  mat_traits< int >
class  mat_traits< double >
class  mat_traits< float >
class  mat_traits< Complex >
class  mat_traits< AutoDiff< D, SCAL > >
class  mat_traits< AutoDiffDiff< D > >
class  mat_traits< const int >
class  mat_traits< const double >
class  mat_traits< const Complex >
class  mat_from_vecs
 matrix type from column and row vectors More...
class  mat_from_vecs< double, double >
class  mat_from_vecs< double, Complex >
class  mat_from_vecs< Complex, double >
class  mat_from_vecs< Complex, Complex >
class  mat_prod_type
 matrix type of product More...
class  mat_prod_type< double, double >
class  mat_prod_type< double, Complex >
class  mat_prod_type< Complex, double >
class  mat_prod_type< Complex, Complex >
class  mat_prod_type< AutoDiff< D, TA >, TB >
class  mat_prod_type< TB, AutoDiff< D, TA > >
class  mat_prod_type< AutoDiff< D, TA >, AutoDiff< E, TB > >
class  mat_sum_type
 matrix type of sum (important for double+Complex) More...
class  mat_sum_type< float, float >
class  mat_sum_type< double, double >
class  mat_sum_type< double, Complex >
class  mat_sum_type< Complex, double >
class  mat_sum_type< Complex, Complex >
class  mat_sum_type< AutoDiff< D, TA >, TB >
class  mat_sum_type< TB, AutoDiff< D, TA > >
class  mat_sum_type< AutoDiff< D, TA >, AutoDiff< E, TB > >
class  mat_scale_type
 matrix type of scale More...
class  mat_scale_type< double, double >
class  mat_scale_type< double, Complex >
class  mat_scale_type< Complex, double >
class  mat_scale_type< Complex, Complex >
class  mat_scale_type< TB, AutoDiff< D, TA > >
class  mat_scale_type< AutoDiff< D, TA >, TB >
class  mat_scale_type< AutoDiff< D, TA >, AutoDiff< E, TB > >
class  Complex2RealException
 Complex to double assignment called. More...
class  Expr
 Expr is the base class for all matrix template expressions. More...
class  SymExpr
 Caller knows that matrix expression is a symmetric matrix. More...
class  LapackExpr
class  LocalHeapExpr
class  MatExpr
 The base class for matrices. More...
class  CMCPMatExpr
 The base class for matrices. More...
class  SumExpr
 Sum of 2 matrix expressions. More...
class  SubExpr
 Matrix-expr minus Matrix-expr. More...
class  MinusExpr
 minus Matrix-expr More...
class  ScaleExpr
 Scalar times Matrix-expr. More...
class  MultExpr
 Matrix-expr timex Matrix-expr. More...
class  TransExpr
 Transpose of Matrix-expr. More...
class  SubMatrixExpr
 RowsArray. More...
class  RowsArrayExpr
 RowsArray. More...
class  ColsArrayExpr
 ColsArray. More...
class  ConjExpr
 Conjugate of Matrix-expr. More...
class  FlatMatrix
 A simple matrix. More...
class  Matrix
 A Matrix class with memory allocation/deallocation. More...
class  Mat
 A matrix of fixed size. More...
class  FlatMatrixFixWidth
 A Matrix with width known at compile time No memory allocation/deallocation. More...
class  MatrixFixWidth
 A Matrix class with memory allocation/deallocation. More...
class  FlatMatrixFixHeight
 A Matrix which height is known at compile time No memory allocation/deallocation. More...
class  MatrixFixHeight
 A Matrix class with memory allocation/deallocation. More...
class  SliceMatrix
class  DoubleSliceMatrix
class  Scalar2ElemMatrix
class  Id
 Identity Matrix of fixed size. More...
class  Identity
 Variable size identity matrix. More...
class  FlatSymmetricMatrix
 A symmetric band-matrix. More...
class  SymmetricMatrix
 A symmetric band-matrix with memory management. More...
class  FlatVector
 A simple vector. More...
class  FlatVector< Vec< S, T > >
class  Vector
 A Vector class with memory allocation/deallocation. More...
class  Vector< Vec< S, T > >
class  VectorMem
 A Vector class with memory allocation/deallocation. More...
class  FlatSysVector
class  Vec
 A vector of fixed size. More...
class  FlatVec
 A pointer to a vector of fixed size. More...
class  SliceVector
 A vector with non-linear data access. More...
class  FixSliceVector
 A vector with non-linear data access. More...
class  Scalar2ElemVector
class  Scalar2ElemVector< TSCAL, TSCAL >
class  mat_traits< FlatVector< T > >

Typedefs

typedef std::complex< double > Complex
typedef int T_Lapack
typedef int integer

Functions

double fabs (Complex v)
bool IsComplex (double v)
bool IsComplex (Complex v)
void CalcEigenSystem (const FlatMatrix< double > &mat, FlatVector< double > &lami, FlatMatrix< double > &eigenvecs)
 Computes eigenvalues and vectors of the symmetric matrix mat.
void CalcSchurComplement (const FlatMatrix< double > a, FlatMatrix< double > s, const BitArray &used, LocalHeap &lh)
 Computes the Schur Complement.
template<typename T >
std::ostream & operator<< (std::ostream &s, const FlatSymBandMatrix< T > &m)
 output operator
template<typename T >
std::ostream & operator<< (std::ostream &s, const FlatBandCholeskyFactors< T > &m)
 output operator.
template<typename T >
std::ostream & operator<< (std::ostream &s, const FlatCholeskyFactors< T > &m)
 output operator.
template<typename TVEC >
TVEC::TELEM & Access (TVEC &vec, int nr)
template<typename TVEC >
TVEC::TELEM Access (const TVEC &vec, int nr)
double & Access (double &vec, int nr)
double Access (const double &vec, int nr)
Complex & Access (Complex &vec, int nr)
Complex Access (const Complex &vec, int nr)
template<typename TM >
TM::TELEM & Access (TM &mat, int i, int j)
template<typename TM >
TM::TELEM Access (const TM &mat, int i, int j)
double & Access (double &mat, int i, int j)
double Access (const double &mat, int i, int j)
Complex & Access (Complex &mat, int i, int j)
Complex Access (const Complex &mat, int i, int j)
template<class TM >
int Height (const TM &m)
 Height of matrix.
template<class TM >
int Width (const TM &m)
 Width of matrix.
template<>
int Height< double > (const double &)
template<>
int Height< Complex > (const Complex &)
template<>
int Width< double > (const double &)
template<>
int Width< Complex > (const Complex &)
template<typename TO >
TO ConvertTo (double f)
template<typename TO >
TO ConvertTo (Complex f)
template<typename TO >
TO ConvertTo (const AutoDiff< 1, Complex > &f)
template<>
double ConvertTo (Complex f)
template<typename T >
SymExpr< T > Symmetric (const Expr< T > &a)
 Declare that matrix expression is symmetric.
template<typename TA >
LapackExpr< TA > operator| (const Expr< TA > &a, T_Lapack)
template<typename TA >
LocalHeapExpr< TA > operator| (const Expr< TA > &a, LocalHeap &lh)
template<typename TA , typename TB >
SumExpr< TA, TB > operator+ (const Expr< TA > &a, const Expr< TB > &b)
template<typename TA , typename TB >
SubExpr< TA, TB > operator- (const Expr< TA > &a, const Expr< TB > &b)
template<typename TA >
MinusExpr< TA > operator- (const Expr< TA > &a)
template<typename TA >
ScaleExpr< TA, double > operator* (double b, const Expr< TA > &a)
template<typename TA >
ScaleExpr< TA, Complex > operator* (Complex b, const Expr< TA > &a)
template<int D, typename TAD , typename TA >
ScaleExpr< TA, AutoDiff< D, TAD > > operator* (const AutoDiff< D, TAD > &b, const Expr< TA > &a)
template<typename TA , typename TB >
MultExpr< TA, TB > operator* (const Expr< TA > &a, const Expr< TB > &b)
double Trans (double a)
Complex Trans (Complex a)
template<int D, typename TAD >
AutoDiff< D, TAD > Trans (const AutoDiff< D, TAD > &a)
template<typename TA >
TransExpr< TA > Trans (const Expr< TA > &a)
 Transpose.
double Conj (double a)
Complex Conj (Complex a)
template<typename TA >
ConjExpr< TA > Conj (const Expr< TA > &a)
 Conjugate.
template<int D, typename TAD >
AutoDiff< D, TAD > Conj (const AutoDiff< D, TAD > &a)
double InnerProduct (double a, double b)
Complex InnerProduct (Complex a, Complex b)
Complex InnerProduct (double a, Complex b)
Complex InnerProduct (Complex a, double b)
template<class TA , class TB >
mat_prod_type< typename
TA::TSCAL, typename TB::TSCAL >
::TMAT 
InnerProduct (const Expr< TA > &a, const Expr< TB > &b)
 Inner product.
template<class TA >
TA::TELEM Trace (const Expr< TA > &a)
 Calculates the trace of a matrix expression.
double L2Norm2 (double v)
 Euclidean norm squared.
double L2Norm2 (Complex v)
template<int D, typename SCAL >
double L2Norm2 (const AutoDiff< D, SCAL > &x) throw ()
template<class TA >
double L2Norm2 (const Expr< TA > &v)
template<class TA >
double L2Norm (const Expr< TA > &v)
 Calculates the Euclidean norm.
double MaxNorm (double v)
 Euclidean norm squared.
double MaxNorm (Complex v)
template<int D, typename SCAL >
double L2Norm (const AutoDiff< D, SCAL > &x) throw ()
template<class TA >
double MaxNorm (const Expr< TA > &v)
template<typename T >
std::ostream & operator<< (std::ostream &s, const Expr< T > &v)
 Print matrix-expr.
template<class T2 >
NGS_DLL_HEADER void CalcInverse (FlatMatrix< T2 > inv)
 Calculate inverse. Gauss elimination with row pivoting.
NGS_DLL_HEADER void CalcInverse (FlatMatrix< double > inv)
template<class T , class T2 >
void CalcInverse (const FlatMatrix< T > m, FlatMatrix< T2 > inv)
template<class T , class T2 >
void CalcInverse (const FlatMatrix< T > m, Matrix< T2 > &inv)
template<typename T >
Matrix< T > Inv (const FlatMatrix< T > &m)
 Calculates the inverse of a Matrix.
void CalcInverse (double &m)
void CalcInverse (Complex &m)
template<int H, int W, typename T >
void CalcInverse (Mat< H, W, T > &m)
void CalcInverse (const double &m, double &inv)
void CalcInverse (const Complex &m, Complex &inv)
template<int H, int W, typename T , typename TINV >
void CalcInverse (const Mat< H, W, T > &m, TINV &inv)
template<typename T , typename TINV >
void CalcInverse (const Mat< 1, 1, T > &m, TINV &inv)
template<typename T , typename TINV >
void CalcInverse (const Mat< 2, 2, T > &m, TINV &inv)
template<typename T , typename TINV >
void CalcInverse (const Mat< 3, 3, T > &m, TINV &inv)
template<int H, int W, typename T >
Mat< H, W, T > Inv (const Mat< H, W, T > &m)
template<class T >
T::TELEM Det (const MatExpr< T > &m)
 Calculates the determinant of a Matrix.
void CheckMatRange (int h, int w, int i)
void CheckMatRange (int h, int w, int i, int j)
template<int H, int W, typename T >
std::ostream & operator<< (std::ostream &s, const Mat< H, W, T > &m)
void LapackMultAtx (ngbla::FlatMatrix< double > a, ngbla::FlatVector< double > x, ngbla::FlatVector< double > y)
void LapackAddxyt (ngbla::FlatMatrix< double > a, ngbla::FlatVector< double > x, ngbla::FlatVector< double > y)
template<typename TA , typename TB >
void LapackMult (const TA &a, const TB &b, ngbla::SliceMatrix< double > c)
template<typename TA , typename TB >
void LapackMult (const TA &a, const TB &b, ngbla::SliceMatrix< Complex > c)
template<typename TA , typename TB >
void LapackMultAdd (const TA &a, const TB &b, double alpha, SliceMatrix< double > c, double beta)
template<typename TA , typename TB >
void LapackMultAdd (const TA &a, const TB &b, Complex alpha, SliceMatrix< Complex > c, Complex beta)
void LapackMultABt (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, ngbla::FlatMatrix< double > c)
void LapackMultAtB (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, ngbla::FlatMatrix< double > c)
void LapackMultAB (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, ngbla::FlatMatrix< double > c)
void LapackMultABt (ngbla::FlatMatrix< ngbla::Complex > a, ngbla::FlatMatrix< ngbla::Complex > b, ngbla::FlatMatrix< ngbla::Complex > c)
void LapackMultAtB (ngbla::FlatMatrix< Complex > a, ngbla::FlatMatrix< Complex > b, ngbla::FlatMatrix< Complex > c)
void LapackMultAddAB (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, double fac, ngbla::FlatMatrix< double > c)
void LapackMultAddABt (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, double fac, ngbla::FlatMatrix< double > c)
void LapackMultAddAtB (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, double fac, ngbla::FlatMatrix< double > c)
void LapackMultAddAB (ngbla::FlatMatrix< ngbla::Complex > a, ngbla::FlatMatrix< ngbla::Complex > b, double fac, ngbla::FlatMatrix< ngbla::Complex > c)
void LapackMultAddABt (ngbla::FlatMatrix< ngbla::Complex > a, ngbla::FlatMatrix< ngbla::Complex > b, double fac, ngbla::FlatMatrix< ngbla::Complex > c)
void LapackInverse (ngbla::FlatMatrix< double > a)
void LapackInverse (ngbla::FlatMatrix< ngbla::Complex > a)
void LapackAInvBt (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, char trans= 'N')
void LapackAInvBt (ngbla::FlatMatrix< Complex > a, ngbla::FlatMatrix< Complex > b, char trans= 'N')
void LapackEigenValuesSymmetric (ngbla::FlatMatrix< double > a, ngbla::FlatVector< double > lami)
void LapackEigenValuesSymmetric (ngbla::FlatMatrix< double > a, ngbla::FlatMatrix< double > b, ngbla::FlatVector< double > lami)
void LapackEigenValuesSymmetric (ngbla::FlatMatrix< ngbla::Complex > a, ngbla::FlatVector< ngbla::Complex > lami)
void LapackHessenbergEP (int n, std::complex< double > *H, std::complex< double > *lami, std::complex< double > *evecs)
template<typename T >
std::ostream & operator<< (std::ostream &s, const FlatSymmetricMatrix< T > &m)
void CheckVecRange (int s, int i)
void CheckVecRange (int s, int i, int j)
template<typename S >
Vec< 3, S > Cross (const Vec< 3, S > &a, const Vec< 3, S > &b)
 cross product
template<int S, typename T >
ostream & operator<< (ostream &ost, const Vec< S, T > &v)
 output vector
template<int S, typename TB >
Vec< S > & operator+= (Vec< S > &v, const Expr< TB > &v2)
template<int S, typename T >
ostream & operator<< (ostream &ost, const FlatVec< S, T > &v)
 output vector.

Detailed Description

Basic Linear Algebra.

namespace for basic linear algebra

The basic linear algebra is implemented by means of expression templates. This allows to write matrix and vector operations in a convenient way such as

\[ x = y + A * z \]

There is no compromise to efficiency. In particular, there is no frequent allocation and dealloction of dynamic objects. The generated code is comparable to a manually optimized code.

The main idea is the following: The operator* (matrix, vector) returns a symbolic object matrix-vector product without evaluating it. The computations are done in the assignement, where the required memory for storing the result is available.

A good introduction to expression templates is "Techniques for Scientific C++" by Todd Veldhuizen.

The following vector types are available: Vec , FlatVector, Vector, VectorMem, SliceVector

The following matrix types are available: Mat, Matrix, MatrixFixWidth, MatrixFixHeight, SymBandMatrix, BandCholeskyFactors.

Again, there are corresponding matrix types without memory management: {FlatMatrix}, {FlatMatrixFixWidth}, {FlatMatrixFixHeight}, {FlatSymBandMatrix}, {FlatBandCholeskyFactors},

NGBLA provides the canonical operators (+,-,*,+=, -=) for matrices and vectors. Additionally, the following functions are avialable: {Trans}, {Inv}, {Height}, {Width}, {Trace}, {InnerProduct}, {L2Norm}, {Det}

Implemented algorithms are Inversion {CalcInverse}, Eigenvalue computation {EigenSystem}