GEOSX
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
geosx::Tensor< T, SIZE_TPARAM > Class Template Reference

Lightweight wrapper around a c-array. More...

#include <Tensor.hpp>

Public Types

using value_type = T
 Alias for type template parameter.
 

Public Member Functions

GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE T const & operator[] (std::ptrdiff_t const i) const
 Const element access. More...
 
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE T & operator[] (std::ptrdiff_t const i)
 Non-const element access. More...
 
template<typename U = T>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE std::enable_if_t< std::is_floating_point< U >::value, bool > operator== (Tensor< U, SIZE > const &rhs) const
 Equality comparison operator. More...
 
template<typename U = T>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE std::enable_if_t< !std::is_floating_point< U >::value, bool > operator== (Tensor< U, SIZE > const &rhs) const
 Equality comparison operator. More...
 
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE constexpr int size (int junk) const
 Returns the size of the tensor. More...
 

Public Attributes

data [SIZE] = {}
 Underlying array.
 

Static Public Attributes

static constexpr int SIZE = SIZE_TPARAM
 Alias for size template parameter.
 

Friends

std::ostream & operator<< (std::ostream &os, Tensor< T, SIZE > const &t)
 Stream insertion operator for Tensor. More...
 

Detailed Description

template<typename T, int SIZE_TPARAM>
class geosx::Tensor< T, SIZE_TPARAM >

Lightweight wrapper around a c-array.

Template Parameters
Tdata type
SIZE_TPARAMnumber of values

Definition at line 29 of file Tensor.hpp.

Member Function Documentation

◆ operator==() [1/2]

template<typename T, int SIZE_TPARAM>
template<typename U = T>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE std::enable_if_t< std::is_floating_point< U >::value, bool > geosx::Tensor< T, SIZE_TPARAM >::operator== ( Tensor< U, SIZE > const &  rhs) const
inline

Equality comparison operator.

Template Parameters
Udummy parameter to enable SFINAE, do not provide explicitly
Parameters
rhsthe right-hand side value to compare to
Returns
true iff
data[i] == rhs.data[i]
Note
Version for floating point types that avoids direct equality comparison.

Definition at line 76 of file Tensor.hpp.

◆ operator==() [2/2]

template<typename T, int SIZE_TPARAM>
template<typename U = T>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE std::enable_if_t< !std::is_floating_point< U >::value, bool > geosx::Tensor< T, SIZE_TPARAM >::operator== ( Tensor< U, SIZE > const &  rhs) const
inline

Equality comparison operator.

Template Parameters
Udummy parameter to enable SFINAE, do not provide explicitly
Parameters
rhsthe right-hand side value to compare to
Returns
true iff
data[i] == rhs.data[i]
Note
Version for all types except floating point.

Definition at line 99 of file Tensor.hpp.

◆ operator[]() [1/2]

template<typename T, int SIZE_TPARAM>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE T const& geosx::Tensor< T, SIZE_TPARAM >::operator[] ( std::ptrdiff_t const  i) const
inline

Const element access.

Parameters
ielement index
Returns
const reference to the i-th element

Definition at line 48 of file Tensor.hpp.

◆ operator[]() [2/2]

template<typename T, int SIZE_TPARAM>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE T& geosx::Tensor< T, SIZE_TPARAM >::operator[] ( std::ptrdiff_t const  i)
inline

Non-const element access.

Parameters
ielement index
Returns
reference to the i-th element

Definition at line 60 of file Tensor.hpp.

◆ size()

template<typename T, int SIZE_TPARAM>
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE constexpr int geosx::Tensor< T, SIZE_TPARAM >::size ( int  junk) const
inline

Returns the size of the tensor.

Parameters
junkUnused
Returns
The value of the template parameter SIZE.

Definition at line 118 of file Tensor.hpp.

Friends And Related Function Documentation

◆ operator<<

template<typename T, int SIZE_TPARAM>
std::ostream& operator<< ( std::ostream &  os,
Tensor< T, SIZE > const &  t 
)
friend

Stream insertion operator for Tensor.

Parameters
osthe output stream
tthe tensor value
Returns
reference to os

Definition at line 135 of file Tensor.hpp.


The documentation for this class was generated from the following file: