strata::Constant¶
Part of Generators.
The same value at every index: a scalar with a shape.
Read as a scalar is, so dense in every order, and an expression over it and dense views is still walked flat. It answers slice, permute, block and expand itself, giving a Constant of the resulting shape. It holds no memory beyond the value, and assigning it to a tensor fills the tensor. Made by zeros, ones and full.
Template parameters
| Name | Description |
|---|---|
T | The type of the value. |
S | The shape. |
Members¶
Constant¶
A constant of shape shape with value at every index.
shape¶
The shape.
value¶
The value every element has.
operator[]¶
The element at indices: the value, whatever they are.
Precondition
Each index is within the extent of its axis.
cursor¶
Where a traversal starts: a scalar's cursor, which never moves.
slice¶
template <std::size_t... Axes>
constexpr auto slice(const Constant &constant, const std::array<std::size_t, sizeof...(Axes)> &)
The slice of the constant: a constant of the shape without Axes.
permute¶
The permutation of the constant: a constant of the shape with its axes reordered.
block¶
template <Extent... Sizes>
constexpr auto block(const Constant &constant, const Shape<Sizes...> &sizes, const std::array<std::size_t, sizeof...(Sizes)> &)
The block of the constant: a constant of the shape of the block.
expand¶
template <std::size_t... Inserted, shape_like Space>
constexpr auto expand(const Constant &constant, const Space &space)
The constant in a shape with new axes: a constant of that shape.