LvArray
Namespaces | Functions | Variables
genericTensorOps.hpp File Reference

Contains the implementation of arbitrary sized vector and matrix operations. More...

#include "ArraySlice.hpp"
#include "math.hpp"
Include dependency graph for genericTensorOps.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 LvArray
 The top level namespace.
 
 LvArray::tensorOps
 Contains operations for operating on compile time sized vectors and matrices.
 

Macros

Initialization and assignment macros.

Macros that aid in to initializng and assigning to common vector and matrix sizes.

Use these macros to initialize c-arrays from other c-arrays or Array objects and to assign to either c-arrays or Array objects. Usage:

int vectorA[ 3 ] = { 0, 1, 2 };
int const vectorACopy[ 3 ] = LVARRAY_TENSOROPS_INIT_LOCAL_3( vectorA );
LVARRAY_TENSOROPS_ASSIGN_2( vectorA, 5, 3 );
Array< double, 2, ... > arrayOfMatrices( JSIZE, 2, 2 );
double matrix[ 2 ][ 2 ] = LVARRAY_TENSOROPS_INIT_LOCAL_2x2( arrayOfMatrices[ 0 ] );
LVARRAY_TENSOROPS_ASSIGN_2x2( arrayOfMatrices[ 0 ], a00, a01, a10, a11 );

Note that since these are macros expressions and not just variables can be passed.

int vectorA[ 3 ] = { 0, 1, 2 };
int const vectorATimes2[ 3 ] = LVARRAY_TENSOROPS_INIT_LOCAL_3( 2 * vectorA );
Note
No bounds checking is done on the provided expression.
#define LVARRAY_TENSOROPS_INIT_LOCAL_2(EXP)   { EXP[ 0 ], EXP[ 1 ] }
 Create an initializer list of length 2 from EXP. More...
 
#define LVARRAY_TENSOROPS_ASSIGN_2(var, exp0, exp1)   var[ 0 ] = exp0; var[ 1 ] = exp1
 Assign to the length 2 vector var. More...
 
#define LVARRAY_TENSOROPS_INIT_LOCAL_3(EXP)   { EXP[ 0 ], EXP[ 1 ], EXP[ 2 ] }
 Create an initializer list of length 3 from EXP. More...
 
#define LVARRAY_TENSOROPS_ASSIGN_3(var, exp0, exp1, exp2)   var[ 0 ] = exp0; var[ 1 ] = exp1; var[ 2 ] = exp2
 Assign to the length 3 vector var. More...
 
#define LVARRAY_TENSOROPS_INIT_LOCAL_6(EXP)   { EXP[ 0 ], EXP[ 1 ], EXP[ 2 ], EXP[ 3 ], EXP[ 4 ], EXP[ 5 ] }
 Create an initializer list of length 6 from EXP. More...
 
#define LVARRAY_TENSOROPS_ASSIGN_6(var, exp0, exp1, exp2, exp3, exp4, exp5)   var[ 0 ] = exp0; var[ 1 ] = exp1; var[ 2 ] = exp2; var[ 3 ] = exp3; var[ 4 ] = exp4; var[ 5 ] = exp5
 Assign to the length 6 vector var. More...
 
#define LVARRAY_TENSOROPS_INIT_LOCAL_2x2(EXP)
 Create an 2x2 initializer list from EXP. More...
 
#define LVARRAY_TENSOROPS_ASSIGN_2x2(var, exp00, exp01, exp10, exp11)
 Assign to the 2x2 matrix var. More...
 
#define LVARRAY_TENSOROPS_INIT_LOCAL_3x3(EXP)
 Create an 3x3 initializer list from EXP. More...
 
#define LVARRAY_TENSOROPS_ASSIGN_3x3(var, exp00, exp01, exp02, exp10, exp11, exp12, exp20, exp21, exp22)
 Assign to the 3x3 matrix var. More...
 

Functions

 LvArray::tensorOps::internal::HAS_STATIC_MEMBER (SIZE)
 Expands to a static constexpr template bool HasStaticMember_SIZE which is true if T has a static member T::SIZE. More...
 
 LvArray::tensorOps::internal::HAS_STATIC_MEMBER (NDIM)
 Expands to a static constexpr template bool HasStaticMember_NDIM which is true if T has a static member T::NDIM. More...
 
template<std::ptrdiff_t ISIZE, typename T >
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< HasStaticMember_SIZE< T > > LvArray::tensorOps::internal::checkSizes (T const &src)
 Verify at compile time that the size of a user-provided type is as expected. More...
 
template<std::ptrdiff_t PROVIDED_SIZE, typename T , std::ptrdiff_t INFERRED_SIZE>
LVARRAY_HOST_DEVICE constexpr void LvArray::tensorOps::internal::checkSizes (T const (&src)[INFERRED_SIZE])
 Verify at compile time that the size of the c-array is as expected. More...
 
template<std::ptrdiff_t PROVIDED_M, std::ptrdiff_t PROVIDED_N, typename T , std::ptrdiff_t INFERRED_M, std::ptrdiff_t INFERRED_N>
LVARRAY_HOST_DEVICE constexpr void LvArray::tensorOps::internal::checkSizes (T const (&src)[INFERRED_M][INFERRED_N])
 Verify at compile time that the size of the 2D c-array is as expected. More...
 
template<std::ptrdiff_t ISIZE, typename ARRAY >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< HasStaticMember_NDIM< ARRAY > > LvArray::tensorOps::internal::checkSizes (ARRAY const &array)
 Verify at compile time that. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename ARRAY >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< HasStaticMember_NDIM< ARRAY > > LvArray::tensorOps::internal::checkSizes (ARRAY const &array)
 Verify at compile time that. More...
 
Generic operations

Functions that are overloaded to operate on both vectors and matrices.

Note
Not all of the functions have been overloaded to operate on both vectors and matrices.
template<std::ptrdiff_t ISIZE, typename VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::maxAbsoluteEntry (VECTOR &&vector)
 
template<std::ptrdiff_t ISIZE, typename VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::fill (VECTOR &&vector, std::remove_reference_t< decltype(vector[0]) > const value)
 Set the entries of vector to value. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::fill (MATRIX &&matrix, std::remove_reference_t< decltype(matrix[0][0]) > const value)
 Set the entries of matrix to value. More...
 
template<std::ptrdiff_t ISIZE, typename DST_VECTOR , typename SRC_VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::copy (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, SRC_VECTOR const &LVARRAY_RESTRICT_REF srcVector)
 Copy srcVector into dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename SRC_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::copy (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, SRC_MATRIX const &LVARRAY_RESTRICT_REF srcMatrix)
 Copy srcMatrix into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, typename VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::scale (VECTOR &&vector, std::remove_reference_t< decltype(vector[0]) > const scale)
 Multiply the entries of vector by scale. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::scale (MATRIX &&matrix, std::remove_reference_t< decltype(matrix[0][0]) > const scale)
 Multiply the entries of matrix by scale. More...
 
template<std::ptrdiff_t ISIZE, typename DST_VECTOR , typename SRC_VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::scaledCopy (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, SRC_VECTOR const &LVARRAY_RESTRICT_REF srcVector, std::remove_reference_t< decltype(srcVector[0]) > const scale)
 Copy srcVector scaled by scale into dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename SRC_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::scaledCopy (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, SRC_MATRIX const &LVARRAY_RESTRICT_REF srcMatrix, std::remove_reference_t< decltype(srcMatrix[0][0]) > const scale)
 Copy srcMatrix scaled by scale into dstMatrix. More...
 
template<std::ptrdiff_t M, typename DST_VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::addScalar (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, std::remove_reference_t< decltype(dstVector[0]) > const value)
 Add value to dstVector. More...
 
template<std::ptrdiff_t ISIZE, typename DST_VECTOR , typename SRC_VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::add (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, SRC_VECTOR const &LVARRAY_RESTRICT_REF srcVector)
 Add srcVector to dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename SRC_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::add (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, SRC_MATRIX const &LVARRAY_RESTRICT_REF srcMatrix)
 Add srcMatrix to dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, typename DST_VECTOR , typename SRC_VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::subtract (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, SRC_VECTOR const &LVARRAY_RESTRICT_REF srcVector)
 Subtract srcVector from dstVector. More...
 
template<std::ptrdiff_t ISIZE, typename DST_VECTOR , typename SRC_VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::scaledAdd (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, SRC_VECTOR const &LVARRAY_RESTRICT_REF srcVector, std::remove_reference_t< decltype(srcVector[0]) > const scale)
 Add srcVector scaled by scale to dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename SRC_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::scaledAdd (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, SRC_MATRIX const &LVARRAY_RESTRICT_REF srcMatrix, std::remove_reference_t< decltype(srcMatrix[0][0]) > const scale)
 Add srcMatrix scaled by scale to dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, typename DST_VECTOR , typename VECTOR_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::hadamardProduct (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, VECTOR_A const &LVARRAY_RESTRICT_REF vectorA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Multiply the elements of vectorA and vectorB putting the result into dstVector. More...
 
Vector operations

Functions that operate on vectors.

template<std::ptrdiff_t ISIZE, typename VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::l2NormSquared (VECTOR const &vector)
 
template<std::ptrdiff_t ISIZE, typename VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::l2Norm (VECTOR const &vector)
 
template<std::ptrdiff_t ISIZE, typename VECTOR >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::normalize (VECTOR &&vector)
 Scale vector to a unit vector. More...
 
template<std::ptrdiff_t JSIZE, typename VECTOR_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::AiBi (VECTOR_A const &LVARRAY_RESTRICT_REF vectorA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 
template<typename DST_VECTOR , typename VECTOR_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::crossProduct (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, VECTOR_A const &LVARRAY_RESTRICT_REF vectorA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Compute the cross product of vectorA and vectorB and put it in dstVector. More...
 
Matrix-vector operations

Functions that operate on matrices and vectors.

template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename VECTOR_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_eq_AiBj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, VECTOR_A const &LVARRAY_RESTRICT_REF vectorA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Perform the outer product of vectorA and vectorB writing the result to dstMatrix. More...
 
template<std::ptrdiff_t JSIZE, std::ptrdiff_t ISIZE, typename DST_MATRIX , typename VECTOR_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_add_AiBj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, VECTOR_A const &LVARRAY_RESTRICT_REF vectorA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Perform the outer product of vectorA and vectorB adding the result to dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_VECTOR , typename MATRIX_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Ri_eq_AijBj (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Perform the matrix vector multiplication of matrixA and vectorB writing the result to dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_VECTOR , typename MATRIX_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Ri_add_AijBj (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Perform the matrix vector multiplication of matrixA and vectorB adding the result to dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_VECTOR , typename MATRIX_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Ri_eq_AjiBj (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Perform the matrix vector multiplication of the transpose of matrixA and vectorB writing the result to dstVector. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_VECTOR , typename MATRIX_A , typename VECTOR_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Ri_add_AjiBj (DST_VECTOR &&LVARRAY_RESTRICT_REF dstVector, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, VECTOR_B const &LVARRAY_RESTRICT_REF vectorB)
 Perform the matrix vector multiplication of the transpose of matrixA and vectorB adding the result to dstVector. More...
 
Matrix operations

Functions that operate matrices of any shape.

template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename SRC_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::transpose (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, SRC_MATRIX const &LVARRAY_RESTRICT_REF srcMatrix)
 Store the transpose of the NxM matrix srcMatrix in dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, std::ptrdiff_t KSIZE, typename DST_MATRIX , typename MATRIX_A , typename MATRIX_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_eq_AikBkj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, MATRIX_B const &LVARRAY_RESTRICT_REF matrixB)
 Multiply matrixA with matrixB and put the result into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, std::ptrdiff_t KSIZE, typename DST_MATRIX , typename MATRIX_A , typename MATRIX_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_add_AikBkj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, MATRIX_B const &LVARRAY_RESTRICT_REF matrixB)
 Multiply matrixA with matrixB and add the result to dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, std::ptrdiff_t KSIZE, typename DST_MATRIX , typename MATRIX_A , typename MATRIX_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_eq_AikBjk (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, MATRIX_B const &LVARRAY_RESTRICT_REF matrixB)
 Multiply matrixA with the transpose of matrixB and put the result into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, std::ptrdiff_t KSIZE, typename DST_MATRIX , typename MATRIX_A , typename MATRIX_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_add_AikBjk (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, MATRIX_B const &LVARRAY_RESTRICT_REF matrixB)
 Multiply matrixA with the transpose of matrixB and put the result into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename MATRIX_A >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_add_AikAjk (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA)
 Multiply matrixA with the transpose of itself and put the result into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, std::ptrdiff_t KSIZE, typename DST_MATRIX , typename MATRIX_A , typename MATRIX_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_eq_AkiBkj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, MATRIX_B const &LVARRAY_RESTRICT_REF matrixB)
 Multiply the transpose of matrixA with matrixB and put the result into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename DST_MATRIX , typename MATRIX_A >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_eq_AkiAkj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA)
 Multiply the transpose of matrixA with matrixA and put the result into dstMatrix. More...
 
template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, std::ptrdiff_t KSIZE, typename DST_MATRIX , typename MATRIX_A , typename MATRIX_B >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::Rij_add_AkiBkj (DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, MATRIX_A const &LVARRAY_RESTRICT_REF matrixA, MATRIX_B const &LVARRAY_RESTRICT_REF matrixB)
 Multiply the transpose of matrixA with matrixB and add the result into dstMatrix. More...
 
Square matrix operations

Functions that operate on square matrices of any size.

template<std::ptrdiff_t ISIZE, typename MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::transpose (MATRIX &&LVARRAY_RESTRICT_REF matrix)
 Transpose the MxM matrix matrix. More...
 
template<std::ptrdiff_t ISIZE, typename MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::addIdentity (MATRIX &&matrix, std::remove_reference_t< decltype(matrix[0][0]) > const scale)
 Add scale times the identity matrix to matrix. More...
 
template<std::ptrdiff_t ISIZE, typename MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::trace (MATRIX const &matrix)
 
Symmetric matrix operations

Functions that operate on symmetric matrices of any size.

template<std::ptrdiff_t ISIZE, typename SYM_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::tensorOps::symAddIdentity (SYM_MATRIX &&symMatrix, std::remove_reference_t< decltype(symMatrix[0]) > const scale)
 Add scale times the identity matrix to symMatrix. More...
 
template<std::ptrdiff_t ISIZE, typename SYM_MATRIX >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK auto LvArray::tensorOps::symTrace (SYM_MATRIX const &symMatrix)
 

Variables

template<std::ptrdiff_t ISIZE>
constexpr std::ptrdiff_t LvArray::tensorOps::SYM_SIZE = ( ISIZE * ( ISIZE + 1 ) ) / 2
 The size of a symmetric MxM matrix in Voigt notation.
 

Detailed Description

Contains the implementation of arbitrary sized vector and matrix operations.

Macro Definition Documentation

◆ LVARRAY_TENSOROPS_ASSIGN_2

#define LVARRAY_TENSOROPS_ASSIGN_2 (   var,
  exp0,
  exp1 
)    var[ 0 ] = exp0; var[ 1 ] = exp1

Assign to the length 2 vector var.

Parameters
varThe vector of length 2 to assign to.
exp0The value to assign to var[ 0 ].
exp1The value to assign to var[ 1 ].

◆ LVARRAY_TENSOROPS_ASSIGN_2x2

#define LVARRAY_TENSOROPS_ASSIGN_2x2 (   var,
  exp00,
  exp01,
  exp10,
  exp11 
)
Value:
var[ 0 ][ 0 ] = exp00; var[ 0 ][ 1 ] = exp01; \
var[ 1 ][ 0 ] = exp10; var[ 1 ][ 1 ] = exp11

Assign to the 2x2 matrix var.

Parameters
varThe 2x2 matrix to assign to.
exp00The value to assign to var[ 0 ][ 0 ].
exp01The value to assign to var[ 0 ][ 1 ].
exp10The value to assign to var[ 1 ][ 0 ].
exp11The value to assign to var[ 1 ][ 1 ].

◆ LVARRAY_TENSOROPS_ASSIGN_3

#define LVARRAY_TENSOROPS_ASSIGN_3 (   var,
  exp0,
  exp1,
  exp2 
)    var[ 0 ] = exp0; var[ 1 ] = exp1; var[ 2 ] = exp2

Assign to the length 3 vector var.

Parameters
varThe vector of length 3 to assign to.
exp0The value to assign to var[ 0 ].
exp1The value to assign to var[ 1 ].
exp2The value to assign to var[ 2 ].

◆ LVARRAY_TENSOROPS_ASSIGN_3x3

#define LVARRAY_TENSOROPS_ASSIGN_3x3 (   var,
  exp00,
  exp01,
  exp02,
  exp10,
  exp11,
  exp12,
  exp20,
  exp21,
  exp22 
)
Value:
var[ 0 ][ 0 ] = exp00; var[ 0 ][ 1 ] = exp01; var[ 0 ][ 2 ] = exp02; \
var[ 1 ][ 0 ] = exp10; var[ 1 ][ 1 ] = exp11; var[ 1 ][ 2 ] = exp12; \
var[ 2 ][ 0 ] = exp20; var[ 2 ][ 1 ] = exp21; var[ 2 ][ 2 ] = exp22

Assign to the 3x3 matrix var.

Parameters
varThe 3x3 matrix to assign to.
exp00The value to assign to var[ 0 ][ 0 ].
exp01The value to assign to var[ 0 ][ 1 ].
exp02The value to assign to var[ 0 ][ 2 ].
exp10The value to assign to var[ 1 ][ 0 ].
exp11The value to assign to var[ 1 ][ 1 ].
exp12The value to assign to var[ 1 ][ 2 ].
exp20The value to assign to var[ 2 ][ 0 ].
exp21The value to assign to var[ 2 ][ 1 ].
exp22The value to assign to var[ 2 ][ 2 ].

◆ LVARRAY_TENSOROPS_ASSIGN_6

#define LVARRAY_TENSOROPS_ASSIGN_6 (   var,
  exp0,
  exp1,
  exp2,
  exp3,
  exp4,
  exp5 
)    var[ 0 ] = exp0; var[ 1 ] = exp1; var[ 2 ] = exp2; var[ 3 ] = exp3; var[ 4 ] = exp4; var[ 5 ] = exp5

Assign to the length 6 vector var.

Parameters
varThe vector of length 6 to assign to.
exp0The value to assign to var[ 0 ].
exp1The value to assign to var[ 1 ].
exp2The value to assign to var[ 2 ].
exp3The value to assign to var[ 3 ].
exp4The value to assign to var[ 4 ].
exp5The value to assign to var[ 5 ].

◆ LVARRAY_TENSOROPS_INIT_LOCAL_2

#define LVARRAY_TENSOROPS_INIT_LOCAL_2 (   EXP)    { EXP[ 0 ], EXP[ 1 ] }

Create an initializer list of length 2 from EXP.

Parameters
EXPThe expression used to create the initialize list.

◆ LVARRAY_TENSOROPS_INIT_LOCAL_2x2

#define LVARRAY_TENSOROPS_INIT_LOCAL_2x2 (   EXP)
Value:
{ { EXP[ 0 ][ 0 ], EXP[ 0 ][ 1 ] }, \
{ EXP[ 1 ][ 0 ], EXP[ 1 ][ 1 ] } }

Create an 2x2 initializer list from EXP.

Parameters
EXPThe expression used to create the initialize list.

◆ LVARRAY_TENSOROPS_INIT_LOCAL_3

#define LVARRAY_TENSOROPS_INIT_LOCAL_3 (   EXP)    { EXP[ 0 ], EXP[ 1 ], EXP[ 2 ] }

Create an initializer list of length 3 from EXP.

Parameters
EXPThe expression used to create the initialize list.

◆ LVARRAY_TENSOROPS_INIT_LOCAL_3x3

#define LVARRAY_TENSOROPS_INIT_LOCAL_3x3 (   EXP)
Value:
{ { EXP[ 0 ][ 0 ], EXP[ 0 ][ 1 ], EXP[ 0 ][ 2 ] }, \
{ EXP[ 1 ][ 0 ], EXP[ 1 ][ 1 ], EXP[ 1 ][ 2 ] }, \
{ EXP[ 2 ][ 0 ], EXP[ 2 ][ 1 ], EXP[ 2 ][ 2 ] } }

Create an 3x3 initializer list from EXP.

Parameters
EXPThe expression used to create the initialize list.

◆ LVARRAY_TENSOROPS_INIT_LOCAL_6

#define LVARRAY_TENSOROPS_INIT_LOCAL_6 (   EXP)    { EXP[ 0 ], EXP[ 1 ], EXP[ 2 ], EXP[ 3 ], EXP[ 4 ], EXP[ 5 ] }

Create an initializer list of length 6 from EXP.

Parameters
EXPThe expression used to create the initialize list.

Function Documentation

◆ checkSizes() [1/5]

template<std::ptrdiff_t ISIZE, typename T >
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< HasStaticMember_SIZE< T > > LvArray::tensorOps::internal::checkSizes ( T const &  src)
inline

Verify at compile time that the size of a user-provided type is as expected.

Template Parameters
ISIZEThe size the array should be.
TThe provided type.
Parameters
srcThe value to check.
Note
This overload is enabled for user-defined types that expose a compile-time size parameter through a public static integral member variable SIZE
Returns
None.

◆ checkSizes() [2/5]

template<std::ptrdiff_t PROVIDED_SIZE, typename T , std::ptrdiff_t INFERRED_SIZE>
LVARRAY_HOST_DEVICE constexpr void LvArray::tensorOps::internal::checkSizes ( T const (&)  src[INFERRED_SIZE])
inline

Verify at compile time that the size of the c-array is as expected.

Template Parameters
PROVIDED_SIZEThe size the array should be.
TThe type contained in the array.
INFERRED_SIZEThe size of the array.
Parameters
srcThe 1D c-array to check.

◆ checkSizes() [3/5]

template<std::ptrdiff_t PROVIDED_M, std::ptrdiff_t PROVIDED_N, typename T , std::ptrdiff_t INFERRED_M, std::ptrdiff_t INFERRED_N>
LVARRAY_HOST_DEVICE constexpr void LvArray::tensorOps::internal::checkSizes ( T const (&)  src[INFERRED_M][INFERRED_N])
inline

Verify at compile time that the size of the 2D c-array is as expected.

Template Parameters
PROVIDED_MWhat the size of the first dimension should be.
PROVIDED_MWhat the size of the second dimension should be.
TThe type contained in the array.
PROVIDED_MThe size of the first dimension.
PROVIDED_MThe size of the second dimension.
Parameters
srcThe 2D c-array to check.

◆ checkSizes() [4/5]

template<std::ptrdiff_t ISIZE, typename ARRAY >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< HasStaticMember_NDIM< ARRAY > > LvArray::tensorOps::internal::checkSizes ( ARRAY const &  array)
inline

Verify at compile time that.

Template Parameters
ARRAYis 1D and at runtime verify the size when LVARRAY_BOUNDS_CHECK.
ISIZEThe size expected size.
ARRAYThe type o array, should be an Array, ArrayView or ArraySlice.
Parameters
arrayThe array to check.
Returns
None.

◆ checkSizes() [5/5]

template<std::ptrdiff_t ISIZE, std::ptrdiff_t JSIZE, typename ARRAY >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< HasStaticMember_NDIM< ARRAY > > LvArray::tensorOps::internal::checkSizes ( ARRAY const &  array)
inline

Verify at compile time that.

Template Parameters
ARRAYis 2D and at runtime verify the sizes when LVARRAY_BOUNDS_CHECK.
ISIZEThe expected size of the first dimension.
JSIZEThe expected size of the second dimension.
ARRAYThe type o array, should be an Array, ArrayView or ArraySlice.
Parameters
arrayThe array to check.
Returns
None.

◆ HAS_STATIC_MEMBER() [1/2]

LvArray::tensorOps::internal::HAS_STATIC_MEMBER ( SIZE  )

Expands to a static constexpr template bool HasStaticMember_SIZE which is true if T has a static member T::SIZE.

Template Parameters
TThe type to query.

◆ HAS_STATIC_MEMBER() [2/2]

LvArray::tensorOps::internal::HAS_STATIC_MEMBER ( NDIM  )

Expands to a static constexpr template bool HasStaticMember_NDIM which is true if T has a static member T::NDIM.

Template Parameters
TThe type to query.