strata::Generated¶
Part of Generators.
template <shape_like S, typename F, auto Sources = detail::identity_sources<S::rank()>()>
class strata::Generated;
fn(i, j, ...) at every index of S: a tensor whose elements are computed from their index.
The function takes one std::size_t per axis and returns the element, of the value type it gives, without its reference or const. Read, sliced, permuted and blocked like a view: slices, blocks and permutations change only which coordinates fn is called with, and the result is still a Generated of the same function. Nothing is stored but the function. Made by generate, eye, iota and linspace.
A function that cannot be copied is not carried over to the slice of the generator: that is then a Slice node, which borrows the generator.
Template parameters
| Name | Description |
|---|---|
S | The shape. |
F | The function, callable with Sources.size() indices of std::size_t. |
Sources | Which axis feeds each coordinate of fn, or none where a slice fixed it. It is only changed by slicing and permuting, and stays the default for a generator made by hand. |
Members¶
slice¶
template <std::size_t... Axes>
constexpr auto slice(const Generated &generator, const std::array<std::size_t, sizeof...(Axes)> &indices)
The slice of the generator: the same function, fed the fixed indices, and the axes that are left.
permute¶
The permutation of the generator: the same function, its coordinates fed by the permuted axes.
block¶
template <Extent... Sizes>
constexpr auto block(const Generated &generator, const Shape<Sizes...> &sizes, const std::array<std::size_t, sizeof...(Sizes)> &corner)
The block of the generator: the same function, its coordinates shifted to the corner.
Generated¶
A generator of shape shape that calls fn(i, j, ...) at each index.
shape¶
The shape.
fn¶
The function: the one given, or a new one if it has no state to store.
operator[]¶
The element at indices: fn called with them, moved by what slices and blocks fixed.
Precondition
Each index is non-negative and within the extent of its axis.
cursor¶
Where a traversal starts: the coordinates of the first element.