GEOS
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
geos::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

T const & operator[] (std::ptrdiff_t const i) const
 Const element access. More...
 
T & operator[] (std::ptrdiff_t const i)
 Non-const element access. More...
 
template<typename U = T>
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>
std::enable_if_t< !std::is_floating_point< U >::value, bool > operator== (Tensor< U, SIZE > const &rhs) const
 Equality comparison operator. More...
 
constexpr int size (int junk) const
 Returns the size of the tensor. More...
 
Tensor< T, SIZE_TPARAM > & operator= (const double &rhs)
 Declare assignment operators. More...
 
Tensor< T, SIZE_TPARAM > & operator+= (const double &rhs)
 Adds a single value to all tensor components. More...
 
Tensor< T, SIZE_TPARAM > & operator+= (const Tensor< T, SIZE_TPARAM > &rhs)
 Component-wise addition of two tensors. More...
 

Public Attributes

data [SIZE] = {}
 Underlying array.
 

Static Public Attributes

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

Friends

double operator* (const Tensor< T, SIZE_TPARAM > &lhs, const Tensor< T, SIZE_TPARAM > &rhs)
 Define dot product. TODO: Check compatibility of lhs and rhs.
 
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 geos::Tensor< T, SIZE_TPARAM >

Lightweight wrapper around a c-array.

Template Parameters
Tdata type
SIZE_TPARAMnumber of values

Definition at line 30 of file Tensor.hpp.

Member Function Documentation

◆ operator+=() [1/2]

template<typename T , int SIZE_TPARAM>
Tensor< T, SIZE_TPARAM > & geos::Tensor< T, SIZE_TPARAM >::operator+= ( const double &  rhs)
inline

Adds a single value to all tensor components.

Parameters
rhsthe input value
Returns
The updated tensor.

Definition at line 193 of file Tensor.hpp.

◆ operator+=() [2/2]

template<typename T , int SIZE_TPARAM>
Tensor< T, SIZE_TPARAM > & geos::Tensor< T, SIZE_TPARAM >::operator+= ( const Tensor< T, SIZE_TPARAM > &  rhs)
inline

Component-wise addition of two tensors.

Parameters
rhsthe tensor being added to 'this' one
Returns
The updated tensor.

Definition at line 210 of file Tensor.hpp.

◆ operator=()

template<typename T , int SIZE_TPARAM>
Tensor< T, SIZE_TPARAM > & geos::Tensor< T, SIZE_TPARAM >::operator= ( const double &  rhs)
inline

Declare assignment operators.

Assigns all tensor components to a single input value.

Parameters
rhsthe input value
Returns
The updated tensor.

Definition at line 176 of file Tensor.hpp.

◆ operator==() [1/2]

template<typename T , int SIZE_TPARAM>
template<typename U = T>
std::enable_if_t< std::is_floating_point< U >::value, bool > geos::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]
T data[SIZE]
Underlying array.
Definition: Tensor.hpp:142
Note
Version for floating point types that avoids direct equality comparison.

Definition at line 77 of file Tensor.hpp.

◆ operator==() [2/2]

template<typename T , int SIZE_TPARAM>
template<typename U = T>
std::enable_if_t< !std::is_floating_point< U >::value, bool > geos::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 100 of file Tensor.hpp.

◆ operator[]() [1/2]

template<typename T , int SIZE_TPARAM>
T& geos::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 61 of file Tensor.hpp.

◆ operator[]() [2/2]

template<typename T , int SIZE_TPARAM>
T const& geos::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 49 of file Tensor.hpp.

◆ size()

template<typename T , int SIZE_TPARAM>
constexpr int geos::Tensor< T, SIZE_TPARAM >::size ( int  junk) const
inlineconstexpr

Returns the size of the tensor.

Parameters
junkUnused
Returns
The value of the template parameter SIZE.

Definition at line 119 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 152 of file Tensor.hpp.


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