Skip to content

strata::TensorInterface

Part of Views and expressions.

template <typename Derived>
struct strata::TensorInterface;

The shape-derived members of a tensor, written once.

A node derives from TensorInterface<Node> and declares shape(), and shape_type where it can name it. It gets rank, dyn_rank, static_extent, extent, size and empty from it, and may declare its own extent or size where it has a cheaper way; that hides the one here.

Nothing needs it: a type is a tensor_like by what it has, and cursor(tensor) finds the node's cursor or reads by index. As std::ranges::view_interface does for a view, this only adds members.

Template parameters

Name Description
Derived The node itself.

Members

rank

static constexpr std::size_t rank() noexcept

The number of axes.

dyn_rank

static constexpr std::size_t dyn_rank() noexcept

The number of dynamic axes.

static_extent

static constexpr std::optional<std::size_t> static_extent(std::size_t axis) noexcept

The extent the type fixes for axis, if any.

extent

template <shape_queryable Self>
constexpr std::size_t extent(this const Self &self, std::size_t axis)

The extent of axis, static or dynamic.

size

template <shape_queryable Self>
constexpr std::size_t size(this const Self &self)

The number of elements: the product of all extents.

empty

template <shape_queryable Self>
constexpr bool empty(this const Self &self)

Whether there are no elements.