custom_index_array.h Source File
|
CPP API
|
custom_index_array.h
Go to the documentation of this file.
33 // TODO std::apply or fold expression in C++17; current version required by CustomIndexArray::Slice
75 : std::is_base_of<typename std::iterator_traits<T>::iterator_category, std::random_access_iterator_tag> {
295 return this->m_dimensions == other.m_dimensions && (this->m_y.array() == other.m_y.array()).all();
319 void set_multiple(const std::vector<typename CustomIndexArray<Typ, Tags...>::Index>& indices, const Typ& value)
381 Iterator(iter_type begin_, size_t di_, size_t dr_, Seq<size_t> const& seq_, difference_type offset = 0)
467 a.dr == b.dr && a.seq.start == b.seq.start && a.seq.n == b.seq.n && a.seq.stride == b.seq.stride;
496 // first unravel the inner index into an index (i,j,k) for a 3-dim array with dims (dl, idx_sequence.n, dr)
768 return failure(StatusCode::OutOfRange, "Dimensions of Array don't match the number of elements.");
Definition: custom_index_array.h:373
Iterator & operator-=(const int &rhs)
Definition: custom_index_array.h:405
Iterator & operator=(const Iterator &rhs)
Definition: custom_index_array.h:395
Iterator operator++(int)
Definition: custom_index_array.h:437
friend bool operator!=(const Iterator &a, const Iterator &b)
Definition: custom_index_array.h:469
Iterator operator--(int)
Definition: custom_index_array.h:448
Iterator & operator=(size_t rhs)
Definition: custom_index_array.h:390
Iterator(iter_type begin_, size_t di_, size_t dr_, Seq< size_t > const &seq_, difference_type offset=0)
Definition: custom_index_array.h:381
value_type const & operator*() const
Definition: custom_index_array.h:423
reference operator*()
Definition: custom_index_array.h:419
Iterator operator-(const int &rhs) const
Definition: custom_index_array.h:459
Slice::difference_type outer_offset(difference_type const &inner) const
Definition: custom_index_array.h:491
friend bool operator<=(const Iterator &a, const Iterator &b)
Definition: custom_index_array.h:477
Iterator operator+(const int &rhs) const
Definition: custom_index_array.h:455
value_type const & operator[](const difference_type &rhs) const
Definition: custom_index_array.h:415
value_type & reference
Definition: custom_index_array.h:379
Iterator & operator--()
Definition: custom_index_array.h:443
Iterator & operator++()
Definition: custom_index_array.h:432
std::ptrdiff_t difference_type
Definition: custom_index_array.h:376
difference_type inner_offset
Definition: custom_index_array.h:510
friend bool operator>(const Iterator &a, const Iterator &b)
Definition: custom_index_array.h:481
friend bool operator<(const Iterator &a, const Iterator &b)
Definition: custom_index_array.h:473
std::random_access_iterator_tag iterator_category
Definition: custom_index_array.h:375
value_type * pointer
Definition: custom_index_array.h:378
friend bool operator==(const Iterator &a, const Iterator &b)
Definition: custom_index_array.h:464
Iterator & operator+=(const int &rhs)
Definition: custom_index_array.h:400
reference operator[](const difference_type &rhs)
Definition: custom_index_array.h:411
friend bool operator>=(const Iterator &a, const Iterator &b)
Definition: custom_index_array.h:485
pointer operator->()
Definition: custom_index_array.h:427
iter_type data_begin
Definition: custom_index_array.h:507
A Slice represents a slice of data along one dimension, given a start and end index into that dimensi...
Definition: custom_index_array.h:368
Seq< size_t > idx_sequence
Definition: custom_index_array.h:632
CustomIndexArray< Type, Tags... > as_array()
Definition: custom_index_array.h:569
friend bool operator!=(const Slice &a, const Slice &b)
Definition: custom_index_array.h:587
typename iter_type::difference_type difference_type
Definition: custom_index_array.h:369
Slice(Index const &dimensions, iter_type const &start_iter, Seq< size_t > idx_sequence_)
Constructs a slice into the CustomIndexarray.
Definition: custom_index_array.h:525
Iterator< Type const > const_iterator
Definition: custom_index_array.h:517
Slice< OtherTag, iterator > slice(Seq< size_t > idx_sequence_)
Creates a subslice from the current slice.
Definition: custom_index_array.h:600
Slice< OtherTag, const_iterator > slice(Seq< size_t > idx_sequence_) const
Creates a subslice from the current slice.
Definition: custom_index_array.h:613
friend bool operator==(const Slice &a, const Slice &b)
Definition: custom_index_array.h:580
Slice & operator=(const Type &scalar)
Assign same value to each element of the slice.
Definition: custom_index_array.h:622
A class template for an array with custom indices.
Definition: custom_index_array.h:136
iterator end()
Get an end iterator for the elements.
Definition: custom_index_array.h:674
Type const & operator[](Index const &index) const
returns the entry of the array given a flat index index
Definition: custom_index_array.h:274
Type & operator[](Index const &index)
returns the entry of the array given a MultiIndex
Definition: custom_index_array.h:264
Eigen::Array< Type, Eigen::Dynamic, 1 > InternalArrayType
Definition: custom_index_array.h:140
Slice< Tag, iterator > slice(Seq< size_t > idx_seq)
Creates a slice into the multidimensional array.
Definition: custom_index_array.h:698
Slice< Tag, const_iterator > slice(Seq< size_t > idx_seq) const
Creates a slice into the multidimensional array.
Definition: custom_index_array.h:703
requires(std::is_constructible_v< Type, Ts... >) CustomIndexArray(Index const &dims
CustomIndexArray constructor, that initializes the array to constant instances of CustsomIndexArray::...
Slice< Tag, const_iterator > slice(mio::Index< Tag > idx) const
Creates a slice into the multidimensional array.
Definition: custom_index_array.h:722
mio::Index< Tag > size() const
returns the size along the dimension provided as template parameter
Definition: custom_index_array.h:204
CustomIndexArray & operator=(const Type &scalar)
Assign the same value to each element of the array.
Definition: custom_index_array.h:283
typename InternalArrayType::const_iterator const_iterator
Definition: custom_index_array.h:650
iterator begin()
Get a start iterator for the elements.
Definition: custom_index_array.h:656
CustomIndexArray(Index const &dims, Iter b, Iter e)
Initializes array with values from a range.
Definition: custom_index_array.h:178
Ts m_y(InternalArrayType::Constant(m_numel, 1, Type{std::forward< Ts >(args)...}))
Definition: custom_index_array.h:165
CustomIndexArray()
Create an empty CustomIndexArray with size 0. Use the resize member function to add entries.
Definition: custom_index_array.h:143
Ts m_numel(product(dims))
typename InternalArrayType::iterator iterator
Definition: custom_index_array.h:649
void set_multiple(const std::vector< typename CustomIndexArray< Typ, Tags... >::Index > &indices, const Typ &value)
Set multiple entries to the same value.
Definition: custom_index_array.h:319
bool operator!=(const CustomIndexArray &other) const
Equality comparison.
Definition: custom_index_array.h:297
requires std::convertible_to< Type, OtherType > CustomIndexArray< OtherType, Tags... > convert() const
Convert internally stored data to OtherType and save into new CustomIndexArray.
Definition: custom_index_array.h:333
size_t get_flat_index(Index const &index) const
get_flat_index returns the flat index into the stored array, given the indices of each category
Definition: custom_index_array.h:309
constexpr size_t numel() const
numel returns the number of elements
Definition: custom_index_array.h:193
void resize(mio::Index< Tag > new_dim)
Resize a single dimension, invalidating entries.
Definition: custom_index_array.h:239
static IOResult< Derived > deserialize(IOContext &io, Tag< Derived >)
deserialize an object of a class derived from this class.
Definition: custom_index_array.h:758
requires std::is_enum_v< Tag > Slice< Tag, iterator > slice(Tag idx)
Creates a slice into the multidimensional array.
Definition: custom_index_array.h:728
static IOResult< CustomIndexArray > deserialize(IOContext &io)
deserialize an object of this class.
Definition: custom_index_array.h:781
Slice< Tag, iterator > slice(mio::Index< Tag > idx)
Creates a slice into the multidimensional array.
Definition: custom_index_array.h:717
const_iterator end() const
Get an end iterator for the elements.
Definition: custom_index_array.h:683
void serialize(IOContext &io) const
serialize this.
Definition: custom_index_array.h:745
void resize(Index new_dims)
Resize all dimensions, invalidating entries.
Definition: custom_index_array.h:224
requires std::is_enum_v< Tag > Slice< Tag, const_iterator > slice(Tag idx) const
Creates a slice into the multidimensional array.
Definition: custom_index_array.h:734
bool operator==(const CustomIndexArray &other) const
Equality comparison.
Definition: custom_index_array.h:293
const_iterator begin() const
Get a start iterator for the elements.
Definition: custom_index_array.h:665
auto const & array() const
array returns a reference to the internally stored flat array.
Definition: custom_index_array.h:250
Index size() const
returns the size of the array along all dimensions.
Definition: custom_index_array.h:213
An Index with more than one template parameter combines several Index objects.
Definition: index.h:181
std::pair< size_t, size_t > flatten_index(Index const &indices, Index const &dimensions)
Definition: custom_index_array.h:61
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
constexpr std::size_t index_of_type_v
The index of Type in the list Types.
Definition: metaprogramming.h:191
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ OutOfRange
boost::outcome_v2::in_place_type_t< T > Tag
Type that is used for overload resolution.
Definition: io.h:407
details::ApplyResultT< F, T... > apply(IOContext &io, F f, const IOResult< T > &... rs)
Evaluate a function with zero or more unpacked IOResults as arguments.
Definition: io.h:481
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
requires details::IsElementReference< M > RowMajorIterator< M, false > begin(M &m)
create a non-const iterator to first element of the matrix m.
Definition: eigen_util.h:421
size_t flatten_index(MultiIndex const &indices, MultiIndex const &dimensions)
flatten_index takes a set of indices into a mutlidemsional array and calculates the flat index
Definition: custom_index_array.h:92
constexpr std::tuple_element< I, std::tuple< Index< CategoryTags >... > >::type & get(Index< CategoryTags... > &i) noexcept
Retrieves the Index (by reference) at the Ith position of a MultiIndex.
Definition: index.h:294
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
Definition: custom_index_array.h:75
Generated by