batmat 0.0.15
Batched linear algebra routines
Loading...
Searching...
No Matches
batmat::matrix::View< T, I, S, D, L, O > Struct Template Reference

#include <batmat/matrix/view.hpp>

Detailed Description

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
struct batmat::matrix::View< T, I, S, D, L, O >

Non-owning view of a batch of matrices.

Template Parameters
TElement value type (possibly const-qualified).
IIndex and size type. Usually std::ptrdiff_t or int.
SInner stride type (batch size). Usually std::integral_constant<I, N> for some N.
DBatch depth type. Usually equal to S for a single batch, or I for a dynamic depth.
LLayer stride type. Usually DefaultStride (which implies that the layer stride is equal to outer_stride() * outer_size()), or I for a dynamic layer stride. Dynamic strides are used for subviews of views with a larger outer_size().
OStorage order (column or row major).

Definition at line 33 of file view.hpp.

Constructors

constexpr View (PlainBatchedMatrixView p={})
 Create a new view.
constexpr View (std::span< T > data, layout_type layout)
 Create a new view with the given layout, using the given buffer.
constexpr View (value_type *data, layout_type layout)
 Create a new view with the given layout, using the given buffer.
 View (const View &)=default
 Copy a view. No data is copied.
Viewreassign (View other)
 Reassign the buffer and layout of this view to those of another view. No data is copied.

Element access

value_typeoperator() (index_type l, index_type r, index_type c) const
 Access a single element at layer l, row r and column c.

Batch-wise slicing

batch_view_type batch (index_type b) const
 Access a batch of batch_size() layers, starting at batch index b (i.e.
View< T, I, S, I, L, O > batch_dyn (index_type b) const
 Same as batch(), but returns a view with a dynamic batch size.
View< T, I, S, I, I, O > middle_batches (index_type b, index_type n, index_type stride=1) const
 Get a view of n batches starting at batch b, with a stride of stride layers.

Layer-wise slicing

guanaqo::MatrixView< T, I, standard_stride_type, O > operator() (index_type l) const
 Access a single layer l as a non-batched view.
template<class N>
View< T, I, S, N, L, O > first_layers (N n) const
 Get a view of the first n layers. Note that n can be a compile-time constant.
template<class N>
View< T, I, S, N, L, O > middle_layers (index_type l, N n) const
 Get a view of n layers starting at layer l.

Iterators and buffer access

T * data () const
 Get a pointer to the first element of the first layer.
linear_iterator begin () const
 Iterate linearly (in storage order) over all elements of the view.
std::default_sentinel_t end () const
 Sentinel for begin().

Dimensions

constexpr index_type size () const
 Total number of elements in the view (excluding padding).
constexpr index_type padded_size () const
 Total number of elements in the view (including all padding).
constexpr depth_type depth () const
 Number of layers in the view (i.e. depth).
constexpr index_type ceil_depth () const
 The depth rounded up to a multiple of the batch size.
constexpr batch_size_type batch_size () const
 The batch size, i.e. the number of layers in each batch. Equals the inner stride.
constexpr index_type num_batches () const
 Number of batches in the view, i.e. ceil_depth() / batch_size().
constexpr index_type rows () const
 Number of rows of the matrices.
constexpr index_type cols () const
 Number of columns of the matrices.
constexpr index_type outer_size () const
 The size of the outer dimension, i.e.
constexpr index_type inner_size () const
 The size of the inner dimension, i.e.

Strides

constexpr index_type outer_stride () const
 Outer stride of the matrices (leading dimension in BLAS parlance).
constexpr auto inner_stride () const
 The inner stride of the matrices.
constexpr auto row_stride () const
 The row stride of the matrices, i.e.
constexpr auto col_stride () const
 The column stride of the matrices, i.e.
constexpr index_type layer_stride () const
 The layer stride, i.e.
constexpr bool has_full_layer_stride () const
 Whether the layer_stride() == outer_stride() * outer_size().
constexpr bool has_full_outer_stride () const
 Whether the outer_stride() == inner_stride() * inner_size().
constexpr bool has_full_inner_stride () const
 Whether the inner_stride() == 1. Always true.

Reshaping and slicing

general_slice_view_type reshaped (index_type rows, index_type cols) const
 Reshape the view to the given dimensions. The total size should not change.
row_slice_view_type top_rows (index_type n) const
 Get a view of the first n rows.
col_slice_view_type left_cols (index_type n) const
 Get a view of the first n columns.
row_slice_view_type bottom_rows (index_type n) const
 Get a view of the last n rows.
col_slice_view_type right_cols (index_type n) const
 Get a view of the last n columns.
row_slice_view_type middle_rows (index_type r, index_type n) const
 Get a view of n rows starting at row r.
row_slice_view_type middle_rows (index_type r, index_type n, index_type stride) const
 Get a view of n rows starting at row r, with stride stride.
col_slice_view_type middle_cols (index_type c, index_type n) const
 Get a view of n columns starting at column c.
col_slice_view_type middle_cols (index_type c, index_type n, index_type stride) const
 Get a view of n columns starting at column c, with stride stride.
general_slice_view_type top_left (index_type nr, index_type nc) const
 Get a view of the top-left nr by nc block of the matrices.
general_slice_view_type top_right (index_type nr, index_type nc) const
 Get a view of the top-right nr by nc block of the matrices.
general_slice_view_type bottom_left (index_type nr, index_type nc) const
 Get a view of the bottom-left nr by nc block of the matrices.
general_slice_view_type bottom_right (index_type nr, index_type nc) const
 Get a view of the bottom-right nr by nc block of the matrices.
general_slice_view_type block (index_type r, index_type c, index_type nr, index_type nc) const
 Get a view of the nr by nc block of the matrices starting at row r and column c.
auto transposed () const
 Get a transposed view of the matrices.
static View as_column (std::span< T > v)
 Get a view of the given span as a column vector.

Value manipulation

void add_to_diagonal (const value_type &t)
void set_constant (value_type t)
void negate ()
template<class Other>
void copy_values (const Other &other) const
Viewoperator= (const View &other)
 Copy assignment copies the values from another view with the same layout to this view.
template<class U, class J, class R, class E, class M>
Viewoperator= (View< U, J, R, E, M, O > other)
 Copy values from another view with a compatible value type and the same layout to this view.
template<class U, class J, class R, class E, class M>
Viewoperator+= (View< U, J, R, E, M, O > other)

View conversions

View view () const
 Returns the same view. For consistency with Matrix.
const_view_type as_const () const
 Explicit conversion to a const view.
 operator const_view_type () const
 Non-const views implicitly convert to const views.
 operator guanaqo::MatrixView< T, I, standard_stride_type, O > () const
 If we have a single layer at compile time, we can implicitly convert to a non-batched view.
 operator View< T, I, S, integral_value_type_t< D >, L, O > () const
 Implicit conversion to a view with a dynamic depth.
 operator View< const T, I, S, integral_value_type_t< D >, L, O > () const
 Implicit conversion to a view with a dynamic depth, going from non-const to const.
 operator View< T, I, S, D, I, O > () const
 Implicit conversion to a view with a dynamic layer stride.
 operator View< const T, I, S, D, I, O > () const
 Implicit conversion to a view with a dynamic layer stride, going from non-const to const.

Classes

struct  PlainBatchedMatrixView
 POD helper struct to enable designated initializers during construction. More...
struct  linear_iterator
 Iterator over all elements of a view. More...

Public Types

using layout_type = Layout<I, S, D, L, O>
using value_type = T
using index_type = typename layout_type::index_type
using batch_size_type = typename layout_type::batch_size_type
using depth_type = typename layout_type::depth_type
using layer_stride_type = typename layout_type::layer_stride_type
using standard_stride_type = typename layout_type::standard_stride_type
using const_view_type = View<const T, I, S, D, L, O>
using batch_view_type = View<T, I, S, S, DefaultStride, O>
 When extracing a single batch, the depth equals the batch size, and the layer stride is no longer relevant.
using general_slice_view_type
 When slicing along the outer dimension, the layer stride stays the same, but the outer size may be smaller, which means that even if the original view has a default layer stride, the sliced view may require a dynamic layer stride.
using col_slice_view_type = std::conditional_t<is_row_major, View, general_slice_view_type>
 View with the correct layer stride when slicing along the column dimension.
using row_slice_view_type = std::conditional_t<is_column_major, View, general_slice_view_type>
 View with the correct layer stride when slicing along the row dimension.

Public Attributes

value_typedata_ptr
 Pointer to the first element of the first layer.
layout_type layout
 Layout describing the dimensions and strides of the view.

Static Public Attributes

static constexpr StorageOrder storage_order = layout_type::storage_order
static constexpr bool is_column_major = layout_type::is_column_major
static constexpr bool is_row_major = layout_type::is_row_major
static constexpr bool has_single_batch_at_compile_time
 True if batch_size() and depth() are compile-time constants and are equal.
static constexpr bool has_single_layer_at_compile_time = requires { D::value; } && D{} == 1
 True if depth() is a compile-time constant and is equal to one.

Private Member Functions

template<class V>
constexpr auto get_layer_stride_for () const

Class Documentation

◆ batmat::matrix::View::PlainBatchedMatrixView

struct batmat::matrix::View::PlainBatchedMatrixView
Class Members
value_type * data = nullptr
depth_type depth = guanaqo::default_stride<depth_type>::value
index_type rows = 0
index_type cols = rows == 0 ? 0 : 1
index_type outer_stride = is_row_major ? cols : rows
batch_size_type batch_size
layer_stride_type layer_stride

Member Typedef Documentation

◆ layout_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::layout_type = Layout<I, S, D, L, O>

Definition at line 34 of file view.hpp.

◆ value_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::value_type = T

Definition at line 35 of file view.hpp.

◆ index_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::index_type = typename layout_type::index_type

Definition at line 36 of file view.hpp.

◆ batch_size_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::batch_size_type = typename layout_type::batch_size_type

Definition at line 37 of file view.hpp.

◆ depth_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::depth_type = typename layout_type::depth_type

Definition at line 38 of file view.hpp.

◆ layer_stride_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::layer_stride_type = typename layout_type::layer_stride_type

Definition at line 39 of file view.hpp.

◆ standard_stride_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::standard_stride_type = typename layout_type::standard_stride_type

Definition at line 40 of file view.hpp.

◆ const_view_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::const_view_type = View<const T, I, S, D, L, O>

Definition at line 41 of file view.hpp.

◆ batch_view_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::batch_view_type = View<T, I, S, S, DefaultStride, O>

When extracing a single batch, the depth equals the batch size, and the layer stride is no longer relevant.

Definition at line 57 of file view.hpp.

◆ general_slice_view_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::general_slice_view_type
Initial value:
std::conditional_t<has_single_batch_at_compile_time, View, View<T, I, S, D, I, O>>

When slicing along the outer dimension, the layer stride stays the same, but the outer size may be smaller, which means that even if the original view has a default layer stride, the sliced view may require a dynamic layer stride.

For a single batch, the layer stride is not relevant, so it is preserved.

Definition at line 62 of file view.hpp.

◆ col_slice_view_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::col_slice_view_type = std::conditional_t<is_row_major, View, general_slice_view_type>

View with the correct layer stride when slicing along the column dimension.

For row-major storage, slicing along columns does not change the outer size, in which case the layer stride is still correct. For column-major storage, slicing along columns does change the outer size, in which case we need a dynamic layer stride.

Definition at line 68 of file view.hpp.

◆ row_slice_view_type

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::View< T, I, S, D, L, O >::row_slice_view_type = std::conditional_t<is_column_major, View, general_slice_view_type>

View with the correct layer stride when slicing along the row dimension.

See also
col_slice_view_type

Definition at line 71 of file view.hpp.

Constructor & Destructor Documentation

◆ View() [1/4]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::View ( PlainBatchedMatrixView< T, I, S, D, L, O > p = {})
inlineconstexpr

Create a new view.

Note
It is recommended to use designated initializers for the arguments to avoid mistakes.

Definition at line 96 of file view.hpp.

◆ View() [2/4]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::View ( std::span< T > data,
layout_type layout )
inlineconstexpr

Create a new view with the given layout, using the given buffer.

Definition at line 104 of file view.hpp.

◆ View() [3/4]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::View ( value_type * data,
layout_type layout )
inlineconstexpr

Create a new view with the given layout, using the given buffer.

Definition at line 108 of file view.hpp.

◆ View() [4/4]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::View ( const View< T, I, S, D, L, O > & )
default

Copy a view. No data is copied.

Member Function Documentation

◆ reassign()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
View & batmat::matrix::View< T, I, S, D, L, O >::reassign ( View< T, I, S, D, L, O > other)
inline

Reassign the buffer and layout of this view to those of another view. No data is copied.

Definition at line 114 of file view.hpp.

◆ operator()() [1/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
value_type & batmat::matrix::View< T, I, S, D, L, O >::operator() ( index_type l,
index_type r,
index_type c ) const
inlinenodiscard

Access a single element at layer l, row r and column c.

Definition at line 126 of file view.hpp.

◆ batch()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batch_view_type batmat::matrix::View< T, I, S, D, L, O >::batch ( index_type b) const
inlinenodiscard

Access a batch of batch_size() layers, starting at batch index b (i.e.

starting at layer b * batch_size()).

Definition at line 137 of file view.hpp.

◆ batch_dyn()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
View< T, I, S, I, L, O > batmat::matrix::View< T, I, S, D, L, O >::batch_dyn ( index_type b) const
inlinenodiscard

Same as batch(), but returns a view with a dynamic batch size.

If the total depth is not a multiple of the batch size, the last batch will have a smaller size.

Definition at line 149 of file view.hpp.

◆ middle_batches()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
View< T, I, S, I, I, O > batmat::matrix::View< T, I, S, D, L, O >::middle_batches ( index_type b,
index_type n,
index_type stride = 1 ) const
inlinenodiscard

Get a view of n batches starting at batch b, with a stride of stride layers.

Definition at line 163 of file view.hpp.

◆ operator()() [2/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
guanaqo::MatrixView< T, I, standard_stride_type, O > batmat::matrix::View< T, I, S, D, L, O >::operator() ( index_type l) const
inlinenodiscard

Access a single layer l as a non-batched view.

Note
The inner stride of the returned view is equal to the batch size of this view, so it cannot be used directly with functions that require unit inner stride (e.g. BLAS).

Definition at line 186 of file view.hpp.

◆ first_layers()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class N>
View< T, I, S, N, L, O > batmat::matrix::View< T, I, S, D, L, O >::first_layers ( N n) const
inlinenodiscard

Get a view of the first n layers. Note that n can be a compile-time constant.

Definition at line 192 of file view.hpp.

◆ middle_layers()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class N>
View< T, I, S, N, L, O > batmat::matrix::View< T, I, S, D, L, O >::middle_layers ( index_type l,
N n ) const
inlinenodiscard

Get a view of n layers starting at layer l.

Note that n can be a compile-time constant.

Precondition
l % batch_size() == 0 (i.e. the starting layer must be at the start of a batch).

Definition at line 207 of file view.hpp.

◆ data()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
T * batmat::matrix::View< T, I, S, D, L, O >::data ( ) const
inline

Get a pointer to the first element of the first layer.

Definition at line 225 of file view.hpp.

◆ begin()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
linear_iterator batmat::matrix::View< T, I, S, D, L, O >::begin ( ) const
inlinenodiscard

Iterate linearly (in storage order) over all elements of the view.

Precondition
has_full_outer_stride() (i.e. no padding within layers).
has_full_layer_stride() (i.e. no padding between batches).

Definition at line 258 of file view.hpp.

◆ end()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
std::default_sentinel_t batmat::matrix::View< T, I, S, D, L, O >::end ( ) const
inlinenodiscard

Sentinel for begin().

Definition at line 285 of file view.hpp.

◆ size()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::size ( ) const
inlinenodiscardconstexpr

Total number of elements in the view (excluding padding).

Definition at line 293 of file view.hpp.

◆ padded_size()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::padded_size ( ) const
inlinenodiscardconstexpr

Total number of elements in the view (including all padding).

Definition at line 295 of file view.hpp.

◆ depth()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
depth_type batmat::matrix::View< T, I, S, D, L, O >::depth ( ) const
inlinenodiscardconstexpr

Number of layers in the view (i.e. depth).

Definition at line 298 of file view.hpp.

◆ ceil_depth()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::ceil_depth ( ) const
inlinenodiscardconstexpr

The depth rounded up to a multiple of the batch size.

Definition at line 300 of file view.hpp.

◆ batch_size()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batch_size_type batmat::matrix::View< T, I, S, D, L, O >::batch_size ( ) const
inlinenodiscardconstexpr

The batch size, i.e. the number of layers in each batch. Equals the inner stride.

Definition at line 304 of file view.hpp.

◆ num_batches()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::num_batches ( ) const
inlinenodiscardconstexpr

Number of batches in the view, i.e. ceil_depth() / batch_size().

Definition at line 308 of file view.hpp.

◆ rows()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::rows ( ) const
inlinenodiscardconstexpr

Number of rows of the matrices.

Definition at line 312 of file view.hpp.

◆ cols()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::cols ( ) const
inlinenodiscardconstexpr

Number of columns of the matrices.

Definition at line 314 of file view.hpp.

◆ outer_size()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::outer_size ( ) const
inlinenodiscardconstexpr

The size of the outer dimension, i.e.

the number of columns for column-major storage, or the number of rows for row-major storage.

Definition at line 317 of file view.hpp.

◆ inner_size()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::inner_size ( ) const
inlinenodiscardconstexpr

The size of the inner dimension, i.e.

the number of rows for column-major storage, or the number of columns for row-major storage.

Definition at line 322 of file view.hpp.

◆ outer_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::outer_stride ( ) const
inlinenodiscardconstexpr

Outer stride of the matrices (leading dimension in BLAS parlance).

Should be multiplied by the batch size to get the actual number of elements.

Definition at line 333 of file view.hpp.

◆ inner_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::View< T, I, S, D, L, O >::inner_stride ( ) const
inlinenodiscardconstexpr

The inner stride of the matrices.

Should be multiplied by the batch size to get the actual number of elements.

Definition at line 338 of file view.hpp.

◆ row_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::View< T, I, S, D, L, O >::row_stride ( ) const
inlinenodiscardconstexpr

The row stride of the matrices, i.e.

the distance between elements in consecutive rows in a given column. Should be multiplied by the batch size to get the actual number of elements.

Definition at line 343 of file view.hpp.

◆ col_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::View< T, I, S, D, L, O >::col_stride ( ) const
inlinenodiscardconstexpr

The column stride of the matrices, i.e.

the distance between elements in consecutive columns in a given row. Should be multiplied by the batch size to get the actual number of elements.

Definition at line 348 of file view.hpp.

◆ layer_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::View< T, I, S, D, L, O >::layer_stride ( ) const
inlinenodiscardconstexpr

The layer stride, i.e.

the distance between the first layer of one batch and the first layer of the next batch. Should be multiplied by the batch size to get the actual number of elements.

Definition at line 354 of file view.hpp.

◆ has_full_layer_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::has_full_layer_stride ( ) const
inlinenodiscardconstexpr

Whether the layer_stride() == outer_stride() * outer_size().

Definition at line 358 of file view.hpp.

◆ has_full_outer_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::has_full_outer_stride ( ) const
inlinenodiscardconstexpr

Whether the outer_stride() == inner_stride() * inner_size().

Definition at line 362 of file view.hpp.

◆ has_full_inner_stride()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::has_full_inner_stride ( ) const
inlinenodiscardconstexpr

Whether the inner_stride() == 1. Always true.

Definition at line 366 of file view.hpp.

◆ get_layer_stride_for()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class V>
auto batmat::matrix::View< T, I, S, D, L, O >::get_layer_stride_for ( ) const
inlineconstexprprivate

Definition at line 374 of file view.hpp.

◆ reshaped()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
general_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::reshaped ( index_type rows,
index_type cols ) const
inlinenodiscard

Reshape the view to the given dimensions. The total size should not change.

Definition at line 386 of file view.hpp.

◆ top_rows()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
row_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::top_rows ( index_type n) const
inlinenodiscard

Get a view of the first n rows.

Definition at line 400 of file view.hpp.

◆ left_cols()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
col_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::left_cols ( index_type n) const
inlinenodiscard

Get a view of the first n columns.

Definition at line 413 of file view.hpp.

◆ bottom_rows()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
row_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::bottom_rows ( index_type n) const
inlinenodiscard

Get a view of the last n rows.

Definition at line 426 of file view.hpp.

◆ right_cols()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
col_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::right_cols ( index_type n) const
inlinenodiscard

Get a view of the last n columns.

Definition at line 441 of file view.hpp.

◆ middle_rows() [1/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
row_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::middle_rows ( index_type r,
index_type n ) const
inlinenodiscard

Get a view of n rows starting at row r.

Definition at line 456 of file view.hpp.

◆ middle_rows() [2/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
row_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::middle_rows ( index_type r,
index_type n,
index_type stride ) const
inlinenodiscard

Get a view of n rows starting at row r, with stride stride.

Definition at line 461 of file view.hpp.

◆ middle_cols() [1/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
col_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::middle_cols ( index_type c,
index_type n ) const
inlinenodiscard

Get a view of n columns starting at column c.

Definition at line 480 of file view.hpp.

◆ middle_cols() [2/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
col_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::middle_cols ( index_type c,
index_type n,
index_type stride ) const
inlinenodiscard

Get a view of n columns starting at column c, with stride stride.

Definition at line 485 of file view.hpp.

◆ top_left()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
general_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::top_left ( index_type nr,
index_type nc ) const
inlinenodiscard

Get a view of the top-left nr by nc block of the matrices.

Definition at line 504 of file view.hpp.

◆ top_right()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
general_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::top_right ( index_type nr,
index_type nc ) const
inlinenodiscard

Get a view of the top-right nr by nc block of the matrices.

Definition at line 509 of file view.hpp.

◆ bottom_left()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
general_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::bottom_left ( index_type nr,
index_type nc ) const
inlinenodiscard

Get a view of the bottom-left nr by nc block of the matrices.

Definition at line 514 of file view.hpp.

◆ bottom_right()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
general_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::bottom_right ( index_type nr,
index_type nc ) const
inlinenodiscard

Get a view of the bottom-right nr by nc block of the matrices.

Definition at line 519 of file view.hpp.

◆ block()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
general_slice_view_type batmat::matrix::View< T, I, S, D, L, O >::block ( index_type r,
index_type c,
index_type nr,
index_type nc ) const
inlinenodiscard

Get a view of the nr by nc block of the matrices starting at row r and column c.

Definition at line 524 of file view.hpp.

◆ as_column()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
View batmat::matrix::View< T, I, S, D, L, O >::as_column ( std::span< T > v)
inlinestaticnodiscard

Get a view of the given span as a column vector.

Definition at line 530 of file view.hpp.

◆ transposed()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::View< T, I, S, D, L, O >::transposed ( ) const
inlinenodiscard

Get a transposed view of the matrices.

Note that the data itself is not modified, the returned view simply accesses the same data with rows and column indices swapped.

Definition at line 536 of file view.hpp.

◆ add_to_diagonal()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
void batmat::matrix::View< T, I, S, D, L, O >::add_to_diagonal ( const value_type & t)
inline

Definition at line 552 of file view.hpp.

◆ set_constant()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
void batmat::matrix::View< T, I, S, D, L, O >::set_constant ( value_type t)
inline

Definition at line 565 of file view.hpp.

◆ negate()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
void batmat::matrix::View< T, I, S, D, L, O >::negate ( )
inline

Definition at line 579 of file view.hpp.

◆ copy_values()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class Other>
void batmat::matrix::View< T, I, S, D, L, O >::copy_values ( const Other & other) const
inline

Definition at line 594 of file view.hpp.

◆ operator=() [1/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
View & batmat::matrix::View< T, I, S, D, L, O >::operator= ( const View< T, I, S, D, L, O > & other)
inline

Copy assignment copies the values from another view with the same layout to this view.

Definition at line 616 of file view.hpp.

◆ operator=() [2/2]

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class U, class J, class R, class E, class M>
View & batmat::matrix::View< T, I, S, D, L, O >::operator= ( View< U, J, R, E, M, O > other)
inline

Copy values from another view with a compatible value type and the same layout to this view.

Definition at line 625 of file view.hpp.

◆ operator+=()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class U, class J, class R, class E, class M>
View & batmat::matrix::View< T, I, S, D, L, O >::operator+= ( View< U, J, R, E, M, O > other)
inline

Definition at line 633 of file view.hpp.

◆ view()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
View batmat::matrix::View< T, I, S, D, L, O >::view ( ) const
inlinenodiscard

Returns the same view. For consistency with Matrix.

Definition at line 660 of file view.hpp.

◆ as_const()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
const_view_type batmat::matrix::View< T, I, S, D, L, O >::as_const ( ) const
inlinenodiscard

Explicit conversion to a const view.

Definition at line 662 of file view.hpp.

◆ operator const_view_type()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::operator const_view_type ( ) const
inline

Non-const views implicitly convert to const views.

Definition at line 665 of file view.hpp.

◆ operator guanaqo::MatrixView< T, I, standard_stride_type, O >()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::operator guanaqo::MatrixView< T, I, standard_stride_type, O > ( ) const
inline

If we have a single layer at compile time, we can implicitly convert to a non-batched view.

Definition at line 672 of file view.hpp.

◆ operator View< T, I, S, integral_value_type_t< D >, L, O >()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::operator View< T, I, S, integral_value_type_t< D >, L, O > ( ) const
inline

Implicit conversion to a view with a dynamic depth.

Definition at line 679 of file view.hpp.

◆ operator View< const T, I, S, integral_value_type_t< D >, L, O >()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::operator View< const T, I, S, integral_value_type_t< D >, L, O > ( ) const
inline

Implicit conversion to a view with a dynamic depth, going from non-const to const.

Definition at line 692 of file view.hpp.

◆ operator View< T, I, S, D, I, O >()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::operator View< T, I, S, D, I, O > ( ) const
inline

Implicit conversion to a view with a dynamic layer stride.

Definition at line 705 of file view.hpp.

◆ operator View< const T, I, S, D, I, O >()

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::View< T, I, S, D, L, O >::operator View< const T, I, S, D, I, O > ( ) const
inline

Implicit conversion to a view with a dynamic layer stride, going from non-const to const.

Definition at line 717 of file view.hpp.

Member Data Documentation

◆ storage_order

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
StorageOrder batmat::matrix::View< T, I, S, D, L, O >::storage_order = layout_type::storage_order
staticconstexpr

Definition at line 42 of file view.hpp.

◆ is_column_major

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::is_column_major = layout_type::is_column_major
staticconstexpr

Definition at line 43 of file view.hpp.

◆ is_row_major

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::is_row_major = layout_type::is_row_major
staticconstexpr

Definition at line 44 of file view.hpp.

◆ has_single_batch_at_compile_time

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::has_single_batch_at_compile_time
staticconstexpr
Initial value:
= requires {
S::value;
D::value;
} && S{} == D{}

True if batch_size() and depth() are compile-time constants and are equal.

Note
Views with dynamic batch size and depth may still have a single batch at runtime, but this cannot be statically asserted.

Definition at line 49 of file view.hpp.

◆ has_single_layer_at_compile_time

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::View< T, I, S, D, L, O >::has_single_layer_at_compile_time = requires { D::value; } && D{} == 1
staticconstexpr

True if depth() is a compile-time constant and is equal to one.

Definition at line 54 of file view.hpp.

◆ data_ptr

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
value_type* batmat::matrix::View< T, I, S, D, L, O >::data_ptr

Pointer to the first element of the first layer.

Definition at line 74 of file view.hpp.

◆ layout

template<class T, class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
layout_type batmat::matrix::View< T, I, S, D, L, O >::layout

Layout describing the dimensions and strides of the view.

Definition at line 76 of file view.hpp.


The documentation for this struct was generated from the following file: