cppqed-multidiagonal 0.4.0
Multidiagonal sparse operator algebra for C++QED
Loading...
Searching...
No Matches
cppqedutils::multiarray Namespace Reference

Classes

struct  Placeholder
 Sentinel type for rank-2 slice notation: mav(i, _) returns the i-th row as a rank-1 view. More...
 

Typedefs

template<typename T >
using StorageType = std::vector< T >
 Underlying storage type: std::vector<T>. May eventually be replaced by kokkos::View or std::valarray.
 

Functions

template<size_t RANK>
auto calculateStrides (Extents< RANK > extents)
 Computes first-index-fastest strides from extents (std::layout_left; column-major for rank 2): strides[0]=1, strides[i]=strides[i-1]*extents[i-1].
 
template<size_t RANK>
auto calculateExtent (Extents< RANK > extents)
 Returns the total number of elements: the product of all extents.
 
template<typename T >
auto copyInit (const std::ranges::sized_range auto &input)
 Initializer that copies from a sized range, checking that its size matches the requested extent.
 

Variables

constexpr struct cppqedutils::multiarray::Placeholder _
 
template<typename T >
constexpr auto noInit = [] (size_t e) -> std::vector<T> {return std::vector<T>(e);}
 Initializer for storage of size e whose contents the caller overwrites before reading them.
 
template<typename T >
constexpr auto zeroInit = [] (size_t e) -> std::vector<T> {return std::vector<T>(e,T(0.));}
 Initializer that allocates storage of size e and zero-initializes all elements via T(0.).
 

Typedef Documentation

◆ StorageType

Underlying storage type: std::vector<T>. May eventually be replaced by kokkos::View or std::valarray.

Function Documentation

◆ calculateExtent()

template<size_t RANK>
auto cppqedutils::multiarray::calculateExtent ( Extents< RANK >  extents)

Returns the total number of elements: the product of all extents.

◆ calculateStrides()

template<size_t RANK>
auto cppqedutils::multiarray::calculateStrides ( Extents< RANK >  extents)

Computes first-index-fastest strides from extents (std::layout_left; column-major for rank 2): strides[0]=1, strides[i]=strides[i-1]*extents[i-1].

This is the memory layout of every owning MultiArray. Note that incrementMultiIndex iterates in the opposite order (last index fastest).

◆ copyInit()

template<typename T >
auto cppqedutils::multiarray::copyInit ( const std::ranges::sized_range auto &  input)

Initializer that copies from a sized range, checking that its size matches the requested extent.

Variable Documentation

◆ _

◆ noInit

template<typename T >
constexpr auto cppqedutils::multiarray::noInit = [] (size_t e) -> std::vector<T> {return std::vector<T>(e);}
inlineconstexpr

Initializer for storage of size e whose contents the caller overwrites before reading them.

Note
std::vector<T>(e) value-initializes, so the storage is currently zero-filled after all. Don't rely on that: truly uninitialized storage would need a default-initializing allocator.

◆ zeroInit

template<typename T >
constexpr auto cppqedutils::multiarray::zeroInit = [] (size_t e) -> std::vector<T> {return std::vector<T>(e,T(0.));}
inlineconstexpr

Initializer that allocates storage of size e and zero-initializes all elements via T(0.).

Todo:
Use T{} instead of T(0.) for generality beyond numeric types.