15 #ifndef GEOS_COMMON_TENSOR_HPP_
16 #define GEOS_COMMON_TENSOR_HPP_
28 template<
typename T,
int SIZE_TPARAM >
33 static_assert( SIZE_TPARAM > 0,
"Tensor size must be a positive value" );
39 static constexpr
int SIZE = SIZE_TPARAM;
72 template<
typename U = T >
75 std::enable_if_t< std::is_floating_point< U >::value,
bool >
78 for(
int i = 0; i <
SIZE; ++i )
95 template<
typename U = T >
98 std::enable_if_t< !std::is_floating_point< U >::value,
bool >
101 for(
int i = 0; i <
SIZE; ++i )
118 constexpr
int size(
int junk )
const
133 for(
int i = 0; i < SIZE_TPARAM; ++i )
135 result += lhs.
data[i] * rhs.
data[i];
153 os <<
'{' << t.
data[0];
154 for(
int i = 1; i <
SIZE; ++i )
156 os <<
',' << t.
data[i];
172 template<
typename T,
int SIZE_TPARAM >
177 for(
int i = 0; i < SIZE_TPARAM; ++i )
189 template<
typename T,
int SIZE_TPARAM >
194 for(
int i = 0; i < SIZE_TPARAM; ++i )
206 template<
typename T,
int SIZE_TPARAM >
211 for(
int i = 0; i < SIZE_TPARAM; ++i )
213 data[i] += rhs.
data[i];
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
Lightweight wrapper around a c-array.
Tensor< T, SIZE_TPARAM > & operator+=(const double &rhs)
Adds a single value to all tensor components.
T value_type
Alias for type template parameter.
T const & operator[](std::ptrdiff_t const i) const
Const element access.
std::enable_if_t< !std::is_floating_point< U >::value, bool > operator==(Tensor< U, SIZE > const &rhs) const
Equality comparison operator.
Tensor< T, SIZE_TPARAM > & operator+=(const Tensor< T, SIZE_TPARAM > &rhs)
Component-wise addition of two tensors.
T & operator[](std::ptrdiff_t const i)
Non-const element access.
static constexpr int SIZE
Alias for size template parameter.
T data[SIZE]
Underlying array.
std::enable_if_t< std::is_floating_point< U >::value, bool > operator==(Tensor< U, SIZE > const &rhs) const
Equality comparison operator.
friend std::ostream & operator<<(std::ostream &os, Tensor< T, SIZE > const &t)
Stream insertion operator for Tensor.
constexpr int size(int junk) const
Returns the size of the tensor.
friend double operator*(const Tensor< T, SIZE_TPARAM > &lhs, const Tensor< T, SIZE_TPARAM > &rhs)
Define dot product. TODO: Check compatibility of lhs and rhs.
Tensor< T, SIZE_TPARAM > & operator=(const double &rhs)
Declare assignment operators.