Skip to content

strata::Diagonal

Part of Views and expressions.

template <tensor_like E, std::size_t... Axes>
class strata::Diagonal;

E read along its diagonal: the axes Axes become one, at the place of the first, and element i of it is the operand's at i on each of them.

diagonal<0, 1>(matrix) is the main diagonal.

What diagonal<Axes...> gives for a node that has no diagonal of its own: it reads through the operand, and its cursor is the operand's, stepped along all of Axes at once. A node with a better way, a view whose diagonal is another view, gives that instead.

Template parameters

Name Description
E The operand as it is held, capture_t of what was given: borrowed for an lvalue owner, owned for a temporary one, which makes the diagonal moved and never copied, else by value.
Axes At least two axes of the operand, in increasing order, of one extent.

Members

Diagonal

explicit constexpr Diagonal(E operand)

The diagonal of operand over Axes.

Precondition

The operand's extents along Axes are equal.

operand

constexpr const E & operand() const noexcept STRATA_LIFETIMEBOUND

The operand that is read along its diagonal.

shape

constexpr shape_type shape() const

The operand's shape with Axes made one.

cursor

constexpr auto cursor() const

Where a traversal starts: the operand's cursor, with the diagonal axis stepping along all of Axes.

operator[]

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

The element at a position of the diagonal: the operand's, with the diagonal's index on each of Axes.

Precondition

Each index is within the extent of its axis; the operand checks it.