SpatialOps
MatVecOps.h File Reference

Includes objects for operating on matrices of fields. More...

#include <stdexcept>
#include <sstream>
#include <spatialops/structured/MatVecFields.h>
#include <spatialops/structured/SpatialField.h>
#include <spatialops/SpatialOpsConfigure.h>
#include <Eigen/Dense>

Go to the source code of this file.

Classes

struct  SpatialOps::DotProduct< FieldT >
 Performs the dot product on two vectors. More...
 
struct  SpatialOps::MatVecMult< FieldT >
 fwd declaration as this is a specialized T parameter More...
 
class  SpatialOps::BinaryMatOp< OpT >
 fwd declaration as this is a specialized T parameter More...
 
class  SpatialOps::BinaryMatScalarOp< OpT >
 Wraps RHS of a binary operator with a scalar. More...
 
class  SpatialOps::VecScalarOp< OpT >
 Wraps RHS of a Vector - Scalar or Scalar - Vector operation. More...
 
class  SpatialOps::MatScalarOp< OpT >
 Wraps RHS of a Matrix - Scalar or Scalar - Matrix operation. More...
 
class  SpatialOps::VecVecOp< OpT >
 Wraps RHS of a Vector - Vector operation. More...
 
class  SpatialOps::MatVecOp< OpT >
 Wraps RHS of a Matrix - Vector operation. More...
 
class  SpatialOps::MatMatOp< OpT >
 Wraps RHS of a Matrix - Matrix operation. More...
 
class  SpatialOps::MatUnaryOp< OpT >
 Wraps RHS of a unary matrix operation. More...
 
class  SpatialOps::BinaryRetMatUnaryOp< OpT >
 Wraps RHS of a unary matrix operation. More...
 
class  SpatialOps::MatVecOp< DotProduct< FieldT > >
 Specialization which doesn't use FieldT::operator =( ... ) More...
 
struct  SpatialOps::DotProduct< FieldT >
 Performs the dot product on two vectors. More...
 
struct  SpatialOps::MatOperation< OpT, RightT, LeftT, ResultT >
 Operation base class defined on matrices and/or vectors. More...
 
struct  SpatialOps::VecScalarMult< FieldT >
 Multiply a scalar by a vector. More...
 
struct  SpatialOps::MatScalarMult< FieldT >
 Multiply a matrix by a scalar. More...
 
struct  SpatialOps::MatVecMult< FieldT >
 fwd declaration as this is a specialized T parameter More...
 
struct  SpatialOps::MatMatMult< FieldT >
 Multiply a matix by a matrix on the right. More...
 
struct  SpatialOps::VecVecAdd< FieldT >
 Add a vector to a vector on the right. More...
 
struct  SpatialOps::MatMatAdd< FieldT >
 Add a matix to a matrix on the right. More...
 
struct  SpatialOps::VecVecSub< FieldT >
 Sub a vector to a vector on the right. More...
 
struct  SpatialOps::MatMatSub< FieldT >
 Sub a matix to a matrix on the right. More...
 
struct  SpatialOps::MatScalDiagOffset< FieldT >
 Add a scalar value to the diagonal elements of a matrix. More...
 
class  SpatialOps::LinearSolve< FieldT >
 Find the solution to result = inv(mat) * rhsVec with LU decomposition. More...
 
class  SpatialOps::EigenDecomposition< FieldT >
 Operator to perform eigen decomposition. More...
 

Functions

template<typename FieldT >
VecScalarOp< VecScalarMult< FieldT > > SpatialOps::operator* (const typename FieldT::value_type &left, const FieldVector< FieldT > &right)
 Multiply a vector (right) with a scalar, i.e. scal * vec. More...
 
template<typename FieldT >
MatScalarOp< MatScalarMult< FieldT > > SpatialOps::operator* (const typename FieldT::value_type &left, const FieldMatrix< FieldT > &right)
 Multiply a matrix (right) with a scalar, i.e. scal * mat. More...
 
template<typename FieldT >
MatVecOp< MatVecMult< FieldT > > SpatialOps::operator* (const FieldMatrix< FieldT > &left, const FieldVector< FieldT > &right)
 Multiply a matrix (right) with a vector on the left, i.e. mat * vec. More...
 
template<typename FieldT >
MatMatOp< MatMatMult< FieldT > > SpatialOps::operator* (const FieldMatrix< FieldT > &left, const FieldMatrix< FieldT > &right)
 Multiply a matrix (right) with another matrix on the left, i.e. mat1 * mat2. More...
 
template<typename FieldT >
VecVecOp< VecVecAdd< FieldT > > SpatialOps::operator+ (const FieldVector< FieldT > &left, const FieldVector< FieldT > &right)
 Add a vector (right) with another vector on the left, i.e. vec1 + vec2. More...
 
template<typename FieldT >
MatMatOp< MatMatAdd< FieldT > > SpatialOps::operator+ (const FieldMatrix< FieldT > &left, const FieldMatrix< FieldT > &right)
 Add a matrix (right) with another matrix on the left, i.e. mat1 + mat2. More...
 
template<typename FieldT >
VecVecOp< VecVecSub< FieldT > > SpatialOps::operator- (const FieldVector< FieldT > &left, const FieldVector< FieldT > &right)
 Sub a vector (right) with another vector on the left, i.e. vec1 - vec2. More...
 
template<typename FieldT >
MatMatOp< MatMatSub< FieldT > > SpatialOps::operator- (const FieldMatrix< FieldT > &left, const FieldMatrix< FieldT > &right)
 Sub a matrix (right) with another matrix on the left, i.e. mat1 - mat2. More...
 
template<typename FieldT >
static MatVecOp< DotProduct< FieldT > > SpatialOps::dot_product_proto (const FieldVector< FieldT > &vec1, const FieldVector< FieldT > &vec2)
 calculate the dot product of two vectors More...
 

Detailed Description

Includes objects for operating on matrices of fields.

IMPORTANT: While reading, the brace indentations are organized such that every open brace and close brace pair are at the exact same indentation. One line blocks are an exception, the close brace is placed at the end of the single line.

Two classes in this file provide the interface for linear operations, MatVecOp and MatUnaryOp. Their functionality is identical except the former is constructed with two objects vs. one with the latter. The basic procedure for any operation proceeds in 4 steps: first a Mat*Op object is constructed from the rhs; second the ::eval method is called on the lhs; third, the lhs and rhs pointers are given to the operator in the ::launch method; fourth, the problem is divided on available cores and the operation is performed or it is sent to the GPU device and performed.

Definition in file MatVecOps.h.

Function Documentation

◆ dot_product_proto()

template<typename FieldT >
static MatVecOp< DotProduct< FieldT > > SpatialOps::dot_product_proto ( const FieldVector< FieldT > &  vec1,
const FieldVector< FieldT > &  vec2 
)
static

calculate the dot product of two vectors

Parameters
vec1a vector to dot with
vec2other vector to dot with
Returns
DotProduct object to interface with assignment operator

Returns the operator for the dot prod. Implementation is still a prototype partly because we do not want to add an extra operator before ensuring the validity of this code.

Definition at line 1036 of file MatVecOps.h.

References SpatialOps::dot_product_proto().

Referenced by SpatialOps::dot_product_proto().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*() [1/4]

template<typename FieldT >
VecScalarOp< VecScalarMult< FieldT > > SpatialOps::operator* ( const typename FieldT::value_type &  left,
const FieldVector< FieldT > &  right 
)

Multiply a vector (right) with a scalar, i.e. scal * vec.

Parameters
leftscalar on rhs
rightvector on rhs
Returns
MatScalarOp collects pointers of the left and right hand sides

This creates an operator for a simple "scalar * vector" operation

Definition at line 932 of file MatVecOps.h.

◆ operator*() [2/4]

template<typename FieldT >
MatScalarOp< MatScalarMult< FieldT > > SpatialOps::operator* ( const typename FieldT::value_type &  left,
const FieldMatrix< FieldT > &  right 
)

Multiply a matrix (right) with a scalar, i.e. scal * mat.

Parameters
leftscalar on rhs
rightmatrix on rhs
Returns
MatVecOp collects pointers of the left and right hand sides

This creates an operator for a simple "scalar * matrix" operation

Definition at line 947 of file MatVecOps.h.

◆ operator*() [3/4]

template<typename FieldT >
MatVecOp< MatVecMult< FieldT > > SpatialOps::operator* ( const FieldMatrix< FieldT > &  left,
const FieldVector< FieldT > &  right 
)

Multiply a matrix (right) with a vector on the left, i.e. mat * vec.

Parameters
leftmatrix on rhs
rightvector on rhs
Returns
MatVecOp collects pointers of the left and right hand sides

This creates an operator for a simple "matrix * vector" operation

Definition at line 962 of file MatVecOps.h.

◆ operator*() [4/4]

template<typename FieldT >
MatMatOp< MatMatMult< FieldT > > SpatialOps::operator* ( const FieldMatrix< FieldT > &  left,
const FieldMatrix< FieldT > &  right 
)

Multiply a matrix (right) with another matrix on the left, i.e. mat1 * mat2.

Parameters
leftmatrix on rhs
rightmatrix on rhs
Returns
MatVecOp collects pointers of the left and right hand sides

This creates an operator for a simple "matrix * matrix" operation

Definition at line 974 of file MatVecOps.h.

◆ operator+() [1/2]

template<typename FieldT >
VecVecOp< VecVecAdd< FieldT > > SpatialOps::operator+ ( const FieldVector< FieldT > &  left,
const FieldVector< FieldT > &  right 
)

Add a vector (right) with another vector on the left, i.e. vec1 + vec2.

Parameters
leftvector on rhs
rightvector on rhs
Returns
VecVecOp collects pointers of the left and right hand sides

This creates an operator for a simple "vector + vector" operation

Definition at line 986 of file MatVecOps.h.

◆ operator+() [2/2]

template<typename FieldT >
MatMatOp< MatMatAdd< FieldT > > SpatialOps::operator+ ( const FieldMatrix< FieldT > &  left,
const FieldMatrix< FieldT > &  right 
)

Add a matrix (right) with another matrix on the left, i.e. mat1 + mat2.

Parameters
leftmatrix on rhs
rightmatrix on rhs
Returns
MatMatOp collects pointers of the left and right hand sides

This creates an operator for a simple "matrix + matrix" operation

Definition at line 998 of file MatVecOps.h.

◆ operator-() [1/2]

template<typename FieldT >
VecVecOp< VecVecSub< FieldT > > SpatialOps::operator- ( const FieldVector< FieldT > &  left,
const FieldVector< FieldT > &  right 
)

Sub a vector (right) with another vector on the left, i.e. vec1 - vec2.

Parameters
leftvector on rhs
rightvector on rhs
Returns
VecVecOp collects pointers of the left and right hand sides

This creates an operator for a simple "vector - vector" operation

Definition at line 1010 of file MatVecOps.h.

◆ operator-() [2/2]

template<typename FieldT >
MatMatOp< MatMatSub< FieldT > > SpatialOps::operator- ( const FieldMatrix< FieldT > &  left,
const FieldMatrix< FieldT > &  right 
)

Sub a matrix (right) with another matrix on the left, i.e. mat1 - mat2.

Parameters
leftmatrix on rhs
rightmatrix on rhs
Returns
MatMatOp collects pointers of the left and right hand sides

This creates an operator for a simple "matrix - matrix" operation

Definition at line 1022 of file MatVecOps.h.