Ensign
Low-rank framework for multi-core CPUs and GPUs
Loading...
Searching...
No Matches
Ensign::multi_array< T, d > Struct Template Reference

Dense d-dimensional array stored contiguously in column-major order (i.e. More...

#include <storage.hpp>

Public Member Functions

 multi_array (stloc _sl=stloc::host)
 
 multi_array (array< Index, d > _e, stloc _sl=stloc::host)
 
 multi_array (array< Index, d > _emax, array< Index, d > _e, stloc _sl=stloc::host)
 
 multi_array (const multi_array &ma)
 
multi_array & operator= (const multi_array &ma)
 
void resize (array< Index, d > _e)
 
void reserve (array< Index, d > _emax, array< Index, d > _e)
 
void swap (multi_array &ma)
 
void update_shape (array< Index, d > _e)
 
 ~multi_array ()
 
void set_zero ()
 
Index linear_idx (array< Index, d > idx) const
 
void to_cplx (multi_array< complex< T >, d > &out) const
 
void save_vector (std::string fn)
 
T & operator() (array< Index, d > idx)
 
const T & operator() (array< Index, d > idx) const
 
template<typename... Ints>
T & operator() (Ints &&... idx)
 
template<typename... Ints>
const T & operator() (Ints &&... idx) const
 
T * extract (array< Index, d-1 > idx_r)
 
const T * extract (array< Index, d-1 > idx_r) const
 
array< Index, d > shape () const
 
array< Index, d > shape_alloc () const
 
T * data ()
 
const T * data () const
 
Index num_elements () const
 
T * begin () const noexcept
 
T * end () const noexcept
 
multi_array & operator+= (const multi_array &lhs)
 
multi_array & operator+= (const T scalar)
 
multi_array & operator-= (const multi_array &lhs)
 
multi_array & operator*= (T scalar)
 
multi_array & operator/= (const T scalar)
 
multi_array operator+ (const multi_array &lhs)
 
multi_array operator- (const multi_array &lhs)
 
multi_array operator* (const T scalar)
 
bool operator== (const multi_array &lhs) const
 
void sadd (const T scalar, const multi_array &ma)
 

Public Attributes

array< Index, d > e
 
array< Index, d > emax
 
T * v
 
stloc sl
 

Friends

std::ostream & operator<< (std::ostream &os, const multi_array &A)
 

Detailed Description

template<class T, size_t d>
struct Ensign::multi_array< T, d >

Dense d-dimensional array stored contiguously in column-major order (i.e.

the leftmost index is contiguous in memory).

The memory resides either on the host (CPU) or the device (GPU), depending on stloc. Memory for a larger shape (emax) can be reserved and the current shape (e) changed without reallocation.

Definition at line 24 of file storage.hpp.

Constructor & Destructor Documentation

◆ multi_array() [1/4]

template<class T , size_t d>
Ensign::multi_array< T, d >::multi_array ( stloc  _sl = stloc::host)
inline

Definition at line 30 of file storage.hpp.

◆ multi_array() [2/4]

template<class T , size_t d>
Ensign::multi_array< T, d >::multi_array ( array< Index, d >  _e,
stloc  _sl = stloc::host 
)
inline

Definition at line 35 of file storage.hpp.

◆ multi_array() [3/4]

template<class T , size_t d>
Ensign::multi_array< T, d >::multi_array ( array< Index, d >  _emax,
array< Index, d >  _e,
stloc  _sl = stloc::host 
)
inline

Definition at line 39 of file storage.hpp.

◆ multi_array() [4/4]

template<class T , size_t d>
Ensign::multi_array< T, d >::multi_array ( const multi_array< T, d > &  ma)
inline

Definition at line 44 of file storage.hpp.

◆ ~multi_array()

template<class T , size_t d>
Ensign::multi_array< T, d >::~multi_array ( )
inline

Definition at line 158 of file storage.hpp.

Member Function Documentation

◆ begin()

template<class T , size_t d>
T * Ensign::multi_array< T, d >::begin ( ) const
inlinenoexcept

Definition at line 276 of file storage.hpp.

◆ data() [1/2]

template<class T , size_t d>
T * Ensign::multi_array< T, d >::data ( )
inline

Definition at line 252 of file storage.hpp.

◆ data() [2/2]

template<class T , size_t d>
const T * Ensign::multi_array< T, d >::data ( ) const
inline

Definition at line 260 of file storage.hpp.

◆ end()

template<class T , size_t d>
T * Ensign::multi_array< T, d >::end ( ) const
inlinenoexcept

Definition at line 284 of file storage.hpp.

◆ extract() [1/2]

template<class T , size_t d>
T * Ensign::multi_array< T, d >::extract ( array< Index, d-1 >  idx_r)
inline

Definition at line 229 of file storage.hpp.

◆ extract() [2/2]

template<class T , size_t d>
const T * Ensign::multi_array< T, d >::extract ( array< Index, d-1 >  idx_r) const
inline

Definition at line 236 of file storage.hpp.

◆ linear_idx()

template<class T , size_t d>
Index Ensign::multi_array< T, d >::linear_idx ( array< Index, d >  idx) const
inline

Definition at line 186 of file storage.hpp.

◆ num_elements()

template<class T , size_t d>
Index Ensign::multi_array< T, d >::num_elements ( ) const
inline

Definition at line 268 of file storage.hpp.

◆ operator()() [1/4]

template<class T , size_t d>
T & Ensign::multi_array< T, d >::operator() ( array< Index, d >  idx)
inline

Definition at line 206 of file storage.hpp.

◆ operator()() [2/4]

template<class T , size_t d>
const T & Ensign::multi_array< T, d >::operator() ( array< Index, d >  idx) const
inline

Definition at line 210 of file storage.hpp.

◆ operator()() [3/4]

template<class T , size_t d>
template<typename... Ints>
T & Ensign::multi_array< T, d >::operator() ( Ints &&...  idx)
inline

Definition at line 217 of file storage.hpp.

◆ operator()() [4/4]

template<class T , size_t d>
template<typename... Ints>
const T & Ensign::multi_array< T, d >::operator() ( Ints &&...  idx) const
inline

Definition at line 223 of file storage.hpp.

◆ operator*()

template<class T , size_t d>
multi_array Ensign::multi_array< T, d >::operator* ( const T  scalar)
inline

Definition at line 411 of file storage.hpp.

◆ operator*=()

template<class T , size_t d>
multi_array & Ensign::multi_array< T, d >::operator*= ( T  scalar)
inline

Definition at line 352 of file storage.hpp.

◆ operator+()

template<class T , size_t d>
multi_array Ensign::multi_array< T, d >::operator+ ( const multi_array< T, d > &  lhs)
inline

Definition at line 381 of file storage.hpp.

◆ operator+=() [1/2]

template<class T , size_t d>
multi_array & Ensign::multi_array< T, d >::operator+= ( const multi_array< T, d > &  lhs)
inline

Definition at line 292 of file storage.hpp.

◆ operator+=() [2/2]

template<class T , size_t d>
multi_array & Ensign::multi_array< T, d >::operator+= ( const T  scalar)
inline

Definition at line 317 of file storage.hpp.

◆ operator-()

template<class T , size_t d>
multi_array Ensign::multi_array< T, d >::operator- ( const multi_array< T, d > &  lhs)
inline

Definition at line 396 of file storage.hpp.

◆ operator-=()

template<class T , size_t d>
multi_array & Ensign::multi_array< T, d >::operator-= ( const multi_array< T, d > &  lhs)
inline

Definition at line 332 of file storage.hpp.

◆ operator/=()

template<class T , size_t d>
multi_array & Ensign::multi_array< T, d >::operator/= ( const T  scalar)
inline

Definition at line 367 of file storage.hpp.

◆ operator=()

template<class T , size_t d>
multi_array & Ensign::multi_array< T, d >::operator= ( const multi_array< T, d > &  ma)
inline

Definition at line 62 of file storage.hpp.

◆ operator==()

template<class T , size_t d>
bool Ensign::multi_array< T, d >::operator== ( const multi_array< T, d > &  lhs) const
inline

Definition at line 447 of file storage.hpp.

◆ reserve()

template<class T , size_t d>
void Ensign::multi_array< T, d >::reserve ( array< Index, d >  _emax,
array< Index, d >  _e 
)
inline

Definition at line 118 of file storage.hpp.

◆ resize()

template<class T , size_t d>
void Ensign::multi_array< T, d >::resize ( array< Index, d >  _e)
inline

Definition at line 94 of file storage.hpp.

◆ sadd()

template<class T , size_t d>
void Ensign::multi_array< T, d >::sadd ( const T  scalar,
const multi_array< T, d > &  ma 
)
inline

Definition at line 464 of file storage.hpp.

◆ save_vector()

template<class T , size_t d>
void Ensign::multi_array< T, d >::save_vector ( std::string  fn)
inline

Definition at line 201 of file storage.hpp.

◆ set_zero()

template<class T , size_t d>
void Ensign::multi_array< T, d >::set_zero ( )
inline

Definition at line 174 of file storage.hpp.

◆ shape()

template<class T , size_t d>
array< Index, d > Ensign::multi_array< T, d >::shape ( ) const
inline

Definition at line 244 of file storage.hpp.

◆ shape_alloc()

template<class T , size_t d>
array< Index, d > Ensign::multi_array< T, d >::shape_alloc ( ) const
inline

Definition at line 248 of file storage.hpp.

◆ swap()

template<class T , size_t d>
void Ensign::multi_array< T, d >::swap ( multi_array< T, d > &  ma)
inline

Definition at line 143 of file storage.hpp.

◆ to_cplx()

template<class T , size_t d>
void Ensign::multi_array< T, d >::to_cplx ( multi_array< complex< T >, d > &  out) const
inline

Definition at line 197 of file storage.hpp.

◆ update_shape()

template<class T , size_t d>
void Ensign::multi_array< T, d >::update_shape ( array< Index, d >  _e)
inline

Definition at line 154 of file storage.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<class T , size_t d>
std::ostream & operator<< ( std::ostream &  os,
const multi_array< T, d > &  A 
)
friend

Definition at line 426 of file storage.hpp.

Member Data Documentation

◆ e

template<class T , size_t d>
array<Index,d> Ensign::multi_array< T, d >::e

Definition at line 25 of file storage.hpp.

◆ emax

template<class T , size_t d>
array<Index,d> Ensign::multi_array< T, d >::emax

Definition at line 26 of file storage.hpp.

◆ sl

template<class T , size_t d>
stloc Ensign::multi_array< T, d >::sl

Definition at line 28 of file storage.hpp.

◆ v

template<class T , size_t d>
T* Ensign::multi_array< T, d >::v

Definition at line 27 of file storage.hpp.


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