1#ifndef NGEN_MDARRAY_DEFINITION_HPP
2#define NGEN_MDARRAY_DEFINITION_HPP
7#include <boost/core/span.hpp>
17 using size_type =
typename container_type::size_type;
19 using reference =
typename container_type::reference;
21 using pointer =
typename container_type::pointer;
42 mdarray(
const boost::span<const size_type> dsizes)
46 constexpr mdarray(std::initializer_list<size_type> dsizes)
129 void insert(std::initializer_list<std::pair<
const boost::span<const size_type>,
value_type>> args)
131 for (
const auto& arg : args) {
132 this->
insert(arg.first, arg.second);
143 return this->
m_data.size();
169 boost::span<const size_t>
shape() const noexcept
185 index += n[k] * stride;
202 assert(n.size() == this->rank());
203 assert(idx < this->
size());
207 n[k] = idx / stride % this->
m_shape[k];
222 throw std::out_of_range(
223 "index " + std::to_string(n[i]) +
224 " must be less than dimension size " +
225 std::to_string(this->
m_shape[i])
Definition mdarray.hpp:13
iterator end() const noexcept
Definition mdarray.hpp:150
typename container_type::const_pointer const_pointer
Definition mdarray.hpp:22
reference at(const boost::span< const size_type > n)
Definition mdarray.hpp:61
typename container_type::size_type size_type
Definition mdarray.hpp:17
void insert(std::initializer_list< std::pair< const boost::span< const size_type >, value_type > > args)
Definition mdarray.hpp:129
typename container_type::reference reference
Definition mdarray.hpp:19
typename container_type::const_reference const_reference
Definition mdarray.hpp:20
size_type rank() const noexcept
Get the rank of this mdarray.
Definition mdarray.hpp:159
constexpr mdarray(std::initializer_list< size_type > dsizes)
Definition mdarray.hpp:46
void insert(const boost::span< const size_type > n, value_type value)
Insert a multi-dimensonal value at the given index.
Definition mdarray.hpp:122
std::vector< size_type > m_shape
Definition mdarray.hpp:230
const_reference at(const boost::span< const size_type > n) const
Definition mdarray.hpp:94
container_type m_data
Definition mdarray.hpp:231
friend iterator
Definition mdarray.hpp:25
reference operator[](const boost::span< const size_type > n) noexcept
Definition mdarray.hpp:79
size_type max_size(Tp shape)
Definition mdarray.hpp:29
typename container_type::pointer pointer
Definition mdarray.hpp:21
void bounds_check(const boost::span< const size_type > n) const
Definition mdarray.hpp:214
size_type index(const boost::span< const size_type > n) const
Index a multi-dimensional set of indices to a single address index.
Definition mdarray.hpp:180
iterator begin() const noexcept
Definition mdarray.hpp:146
typename container_type::difference_type difference_type
Definition mdarray.hpp:18
boost::span< const size_t > shape() const noexcept
Get the shape of this mdarray.
Definition mdarray.hpp:169
void deindex(size_type idx, boost::span< size_type > n) const
Retrieve the multi-dimensional index from a given address index.
Definition mdarray.hpp:200
size_type size() const noexcept
Get the size of allocated values in this mdarray (aka the allocated elements in the backing vector)
Definition mdarray.hpp:141
std::vector< value_type > container_type
Definition mdarray.hpp:16
const_reference operator[](const boost::span< const size_type > n) const noexcept
Definition mdarray.hpp:111
mdarray(const boost::span< const size_type > dsizes)
Definition mdarray.hpp:42
T value_type
Definition mdarray.hpp:15
Definition DomainLayer.hpp:9
Definition iterator.hpp:10