Skip to content

strata::Expanded

Part of Views and expressions.

template <tensor_like E, auto Axes, shape_like Space>
class strata::Expanded;

E read as a tensor of the space Space: element s... is operand[s[Axes[a]]...].

An operand with axes inserted. Its axis a is space axis Axes[a], in the order it has them; the other axes of the space are new, and along them it does not change, a broadcast. What expand makes. Only read, never written: through a broadcast axis every position would write the same element.

A slice, a permutation or a block of it is the same operation on its operand, along the operand's axes that are on the space axes it touches. That is so for an expansion that can be copied; one that holds a temporary owner is cut by the nodes of slice, permute and block.

Template parameters

Name Description
E The operand as it is held, a tensor: capture_t of what was given.
Axes The space axis of each axis of E, an array of rank_v<E> of them, increasing.
Space The shape of the space.

Members

Expanded

constexpr Expanded(E operand, const Space &space)

operand read in space.

Precondition

The extent of each axis of operand is that of its space axis in space.

operand

constexpr const E & operand() const noexcept

The operand that is read in the space.

shape

constexpr const Space & shape() const noexcept

The shape of the space.

cursor

constexpr auto cursor() const

Where a traversal starts: the operand's cursor, stepped along the space.

operator[]

template <index_like... Indices>
constexpr value_type operator[](Indices... indices) const

The element at a position of the space: the operand's at the indices of its space axes.

slice

template <std::size_t... Fixed>
constexpr auto slice(const Expanded &expanded, const std::array<std::size_t, sizeof...(Fixed)> &indices)

The slice of the expansion along space axes: the expansion of the operand sliced along its axes that are on them, none for a new axis, in the space without them.

permute

template <std::size_t... Permutation>
constexpr auto permute(const Expanded &expanded)

The permutation of the expansion: the expansion, in the permuted space, of the operand with its axes permuted to the order they have there.

block

template <Extent... Sizes>
constexpr auto block(const Expanded &expanded, const Shape<Sizes...> &sizes, const std::array<std::size_t, sizeof...(Sizes)> &corner)

The block of the expansion: the expansion of the operand's block, over each of its axes the box of its space axis.

expand

template <std::size_t... Inserted, shape_like NewSpace>
constexpr auto expand(const Expanded &expanded, const NewSpace &space)

The expansion of the expansion: the same operand in the larger space, its axes on the axes of that the first space's are.

Inserting axes twice is inserting them once.