strata::Ewise¶
Part of Element-wise expressions.
An element-wise expression: fn(operands[i...]...) for every index, computed when assigned, not before.
Operands are tensors, other expressions and scalars, each held as capture_t says: a view or an expression by value, which is cheap, an lvalue owner borrowed, a temporary owner moved in and owned, which makes the expression moved and never copied. Chains of one left-foldable operation are kept flat: a + b + c is one Ewise<Plus> over three operands, computed as (a + b) + c all the same. Expressions are usually made by the operators and by map, not spelled out.
A slice, a permutation or a block of an expression is the expression over the same operation of each operand, which keeps the views views, and the expression walkable as they are. That is so for an expression that can be copied; one that holds a temporary owner is cut by the nodes of slice, permute and block, which move it in.
Template parameters
| Name | Description |
|---|---|
Fn | The function object applied to the operand values at each index. |
Args | The operands as they are held, each a tensor or a Scalar. |
Precondition
Every tensor operand has the same extents (checked on construction).
Members¶
shape_type¶
The common shape of the tensor operands.
value_type¶
using strata::Ewise< Fn, Args >::value_type = std::remove_cvref_t<std::invoke_result_t<const Fn&, value_t<Args>...>>
What fn gives for the operand values, without const and references.
nothrow_make¶
static constexpr bool nothrow_make = std::is_nothrow_move_constructible_v<Fn> &&
(std::is_nothrow_move_constructible_v<Args> && ...) && shapes_nothrow
Whether making the expression from its function and operands does not throw.
Ewise¶
The expression of fn over operands.
Precondition
The tensor operands have equal extents on every axis.
fn¶
The function applied at each index.
operands¶
The operands, in order.
The operands of an expression that is no longer used, to be moved on.
shape¶
The shape of the expression: the extents of the tensor operands, static wherever any fixes them.
cursor¶
Where a traversal starts: every operand's cursor, and the functor.
operator[]¶
The value at the index, computed from the operands there.
Parameters
| Name | Description |
|---|---|
indices | One per axis. |
slice¶
template <std::size_t... Axes>
constexpr auto slice(const Ewise &expression, const std::array<std::size_t, sizeof...(Axes)> &indices)
The slice of the expression: the expression over the slice of each tensor operand.
permute¶
The permutation of the expression: the expression over the permutation of each tensor operand.
block¶
template <Extent... Sizes>
constexpr auto block(const Ewise &expression, const Shape<Sizes...> &sizes, const std::array<std::size_t, sizeof...(Sizes)> &corner)
The block of the expression: the expression over the block of each tensor operand.