| Discontinuous Galerkin Library
    #include "dg/algorithm.h" | 
\( \alpha M \cdot x + \beta y\) and \( x^T M y \) More...
| Namespaces | |
| namespace | dg::blas2 | 
| BLAS Level 2 routines. | |
| Functions | |
| template<class ContainerType1 , class MatrixType , class ContainerType2 > | |
| auto | dg::blas2::dot (const ContainerType1 &x, const MatrixType &m, const ContainerType2 &y) | 
| \( x^T M y\); Binary reproducible general dot product | |
| template<class MatrixType , class ContainerType > | |
| get_value_type< MatrixType > | dg::blas2::dot (const MatrixType &m, const ContainerType &x) | 
| \( x^T M x\); Binary reproducible general dot product | |
| template<class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::blas2::symv (get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y) | 
| \( y = \alpha M x + \beta y\) | |
| template<class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::blas2::symv (MatrixType &&M, const ContainerType1 &x, ContainerType2 &y) | 
| \( y = M x\) | |
| template<class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::blas2::gemv (get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y) | 
| Alias for blas2::symv\( y = \alpha M x + \beta y \);. | |
| template<class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::blas2::gemv (MatrixType &&M, const ContainerType1 &x, ContainerType2 &y) | 
| Alias for blas2::symv\( y = M x\);. | |
| template<class Stencil , class ContainerType , class ... ContainerTypes> | |
| void | dg::blas2::parallel_for (Stencil f, unsigned N, ContainerType &&x, ContainerTypes &&... xs) | 
| \( f(i, x_0, x_1, ...)\ \forall i\); Customizable and generic for loop | |
| template<class FunctorType , class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::blas2::stencil (FunctorType f, MatrixType &&M, const ContainerType1 &x, ContainerType2 &y) | 
| \( F(M, x, y)\) | |
| template<class MatrixType , class AnotherMatrixType > | |
| void | dg::blas2::transfer (const MatrixType &x, AnotherMatrixType &y) | 
| \( y = x\); Generic way to copy and/or convert a Matrix type to a different Matrix type | |
| template<class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::apply (get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y) | 
| Alias for dg::blas2::symv\( y = \alpha M(x) + \beta y \);. | |
| template<class MatrixType , class ContainerType1 , class ContainerType2 > | |
| void | dg::apply (MatrixType &&M, const ContainerType1 &x, ContainerType2 &y) | 
| Alias for dg::blas2::symv\( y = M( x)\);. | |
\( \alpha M \cdot x + \beta y\) and \( x^T M y \)
| 
 | inline | 
Alias for dg::blas2::symv \( y = \alpha M(x) + \beta y \);. 
This Alias exists for code readability: if your matrix is not actually a matrix but a functor then it may seem unnatural to write blas2::symv in your code especially if M is non-linear. 
| 
 | inline | 
Alias for dg::blas2::symv \( y = M( x)\);. 
This Alias exists for code readability: if your matrix is not actually a matrix but a functor then it may seem unnatural to write blas2::symv in your code especially if M is non-linear. 
| 
 | inline | 
\( x^T M y\); Binary reproducible general dot product
This routine computes the scalar product defined by the symmetric positive definite matrix M
\[ x^T M y = \sum_{i,j=0}^{N-1} x_i M_{ij} y_j \]
For example
Or a more elaborate use case
Inf or NaN or the product of the input numbers reaches Inf or Nan then the behaviour is undefined and the function may throw. See dg::ISNFINITE and dg::ISNSANE in that case dg::exblas library and works for single and double precision. dg::blas1::vdot(
dg::Product(), x, m, y);| x | Left input | 
| m | The diagonal Matrix. | 
| y | Right input (may alias x) | 
x and y are vectors of containers and m is not, then we sum the results of dg::blas2::dot(
x[i], m, y[i]) nan | MatrixType | MatrixTypehas to have a category derived fromAnyVectorTagand must be compatible with theContainerTypes | 
| ContainerType | Any class for which a specialization of TensorTraitsexists and which fulfills the requirements of the there defined data and execution policies derived fromAnyVectorTagandAnyPolicyTag. Among others
 ContainerTypesin the argument list, thenTensorTraitsmust exist for all of them | 
| 
 | inline | 
\( x^T M x\); Binary reproducible general dot product
Alias for dg::blas2::dot( x,m,x) 
\[ x^T M x = \sum_{i,j=0}^{N-1} x_i M_{ij} x_j \]
| m | The diagonal Matrix | 
| x | Right input | 
x is a vector of containers and m is not, then we sum the results of dg::blas2::dot( m, x[i]) dg::blas2::dot( x, m, x); which should be prefered because it looks more explicit | MatrixType | MatrixTypehas to have a category derived fromAnyVectorTagand must be compatible with theContainerTypes | 
| ContainerType | Any class for which a specialization of TensorTraitsexists and which fulfills the requirements of the there defined data and execution policies derived fromAnyVectorTagandAnyPolicyTag. Among others
 ContainerTypesin the argument list, thenTensorTraitsmust exist for all of them | 
| 
 | inline | 
Alias for blas2::symv \( y = \alpha M x + \beta y \);. 
This Alias exists for code readability: if your "symmetric matrix" is not actually a symmetric matrix then it may seem unnatural to write blas2::symv in your code 
| 
 | inline | 
Alias for blas2::symv \( y = M x\);. 
This Alias exists for code readability: if your "symmetric matrix" is not actually a symmetric matrix then it may seem unnatural to write blas2::symv in your code 
| 
 | inline | 
\( f(i, x_0, x_1, ...)\ \forall i\); Customizable and generic for loop
dg::blas1::subroutine This routine loops over an arbitrary user-defined "loop body" functor f with an arbitrary number of arguments \( x_s\) elementwise 
\[ f(i, x_{0}, x_{1}, ...) \]
 where i iterates from 0 to a given size N. The order of iterations is undefined. It is equivalent to the following 
With this function very general for-loops can be parallelized like for example
or
dg::blas1::subroutine to non-trivial parallelization tasks. However, this comes at a price: this function only works for containers with the dg::SharedVectorTag and sclar types. The reason it cannot work for MPI is that the stencil (and thus the communication pattern) is unkown. However, it can serve as an important building block for other parallel functions like dg::blas2::stencil.  kokkos::parallel_for of the Kokkos library.| f | the loop body | 
| N | the total number of iterations in the for loop | 
| x | the first argument | 
| xs | other arguments | 
| Stencil | a function or functor with an arbitrary number of arguments and no return type; The first argument is an unsigned (the loop iteration), afterwards takes a const_pointer_typeargument (const pointer to first element in vector) for each input argument in the call and a pointer_type argument (pointer to first element in vector) for each output argument. Scalars are forwarded "as is" scalar_type .Stencilmust be callable on the device in use. In particular, with CUDA it must be a functor (not a function) and its signature must contain the __device__ specifier. (s.a. DG_DEVICE) | 
| ContainerType | Any class for which a specialization of TensorTraitsexists and which fulfills the requirements of theSharedVectorTagandAnyPolicyTag. Among others | 
| 
 | inline | 
\( F(M, x, y)\)
This routine calls
\[ F(i, [M], x, y) \]
 for all \( i \in [0,N[\), where N is the number of rows in M, using dg::blas2::parallel_for, where [M] depends on the matrix type:
Possible shared memory implementation
Other matrix types have not yet been implemented.
dg::blas2::parallel_for). dg::blas2::parallel_for to MPI vectors at the cost of having to encode the communication stencil in the matrix M and only one vector argument| f | The filter function is called like  f(i, m.row_offsets_ptr, m.column_indices_ptr, m.values_ptr, x_ptr, y_ptr)  | 
| M | The Matrix. | 
| x | input vector | 
| y | contains the solution on output (may not alias x) | 
| FunctorType | A type that is callable  void operator()( unsigned, pointer, [m_pointers], const_pointer) For GPU vector the functor must be callable on the device. | 
| MatrixType | So far only one of the dg::SparseMatrixtypes and their MPI variants are allowed | 
| ContainerType | Any class for which a specialization of TensorTraitsexists and which fulfills the requirements of the there defined data and execution policies derived fromAnyVectorTagandAnyPolicyTag. Among others
 ContainerTypesin the argument list, thenTensorTraitsmust exist for all of them | 
| 
 | inline | 
\( y = \alpha M x + \beta y\)
This routine computes
\[ y = \alpha M x + \beta y \]
 where \( M\) is a matrix (or functor that is called like M(alpha,x,beta,y)). 
M from being non-symmetric or even non-linear. In this sense the term "symv" (symmetrix-Matrix-Vector multiplication) is misleading. For better code readability we introduce aliases: dg::blas2::gemv (general Matrix-Vector multiplication) and dg::apply (general, possibly non-linear functor application).For example
or a more elaborate use case
| alpha | A Scalar | 
| M | The Matrix. | 
| x | input vector | 
| beta | A Scalar | 
| y | contains the solution on output (may not alias x) | 
y may not alias x, the only exception is if MatrixType has the AnyVectorTag | MatrixType | Any class for which a specialization of TensorTraitsexists and defines a tensor_category derived fromAnyMatrixTag. Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
 SelfMadeMatrixTagonly thoseblas2functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If aContainerhas theRecursiveVectorTag, then the matrix is applied to each of the elements unless the type has theSelfMadeMatrixTagor is a Functor type. | 
| ContainerType | Any class for which a specialization of TensorTraitsexists and which fulfills the requirements of the there defined data and execution policies derived fromAnyVectorTagandAnyPolicyTag. Among others
 ContainerTypesin the argument list, thenTensorTraitsmust exist for all of them | 
| 
 | inline | 
\( y = M x\)
This routine computes
\[ y = M x \]
 where \( M\) is a matrix (or functor that is called like M(x,y)). 
M from being non-symmetric or even non-linear. In this sense the term "symv" (symmetrix-Matrix-Vector multiplication) is misleading. For better code readability we introduce aliases: dg::blas2::gemv (general Matrix-Vector multiplication) and dg::apply (general, possibly non-linear functor application)For example
or a more elaborate use case
| M | The Matrix. | 
| x | input vector | 
| y | contains the solution on output (may not alias x) | 
y may not alias x, the only exception is if MatrixType has the AnyVectorTag and ContainerType1 ==ContainerType2 | MatrixType | Any class for which a specialization of TensorTraitsexists and defines a tensor_category derived fromAnyMatrixTag. Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
 SelfMadeMatrixTagonly thoseblas2functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If aContainerhas theRecursiveVectorTag, then the matrix is applied to each of the elements unless the type has theSelfMadeMatrixTagor is a Functor type. | 
| ContainerType | Any class for which a specialization of TensorTraitsexists and which fulfills the requirements of the there defined data and execution policies derived fromAnyVectorTagandAnyPolicyTag. Among others
 ContainerTypesin the argument list, thenTensorTraitsmust exist for all of them | 
| 
 | inline | 
\( y = x\); Generic way to copy and/or convert a Matrix type to a different Matrix type
e.g. from CPU to GPU, or double to float, etc.
| MatrixType | Any class for which a specialization of TensorTraitsexists and defines a tensor_category derived fromAnyMatrixTag. Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
 SelfMadeMatrixTagonly thoseblas2functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If aContainerhas theRecursiveVectorTag, then the matrix is applied to each of the elements unless the type has theSelfMadeMatrixTagor is a Functor type. | 
| AnotherMatrix | Another Matrix type | 
| x | source | 
| y | sink |