Proto  3.2
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Proto::Array< T, N > Class Template Reference

A templated constant size array object similar to std::array, but with the ability to be used inside of device kernels. More...

#include <Proto_Array.H>

Inheritance diagram for Proto::Array< T, N >:
Inheritance graph
[legend]

Public Member Functions

ACCEL_DECORATION Array ()
 Constructs an Array with uninitialized values. More...
 
ACCEL_DECORATION Array (T initValue)
 Constructs an Array with all values set to initValue. More...
 
ACCEL_DECORATION Array (std::initializer_list< T > list)
 Constructs an Array using initializer_list syntax. More...
 
ACCEL_DECORATION Array (const Array< T, N > &arr)
 
ACCEL_DECORATION Array< T, N > & operator= (const Array< T, N > &arr)
 
ACCEL_DECORATION Array (Array< T, N > &&arr)=default
 
ACCEL_DECORATION Array< T, N > & operator= (Array< T, N > &&arr)=default
 
ACCEL_DECORATION Array< T, N > & operator= (const std::array< T, N > &arr)
 
ACCEL_DECORATION operator std::array< T, N > () const
 Implicit Cast to std::array. More...
 
ACCEL_DECORATION Array (const Point &point)
 Constructs an int-valued Array from a Point. More...
 
ACCEL_DECORATION Array (const std::array< T, N > &arr)
 Constructs an Array from a std::array. More...
 
ACCEL_DECORATION ~Array ()=default
 
ACCEL_DECORATION void fill (T value)
 Sets all values of *this to value. More...
 
ACCEL_DECORATION T * data ()
 Returns a raw pointer to the data buffer of *this. More...
 
ACCEL_DECORATION const T * data () const
 Returns a const raw pointer to the data buffer of *this. More...
 
ACCEL_DECORATION T & operator[] (size_t i)
 Returns a reference to the element at index i. More...
 
ACCEL_DECORATION const T & operator[] (size_t i) const
 Returns a const reference to the element at index i. More...
 
ACCEL_DECORATION bool operator== (const Array< T, N > &rhs) const
 Equality operator. Defined by value. More...
 
ACCEL_DECORATION bool operator!= (const Array< T, N > &rhs) const
 Inequality operator. Defined by value. More...
 
template<size_t M>
ACCEL_DECORATION Array< T, N > operator+ (const Array< T, M > &rhs) const
 Vector addition operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are added to the first M elements of the output. More...
 
ACCEL_DECORATION Array< T, N > operator+ (T value) const
 Scalar addition operator. Returns a new Array containing the values of *this + value. More...
 
template<size_t M>
ACCEL_DECORATION void operator+= (const Array< T, M > &rhs)
 Vector in-place addition operator. The first M elements of rhs are added to this. More...
 
ACCEL_DECORATION void operator+= (T value)
 Scalar in-place addition operator. Adds value to each element of *this. More...
 
template<size_t M>
ACCEL_DECORATION Array< T, N > operator- (const Array< T, M > &rhs) const
 Vector subtraction operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are subtracted from the first M elements of the output. More...
 
ACCEL_DECORATION Array< T, N > operator- (T value) const
 Scalar subtraction operator. Subtracts value from each element of *this. More...
 
template<size_t M>
ACCEL_DECORATION void operator-= (const Array< T, M > &rhs)
 Vector in-place subtraction operator. The first M elements of rhs are subtracted from this. More...
 
ACCEL_DECORATION void operator-= (T value)
 Scalar in-place subtraction operator. Subtracts value from each element of *this. More...
 
template<size_t M>
ACCEL_DECORATION Array< T, N > operator* (const Array< T, M > &rhs) const
 Vector product operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are multiplied with the first M elements of the output. More...
 
ACCEL_DECORATION Array< T, N > operator* (T value) const
 Scalar multiplication operator. Multiplies each element of *this by value. More...
 
template<size_t M>
ACCEL_DECORATION void operator*= (const Array< T, M > &rhs)
 Vector in-place multiplication operator. The first M elements of rhs are multplied into this. More...
 
ACCEL_DECORATION void operator*= (T value)
 Scalar in-place multiplication operator. Multiplies each value of *this by value. More...
 
template<size_t M>
ACCEL_DECORATION Array< T, N > operator/ (const Array< T, M > &nonZeroRhs) const
 Vector quotient operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are divided by the first M elements of the output. Fails by assertion if any element of rhs contains zero. More...
 
ACCEL_DECORATION Array< T, N > operator/ (T nonZeroValue) const
 Scalar quotient operator. Divides each element of *this by value. Fails by assertion if value is zero. More...
 
template<size_t M>
ACCEL_DECORATION void operator/= (const Array< T, M > &nonZeroRhs)
 Vector in-place quotient operator. The first M elements this are divided by rhs elementwise Fails by assertion if any element of rhs is zero. More...
 
ACCEL_DECORATION void operator/= (T nonZeroValue)
 Scalar in-place quotient operator. Divides each value of *this by value. Fails by assertion of value is zero. More...
 
ACCEL_DECORATIONmax () const
 Returns the maximum value of this. More...
 
ACCEL_DECORATIONmin () const
 Returns the minimum value of this. More...
 
ACCEL_DECORATIONabsMax () const
 Returns the maximum value of the absolute value of this. More...
 
ACCEL_DECORATIONsum () const
 Returns the sum of the elements of this. More...
 
ACCEL_DECORATIONdot (const Array< T, N > &rhs) const
 Returns the dot product of this with rhs. The dot product is defined as the sum of the elementwise products of the elements of the two Arrays. More...
 
ACCEL_DECORATIONproduct () const
 Returns the product of the elements of this. More...
 
ACCEL_DECORATIONnorm () const
 Returns the L2 norm of the elements of this. The L2 norm is defined as the square root of the sum of the squared elements of this. More...
 
ACCEL_DECORATION ArrayIterator< T, N > begin ()
 
ACCEL_DECORATION ConstArrayIterator< T, N > begin () const
 
ACCEL_DECORATION ArrayIterator< T, N > end ()
 
ACCEL_DECORATION ConstArrayIterator< T, N > end () const
 
std::string str () const
 Returns a string representation of this. More...
 
void print (std::ostream &stream=std::cout) const
 Print a representation of this to a std::ostream [Default: std::cout]. More...
 

Static Public Member Functions

static ACCEL_DECORATION Array< T, N > Zeros ()
 Shortcut for creating an Array filled with zeros. More...
 
static ACCEL_DECORATION Array< T, N > Ones (T scale=1.0)
 Shortcut for creating an isotropic array. More...
 

Private Attributes

m_data [N]
 

Detailed Description

template<typename T, size_t N>
class Proto::Array< T, N >

A templated constant size array object similar to std::array, but with the ability to be used inside of device kernels.

Template Parameters
Ta plain-old-data type (int, double, etc)
Nstatic size of the array

Constructor & Destructor Documentation

◆ Array() [1/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( )
inline

◆ Array() [2/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( initValue)
inline

Constructs an Array with all values set to initValue.

Parameters
initValue- The initial value of all elements of the Array

◆ Array() [3/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( std::initializer_list< T >  list)
inline

Constructs an Array using initializer_list syntax.

Example:

Array<int, 5> a = {1,2,3,4,5};

◆ Array() [4/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( const Array< T, N > &  arr)
inline

◆ Array() [5/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( Array< T, N > &&  arr)
inlinedefault

◆ Array() [6/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( const Point point)
inline

Constructs an int-valued Array from a Point.

◆ Array() [7/7]

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::Array ( const std::array< T, N > &  arr)
inline

Constructs an Array from a std::array.

◆ ~Array()

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::~Array ( )
inlinedefault

Member Function Documentation

◆ Zeros()

template<typename T, size_t N>
static ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::Zeros ( )
inlinestatic

Shortcut for creating an Array filled with zeros.

Returns
An Array of zeros

◆ Ones()

template<typename T, size_t N>
static ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::Ones ( scale = 1.0)
inlinestatic

Shortcut for creating an isotropic array.

Parameters
scale- An optional scale. The output vector will be [scale, scale, scale, ...]. [Default: 1]
Returns
An isotropic Array multiplied by scale

◆ operator=() [1/3]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N>& Proto::Array< T, N >::operator= ( const Array< T, N > &  arr)
inline

◆ operator=() [2/3]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N>& Proto::Array< T, N >::operator= ( Array< T, N > &&  arr)
inlinedefault

◆ operator=() [3/3]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N>& Proto::Array< T, N >::operator= ( const std::array< T, N > &  arr)
inline

◆ operator std::array< T, N >()

template<typename T, size_t N>
ACCEL_DECORATION Proto::Array< T, N >::operator std::array< T, N > ( ) const
inline

Implicit Cast to std::array.

Returns

◆ fill()

template<typename T, size_t N>
ACCEL_DECORATION void Proto::Array< T, N >::fill ( value)
inline

◆ data() [1/2]

template<typename T, size_t N>
ACCEL_DECORATION T* Proto::Array< T, N >::data ( )
inline

Returns a raw pointer to the data buffer of *this.

Referenced by Proto::Array< vector< uint64_t >, DIM >::operator std::array< vector< uint64_t >, N >().

◆ data() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION const T* Proto::Array< T, N >::data ( ) const
inline

Returns a const raw pointer to the data buffer of *this.

◆ operator[]() [1/2]

template<typename T, size_t N>
ACCEL_DECORATION T& Proto::Array< T, N >::operator[] ( size_t  i)
inline

Returns a reference to the element at index i.

Referenced by Proto::Array< vector< uint64_t >, DIM >::operator std::array< vector< uint64_t >, N >().

◆ operator[]() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION const T& Proto::Array< T, N >::operator[] ( size_t  i) const
inline

Returns a const reference to the element at index i.

◆ operator==()

template<typename T, size_t N>
ACCEL_DECORATION bool Proto::Array< T, N >::operator== ( const Array< T, N > &  rhs) const
inline

◆ operator!=()

template<typename T, size_t N>
ACCEL_DECORATION bool Proto::Array< T, N >::operator!= ( const Array< T, N > &  rhs) const
inline

Inequality operator. Defined by value.

◆ operator+() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator+ ( const Array< T, M > &  rhs) const
inline

Vector addition operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are added to the first M elements of the output.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array
Returns
The elementwise sum of *this with rhs on the first M elements

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator+() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator+ ( value) const
inline

Scalar addition operator. Returns a new Array containing the values of *this + value.

◆ operator+=() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION void Proto::Array< T, N >::operator+= ( const Array< T, M > &  rhs)
inline

Vector in-place addition operator. The first M elements of rhs are added to this.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator+=() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION void Proto::Array< T, N >::operator+= ( value)
inline

Scalar in-place addition operator. Adds value to each element of *this.

◆ operator-() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator- ( const Array< T, M > &  rhs) const
inline

Vector subtraction operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are subtracted from the first M elements of the output.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array
Returns
The elementwise difference of *this with rhs on the first M elements

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator-() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator- ( value) const
inline

Scalar subtraction operator. Subtracts value from each element of *this.

◆ operator-=() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION void Proto::Array< T, N >::operator-= ( const Array< T, M > &  rhs)
inline

Vector in-place subtraction operator. The first M elements of rhs are subtracted from this.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator-=() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION void Proto::Array< T, N >::operator-= ( value)
inline

Scalar in-place subtraction operator. Subtracts value from each element of *this.

◆ operator*() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator* ( const Array< T, M > &  rhs) const
inline

Vector product operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are multiplied with the first M elements of the output.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array
Returns
The elementwise product of *this with rhs on the first M elements

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator*() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator* ( value) const
inline

Scalar multiplication operator. Multiplies each element of *this by value.

◆ operator*=() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION void Proto::Array< T, N >::operator*= ( const Array< T, M > &  rhs)
inline

Vector in-place multiplication operator. The first M elements of rhs are multplied into this.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator*=() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION void Proto::Array< T, N >::operator*= ( value)
inline

Scalar in-place multiplication operator. Multiplies each value of *this by value.

◆ operator/() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator/ ( const Array< T, M > &  nonZeroRhs) const
inline

Vector quotient operator. Returns a new Array of the same size as *this. if M < N, the elements of rhs are divided by the first M elements of the output. Fails by assertion if any element of rhs contains zero.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array
Returns
The elementwise quotient of *this with rhs on the first M elements

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator/() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION Array<T,N> Proto::Array< T, N >::operator/ ( nonZeroValue) const
inline

Scalar quotient operator. Divides each element of *this by value. Fails by assertion if value is zero.

◆ operator/=() [1/2]

template<typename T, size_t N>
template<size_t M>
ACCEL_DECORATION void Proto::Array< T, N >::operator/= ( const Array< T, M > &  nonZeroRhs)
inline

Vector in-place quotient operator. The first M elements this are divided by rhs elementwise Fails by assertion if any element of rhs is zero.

Template Parameters
M- The number of elements in rhs
Parameters
rhs- Another Array

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ operator/=() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION void Proto::Array< T, N >::operator/= ( nonZeroValue)
inline

Scalar in-place quotient operator. Divides each value of *this by value. Fails by assertion of value is zero.

◆ max()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::max ( ) const
inline

Returns the maximum value of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ min()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::min ( ) const
inline

Returns the minimum value of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ absMax()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::absMax ( ) const
inline

Returns the maximum value of the absolute value of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ sum()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::sum ( ) const
inline

Returns the sum of the elements of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ dot()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::dot ( const Array< T, N > &  rhs) const
inline

Returns the dot product of this with rhs. The dot product is defined as the sum of the elementwise products of the elements of the two Arrays.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ product()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::product ( ) const
inline

Returns the product of the elements of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ norm()

template<typename T, size_t N>
ACCEL_DECORATION T Proto::Array< T, N >::norm ( ) const
inline

Returns the L2 norm of the elements of this. The L2 norm is defined as the square root of the sum of the squared elements of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ begin() [1/2]

template<typename T, size_t N>
ACCEL_DECORATION ArrayIterator<T,N> Proto::Array< T, N >::begin ( )
inline

◆ begin() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION ConstArrayIterator<T,N> Proto::Array< T, N >::begin ( ) const
inline

◆ end() [1/2]

template<typename T, size_t N>
ACCEL_DECORATION ArrayIterator<T,N> Proto::Array< T, N >::end ( )
inline

◆ end() [2/2]

template<typename T, size_t N>
ACCEL_DECORATION ConstArrayIterator<T,N> Proto::Array< T, N >::end ( ) const
inline

◆ str()

template<typename T, size_t N>
std::string Proto::Array< T, N >::str ( ) const
inline

Returns a string representation of this.

Referenced by Proto::Array< bool, DIM >::operator!=().

◆ print()

template<typename T, size_t N>
void Proto::Array< T, N >::print ( std::ostream &  stream = std::cout) const
inline

Print a representation of this to a std::ostream [Default: std::cout].

Referenced by Proto::Array< bool, DIM >::operator!=().

Member Data Documentation

◆ m_data

template<typename T, size_t N>
T Proto::Array< T, N >::m_data[N]
private

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