HOPS
HOPS class reference
Public Types | Public Member Functions | Protected Attributes | List of all members
hops::MHO_NDArrayView< XValueType, RANK > Class Template Reference

MHO_NDArrayView is a class to represent a view (slice) of a n-dimensional array Thu 13 Aug 2020 02:53:11 PM EDT. More...

#include <MHO_NDArrayView.hh>

Public Types

using const_iterator = MHO_BidirectionalIndexedIterator< XValueType, RANK >
 
using index_type = std::array< std::size_t, RANK >
 
using iterator = MHO_BidirectionalIndexedIterator< XValueType, RANK >
 
typedef std::integral_constant< std::size_t, RANK > rank
 
using value_type = XValueType
 

Public Member Functions

 MHO_NDArrayView (const MHO_NDArrayView &obj)
 
 MHO_NDArrayView (XValueType *ptr, const std::size_t *dim, const std::size_t *strides)
 
virtual ~MHO_NDArrayView ()
 
template<typename... XIndexTypeS>
std::enable_if<(sizeof...(XIndexTypeS)==RANK), XValueType & >::type at (XIndexTypeS... idx)
 at(): same as operator(...) but with bounds checking with bounds checking More...
 
template<typename... XIndexTypeS>
std::enable_if<(sizeof...(XIndexTypeS)==RANK), const XValueType & >::type at (XIndexTypeS... idx) const
 at(): same as const operator(...) but with bounds checking with bounds checking More...
 
iterator begin ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
bool CheckIndexValidity (const index_type &idx) const
 
const_iterator citerator_at (std::size_t offset) const
 
MHO_NDArrayViewClone ()
 clone functionality - Creates a deep copy of this MHO_NDArrayView object. More...
 
void Copy (const MHO_NDArrayView &rhs)
 copy functionality, calling array view must have same shape as rhs More...
 
iterator end ()
 
std::size_t GetDimension (std::size_t idx) const
 Getter for a single dimension dimension. More...
 
index_type GetDimensionArray () const
 get the dimensions/shape of the array as std::array More...
 
const std::size_t * GetDimensions () const
 get the dimensions/shape of the array More...
 
void GetDimensions (std::size_t *dim) const
 get the dimensions/shape of the array More...
 
index_type GetIndicesForOffset (std::size_t offset)
 invert (memory) offset into array to indexes of the associated element More...
 
std::size_t GetOffsetForIndices (const std::size_t *index)
 compute (memory) offset into array from a set of indexes More...
 
std::size_t GetRank () const
 Getter for rank of the array view. More...
 
std::size_t GetSize () const
 get the total size of the array view More...
 
std::size_t GetStride (std::size_t idx) const
 Getter for stride at index. More...
 
index_type GetStrideArray () const
 Getter for stride array. More...
 
const std::size_t * GetStrides () const
 get element strides More...
 
void GetStrides (std::size_t *strd) const
 Getter for strides array (fills passed array) More...
 
iterator iterator_at (std::size_t offset)
 
template<typename... XIndexTypeS>
std::enable_if<(sizeof...(XIndexTypeS)==RANK), XValueType & >::type operator() (XIndexTypeS... idx)
 access operator, accepts multiple indices (,,...,) but does no bounds checking More...
 
template<typename... XIndexTypeS>
std::enable_if<(sizeof...(XIndexTypeS)==RANK), const XValueType & >::type operator() (XIndexTypeS... idx) const
 const reference access operator, accepts multiple indices (,,...,) but does no bounds checking More...
 
MHO_NDArrayViewoperator*= (const MHO_NDArrayView &anArray)
 operator*= in place point-wise multiplication by another array More...
 
template<typename T >
std::enable_if< std::is_same< XValueType, T >::value or std::is_integral< T >::value or std::is_floating_point< T >::value, MHO_NDArrayView & >::type operator*= (T aScalar)
 operator*= in place multiplication by a scalar factor More...
 
MHO_NDArrayViewoperator+= (const MHO_NDArrayView &anArray)
 operator+= in place point-wise addition by another array More...
 
template<typename T >
std::enable_if< std::is_same< XValueType, T >::value or std::is_integral< T >::value or std::is_floating_point< T >::value, MHO_NDArrayView & >::type operator+= (T aScalar)
 operator+= in place addition by a scalar amount More...
 
MHO_NDArrayViewoperator-= (const MHO_NDArrayView &anArray)
 operator-= in place point-wise subtraction by another array More...
 
template<typename T >
std::enable_if< std::is_same< XValueType, T >::value or std::is_integral< T >::value or std::is_floating_point< T >::value, MHO_NDArrayView & >::type operator-= (T aScalar)
 operator-= in place subtraction by a scalar amount More...
 
MHO_NDArrayViewoperator= (const MHO_NDArrayView &rhs)
 
void SetArray (const XValueType &obj)
 set all elements in the array to a certain value More...
 
XValueType & ValueAt (const index_type &idx)
 
const XValueType & ValueAt (const index_type &idx) const
 
void ZeroArray ()
 set all elements in the array to zero More...
 

Protected Attributes

XValueType * fDataPtr
 
index_type fDims
 
uint64_t fSize
 
index_type fStrides
 
index_type fTmp
 

Detailed Description

template<typename XValueType, std::size_t RANK>
class hops::MHO_NDArrayView< XValueType, RANK >

MHO_NDArrayView is a class to represent a view (slice) of a n-dimensional array Thu 13 Aug 2020 02:53:11 PM EDT.

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Mon Mar 28 10:47:46 2022 -0400

Member Typedef Documentation

◆ const_iterator

template<typename XValueType , std::size_t RANK>
using hops::MHO_NDArrayView< XValueType, RANK >::const_iterator = MHO_BidirectionalIndexedIterator< XValueType, RANK >

◆ index_type

template<typename XValueType , std::size_t RANK>
using hops::MHO_NDArrayView< XValueType, RANK >::index_type = std::array< std::size_t, RANK >

◆ iterator

template<typename XValueType , std::size_t RANK>
using hops::MHO_NDArrayView< XValueType, RANK >::iterator = MHO_BidirectionalIndexedIterator< XValueType, RANK >

◆ rank

template<typename XValueType , std::size_t RANK>
typedef std::integral_constant< std::size_t, RANK > hops::MHO_NDArrayView< XValueType, RANK >::rank

◆ value_type

template<typename XValueType , std::size_t RANK>
using hops::MHO_NDArrayView< XValueType, RANK >::value_type = XValueType

Constructor & Destructor Documentation

◆ MHO_NDArrayView() [1/2]

template<typename XValueType , std::size_t RANK>
hops::MHO_NDArrayView< XValueType, RANK >::MHO_NDArrayView ( XValueType *  ptr,
const std::size_t *  dim,
const std::size_t *  strides 
)
inline

◆ MHO_NDArrayView() [2/2]

template<typename XValueType , std::size_t RANK>
hops::MHO_NDArrayView< XValueType, RANK >::MHO_NDArrayView ( const MHO_NDArrayView< XValueType, RANK > &  obj)
inline

◆ ~MHO_NDArrayView()

template<typename XValueType , std::size_t RANK>
virtual hops::MHO_NDArrayView< XValueType, RANK >::~MHO_NDArrayView ( )
inlinevirtual

Member Function Documentation

◆ at() [1/2]

template<typename XValueType , std::size_t RANK>
template<typename... XIndexTypeS>
std::enable_if< (sizeof...(XIndexTypeS) == RANK), XValueType& >::type hops::MHO_NDArrayView< XValueType, RANK >::at ( XIndexTypeS...  idx)
inline

at(): same as operator(...) but with bounds checking with bounds checking

  • uses std::enable_if to do a compile-time check that the number of arguments is the same as the rank of the array
    Parameters
    ...varargs The variable arguments (integers) representing the data element indexes
    Returns
    the element at the specified indexes,throws exception if it doesn't exist

◆ at() [2/2]

template<typename XValueType , std::size_t RANK>
template<typename... XIndexTypeS>
std::enable_if< (sizeof...(XIndexTypeS) == RANK), const XValueType& >::type hops::MHO_NDArrayView< XValueType, RANK >::at ( XIndexTypeS...  idx) const
inline

at(): same as const operator(...) but with bounds checking with bounds checking

  • uses std::enable_if to do a compile-time check that the number of arguments is the same as the rank of the array
    Parameters
    ...varargs The variable arguments (integers) representing the data element indexes
    Returns
    a const reference to element at the specified indexes, throws exception if it doesn't exist

◆ begin()

template<typename XValueType , std::size_t RANK>
iterator hops::MHO_NDArrayView< XValueType, RANK >::begin ( )
inline

◆ cbegin()

template<typename XValueType , std::size_t RANK>
const_iterator hops::MHO_NDArrayView< XValueType, RANK >::cbegin ( ) const
inline

◆ cend()

template<typename XValueType , std::size_t RANK>
const_iterator hops::MHO_NDArrayView< XValueType, RANK >::cend ( ) const
inline

◆ CheckIndexValidity()

template<typename XValueType , std::size_t RANK>
bool hops::MHO_NDArrayView< XValueType, RANK >::CheckIndexValidity ( const index_type idx) const
inline

◆ citerator_at()

template<typename XValueType , std::size_t RANK>
const_iterator hops::MHO_NDArrayView< XValueType, RANK >::citerator_at ( std::size_t  offset) const
inline

◆ Clone()

template<typename XValueType , std::size_t RANK>
MHO_NDArrayView* hops::MHO_NDArrayView< XValueType, RANK >::Clone ( )
inline

clone functionality - Creates a deep copy of this MHO_NDArrayView object.

Returns
A new MHO_NDArrayView instance containing the same data.

◆ Copy()

template<typename XValueType , std::size_t RANK>
void hops::MHO_NDArrayView< XValueType, RANK >::Copy ( const MHO_NDArrayView< XValueType, RANK > &  rhs)
inline

copy functionality, calling array view must have same shape as rhs

Parameters
rhs(const MHO_NDArrayView&)

◆ end()

template<typename XValueType , std::size_t RANK>
iterator hops::MHO_NDArrayView< XValueType, RANK >::end ( )
inline

◆ GetDimension()

template<typename XValueType , std::size_t RANK>
std::size_t hops::MHO_NDArrayView< XValueType, RANK >::GetDimension ( std::size_t  idx) const
inline

Getter for a single dimension dimension.

Parameters
idx(std::size_t)
Returns
value of the specified (idx) dimension

◆ GetDimensionArray()

template<typename XValueType , std::size_t RANK>
index_type hops::MHO_NDArrayView< XValueType, RANK >::GetDimensionArray ( ) const
inline

get the dimensions/shape of the array as std::array

Returns
index_type&: Reference to the dimension array

◆ GetDimensions() [1/2]

template<typename XValueType , std::size_t RANK>
const std::size_t* hops::MHO_NDArrayView< XValueType, RANK >::GetDimensions ( ) const
inline

get the dimensions/shape of the array

Returns
Pointer to an array of std::size_t representing the dimensions

◆ GetDimensions() [2/2]

template<typename XValueType , std::size_t RANK>
void hops::MHO_NDArrayView< XValueType, RANK >::GetDimensions ( std::size_t *  dim) const
inline

get the dimensions/shape of the array

Returns
Pointer to std::size_t array

◆ GetIndicesForOffset()

template<typename XValueType , std::size_t RANK>
index_type hops::MHO_NDArrayView< XValueType, RANK >::GetIndicesForOffset ( std::size_t  offset)
inline

invert (memory) offset into array to indexes of the associated element

◆ GetOffsetForIndices()

template<typename XValueType , std::size_t RANK>
std::size_t hops::MHO_NDArrayView< XValueType, RANK >::GetOffsetForIndices ( const std::size_t *  index)
inline

compute (memory) offset into array from a set of indexes

◆ GetRank()

template<typename XValueType , std::size_t RANK>
std::size_t hops::MHO_NDArrayView< XValueType, RANK >::GetRank ( ) const
inline

Getter for rank of the array view.

Returns
std::size_t representing the rank (total size) of the array

◆ GetSize()

template<typename XValueType , std::size_t RANK>
std::size_t hops::MHO_NDArrayView< XValueType, RANK >::GetSize ( ) const
inline

get the total size of the array view

Returns
Current size as std::size_t.

◆ GetStride()

template<typename XValueType , std::size_t RANK>
std::size_t hops::MHO_NDArrayView< XValueType, RANK >::GetStride ( std::size_t  idx) const
inline

Getter for stride at index.

Parameters
idx(std::size_t)
Returns
stride of the dimensions specified by idx.

◆ GetStrideArray()

template<typename XValueType , std::size_t RANK>
index_type hops::MHO_NDArrayView< XValueType, RANK >::GetStrideArray ( ) const
inline

Getter for stride array.

Returns
index_type: the stride array

◆ GetStrides() [1/2]

template<typename XValueType , std::size_t RANK>
const std::size_t* hops::MHO_NDArrayView< XValueType, RANK >::GetStrides ( ) const
inline

get element strides

Returns
get the array of strides for the array

◆ GetStrides() [2/2]

template<typename XValueType , std::size_t RANK>
void hops::MHO_NDArrayView< XValueType, RANK >::GetStrides ( std::size_t *  strd) const
inline

Getter for strides array (fills passed array)

Parameters
strd(std::size_t*) pointer to an array of size RANK

◆ iterator_at()

template<typename XValueType , std::size_t RANK>
iterator hops::MHO_NDArrayView< XValueType, RANK >::iterator_at ( std::size_t  offset)
inline

◆ operator()() [1/2]

template<typename XValueType , std::size_t RANK>
template<typename... XIndexTypeS>
std::enable_if< (sizeof...(XIndexTypeS) == RANK), XValueType& >::type hops::MHO_NDArrayView< XValueType, RANK >::operator() ( XIndexTypeS...  idx)
inline

access operator, accepts multiple indices (,,...,) but does no bounds checking

  • uses std::enable_if to do a compile-time check that the number of arguments is the same as the rank of the array
    Parameters
    ...varargs The variable arguments (integers) representing the data element indexes
    Returns
    the element at the specified indexes

◆ operator()() [2/2]

template<typename XValueType , std::size_t RANK>
template<typename... XIndexTypeS>
std::enable_if< (sizeof...(XIndexTypeS) == RANK), const XValueType& >::type hops::MHO_NDArrayView< XValueType, RANK >::operator() ( XIndexTypeS...  idx) const
inline

const reference access operator, accepts multiple indices (,,...,) but does no bounds checking

  • uses std::enable_if to do a compile-time check that the number of arguments is the same as the rank of the array
    Parameters
    ...varargs The variable arguments (integers) representing the data element indexes
    Returns
    a const reference to element at the specified indexes

◆ operator*=() [1/2]

template<typename XValueType , std::size_t RANK>
MHO_NDArrayView& hops::MHO_NDArrayView< XValueType, RANK >::operator*= ( const MHO_NDArrayView< XValueType, RANK > &  anArray)
inline

operator*= in place point-wise multiplication by another array

◆ operator*=() [2/2]

template<typename XValueType , std::size_t RANK>
template<typename T >
std::enable_if< std::is_same< XValueType, T >::value or std::is_integral< T >::value or std::is_floating_point< T >::value, MHO_NDArrayView& >::type hops::MHO_NDArrayView< XValueType, RANK >::operator*= ( aScalar)
inline

operator*= in place multiplication by a scalar factor

◆ operator+=() [1/2]

template<typename XValueType , std::size_t RANK>
MHO_NDArrayView& hops::MHO_NDArrayView< XValueType, RANK >::operator+= ( const MHO_NDArrayView< XValueType, RANK > &  anArray)
inline

operator+= in place point-wise addition by another array

◆ operator+=() [2/2]

template<typename XValueType , std::size_t RANK>
template<typename T >
std::enable_if< std::is_same< XValueType, T >::value or std::is_integral< T >::value or std::is_floating_point< T >::value, MHO_NDArrayView& >::type hops::MHO_NDArrayView< XValueType, RANK >::operator+= ( aScalar)
inline

operator+= in place addition by a scalar amount

◆ operator-=() [1/2]

template<typename XValueType , std::size_t RANK>
MHO_NDArrayView& hops::MHO_NDArrayView< XValueType, RANK >::operator-= ( const MHO_NDArrayView< XValueType, RANK > &  anArray)
inline

operator-= in place point-wise subtraction by another array

◆ operator-=() [2/2]

template<typename XValueType , std::size_t RANK>
template<typename T >
std::enable_if< std::is_same< XValueType, T >::value or std::is_integral< T >::value or std::is_floating_point< T >::value, MHO_NDArrayView& >::type hops::MHO_NDArrayView< XValueType, RANK >::operator-= ( aScalar)
inline

operator-= in place subtraction by a scalar amount

◆ operator=()

template<typename XValueType , std::size_t RANK>
MHO_NDArrayView& hops::MHO_NDArrayView< XValueType, RANK >::operator= ( const MHO_NDArrayView< XValueType, RANK > &  rhs)
inline

◆ SetArray()

template<typename XValueType , std::size_t RANK>
void hops::MHO_NDArrayView< XValueType, RANK >::SetArray ( const XValueType &  obj)
inline

set all elements in the array to a certain value

◆ ValueAt() [1/2]

template<typename XValueType , std::size_t RANK>
XValueType& hops::MHO_NDArrayView< XValueType, RANK >::ValueAt ( const index_type idx)
inline

◆ ValueAt() [2/2]

template<typename XValueType , std::size_t RANK>
const XValueType& hops::MHO_NDArrayView< XValueType, RANK >::ValueAt ( const index_type idx) const
inline

◆ ZeroArray()

template<typename XValueType , std::size_t RANK>
void hops::MHO_NDArrayView< XValueType, RANK >::ZeroArray ( )
inline

set all elements in the array to zero

Member Data Documentation

◆ fDataPtr

template<typename XValueType , std::size_t RANK>
XValueType* hops::MHO_NDArrayView< XValueType, RANK >::fDataPtr
protected

◆ fDims

template<typename XValueType , std::size_t RANK>
index_type hops::MHO_NDArrayView< XValueType, RANK >::fDims
protected

◆ fSize

template<typename XValueType , std::size_t RANK>
uint64_t hops::MHO_NDArrayView< XValueType, RANK >::fSize
protected

◆ fStrides

template<typename XValueType , std::size_t RANK>
index_type hops::MHO_NDArrayView< XValueType, RANK >::fStrides
protected

◆ fTmp

template<typename XValueType , std::size_t RANK>
index_type hops::MHO_NDArrayView< XValueType, RANK >::fTmp
mutableprotected

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