Discontinuous Galerkin Library
#include "dg/algorithm.h"
Loading...
Searching...
No Matches
Lowlevel helper functions and classes
Collaboration diagram for Lowlevel helper functions and classes:

Classes

struct  dg::ClonePtr< Cloneable >
 Manager class that invokes the clone() method on the managed ptr when copied. More...
 

Functions

template<class T >
SquareMatrix< T > dg::tensorproduct (const SquareMatrix< T > &op1, const SquareMatrix< T > &op2)
 Form the tensor product between two operators.
 
template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::tensorproduct (unsigned N, const SquareMatrix< T > &op)
 Tensor product between Identity matrix and an operator.
 
template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::sandwich (const SquareMatrix< T > &left, const dg::SparseMatrix< int, T, thrust::host_vector > &m, const SquareMatrix< T > &right)
 Multiply 1d matrices by diagonal block matrices from left and right.
 
template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::tensorproduct (const dg::SparseMatrix< int, T, thrust::host_vector > &lhs, const dg::SparseMatrix< int, T, thrust::host_vector > &rhs)
 \( L\otimes R\) Form the tensor (Kronecker) product between two matrices
 
template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::tensorproduct_cols (const dg::SparseMatrix< int, T, thrust::host_vector > &lhs, const dg::SparseMatrix< int, T, thrust::host_vector > &rhs)
 \( L\otimes R\) Form the tensor (Kronecker) product between two matrices in the column index
 

Detailed Description

Function Documentation

◆ sandwich()

template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::sandwich ( const SquareMatrix< T > & left,
const dg::SparseMatrix< int, T, thrust::host_vector > & m,
const SquareMatrix< T > & right )

Multiply 1d matrices by diagonal block matrices from left and right.

computes (1xleft)m(1xright)

Template Parameters
Tvalue type
Parameters
leftThe left hand side
mThe matrix
rightThe right hand side
Returns
A newly allocated sparse matrix

◆ tensorproduct() [1/3]

template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::tensorproduct ( const dg::SparseMatrix< int, T, thrust::host_vector > & lhs,
const dg::SparseMatrix< int, T, thrust::host_vector > & rhs )

\( L\otimes R\) Form the tensor (Kronecker) product between two matrices

The Kronecker product is formed by the triplets \(I = k n_r+l\), \( J = i N_r +j \), \( M_{IJ} = L_{ki}R_{lj}\)

Note
This function is "order preserving" in the sense that the order of row and column entries of lhs and rhs are preserved in the output. This is important for stencil computations.
Template Parameters
Tvalue type
Parameters
lhsThe left hand side matrix (duplicate entries lead to duplicate entries in result)
rhsThe right hand side matrix (duplicate entries lead to duplicate entries in result)
Returns
newly allocated matrix containing the tensor product

◆ tensorproduct() [2/3]

template<class T >
SquareMatrix< T > dg::tensorproduct ( const SquareMatrix< T > & op1,
const SquareMatrix< T > & op2 )

Form the tensor product between two operators.

Computes C_{ijkl} = op1_{ij}op2_{kl}

Template Parameters
TThe value type
Parameters
op1The left hand side
op2The right hand side
Returns
The tensor product

◆ tensorproduct() [3/3]

template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::tensorproduct ( unsigned N,
const SquareMatrix< T > & op )

Tensor product between Identity matrix and an operator.

\[ M = \begin{pmatrix} op & & & & & \\ & op & & & & \\ & & op & & & \\ & & & op & & \\ & & &...& & \end{pmatrix} \]

Can be used to create tensors that operate on each dg-vector entry

Template Parameters
Tvalue type
Parameters
NSize of the identity (=number of times op is repeated in the matrix)
opThe SquareMatrix
Returns
A newly allocated sparse matrix (of size N*op.size() )
See also
fast_transform

◆ tensorproduct_cols()

template<class T >
dg::SparseMatrix< int, T, thrust::host_vector > dg::tensorproduct_cols ( const dg::SparseMatrix< int, T, thrust::host_vector > & lhs,
const dg::SparseMatrix< int, T, thrust::host_vector > & rhs )

\( L\otimes R\) Form the tensor (Kronecker) product between two matrices in the column index

The Kronecker product in the columns is formed by the triplets \( J = i N_r +j \), \( M_{kJ} = L_{ki}R_{kj}\)

Note
This function is "order preserving" in the sense that the order of row and column entries of lhs and rhs are preserved in the output. This is important for stencil computations.
Template Parameters
Tvalue type
Parameters
lhsThe left hand side matrix (duplicate entries lead to duplicate entries in result)
rhsThe right hand side matrix (duplicate entries lead to duplicate entries in result)
Returns
newly allocated sparse matrix containing the tensor product