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

#include <batmat/matrix/layout.hpp>

Detailed Description

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

Shape and strides describing a batch of matrices, independent of any storage.

Template Parameters
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().
OMatrix storage order, RowMajor or ColMajor.

Definition at line 50 of file layout.hpp.

Compile-time properties

using index_type = I
using batch_size_type = S
using depth_type = D
using layer_stride_type = L
using standard_stride_type
static constexpr StorageOrder storage_order = O
static constexpr bool is_column_major = O == StorageOrder::ColMajor
static constexpr bool is_row_major = O == StorageOrder::RowMajor
static constexpr std::integral_constant< index_type, 1 > inner_stride {}

Layout description

depth_type depth
index_type rows
index_type cols
index_type outer_stride
batch_size_type batch_size
layer_stride_type layer_stride

Initialization

constexpr Layout (PlainLayout p={})

Classes

struct  PlainLayout

Public Member Functions

constexpr index_type outer_size () const
constexpr index_type inner_size () const
constexpr index_type num_batches () const
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 ceil_depth (index_type n) const
 Round up the given size n to a multiple of batch_size.
constexpr index_type ceil_depth () const
 Round up the depth to a multiple of batch_size.
constexpr index_type floor_depth (index_type n) const
 Round down the given size n to a multiple of batch_size.
constexpr index_type floor_depth () const
 Round down the depth to a multiple of batch_size.
constexpr auto get_layer_stride () const
constexpr bool has_full_layer_stride () const
constexpr bool has_full_outer_stride () const
constexpr bool has_full_inner_stride () const
constexpr index_type layer_index (index_type l, index_type s) const
constexpr index_type layer_index (index_type l) const
template<class T>
guanaqo::MatrixView< T, I, standard_stride_type, storage_orderoperator() (T *data, index_type l) const
template<class T>
T & operator() (T *data, index_type l, index_type r, index_type c) const
index_type size () const
 Total number of elements in the view (excluding padding).
index_type padded_size () const

Static Public Member Functions

static standard_stride_type convert_to_standard_stride (auto s)

Class Documentation

◆ batmat::matrix::Layout::PlainLayout

struct batmat::matrix::Layout::PlainLayout
Class Members
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

◆ index_type

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

Definition at line 53 of file layout.hpp.

◆ batch_size_type

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

Definition at line 54 of file layout.hpp.

◆ depth_type

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

Definition at line 55 of file layout.hpp.

◆ layer_stride_type

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

Definition at line 56 of file layout.hpp.

◆ standard_stride_type

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::Layout< I, S, D, L, O >::standard_stride_type
Initial value:
std::conditional_t<requires {
S::value;
}, std::integral_constant<index_t, S::value>, index_t>

Definition at line 62 of file layout.hpp.

Constructor & Destructor Documentation

◆ Layout()

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

Definition at line 93 of file layout.hpp.

Member Function Documentation

◆ outer_size()

template<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::Layout< I, S, D, L, O >::outer_size ( ) const
inlinenodiscardconstexpr

Definition at line 99 of file layout.hpp.

◆ inner_size()

template<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::Layout< I, S, D, L, O >::inner_size ( ) const
inlinenodiscardconstexpr

Definition at line 100 of file layout.hpp.

◆ num_batches()

template<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::Layout< I, S, D, L, O >::num_batches ( ) const
inlinenodiscardconstexpr

Definition at line 101 of file layout.hpp.

◆ row_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::Layout< 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 108 of file layout.hpp.

◆ col_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::Layout< 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 116 of file layout.hpp.

◆ ceil_depth() [1/2]

template<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::Layout< I, S, D, L, O >::ceil_depth ( index_type n) const
inlinenodiscardconstexpr

Round up the given size n to a multiple of batch_size.

Definition at line 123 of file layout.hpp.

◆ ceil_depth() [2/2]

template<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::Layout< I, S, D, L, O >::ceil_depth ( ) const
inlinenodiscardconstexpr

Round up the depth to a multiple of batch_size.

Definition at line 128 of file layout.hpp.

◆ floor_depth() [1/2]

template<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::Layout< I, S, D, L, O >::floor_depth ( index_type n) const
inlinenodiscardconstexpr

Round down the given size n to a multiple of batch_size.

Definition at line 132 of file layout.hpp.

◆ floor_depth() [2/2]

template<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::Layout< I, S, D, L, O >::floor_depth ( ) const
inlinenodiscardconstexpr

Round down the depth to a multiple of batch_size.

Definition at line 137 of file layout.hpp.

◆ get_layer_stride()

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

Definition at line 140 of file layout.hpp.

◆ has_full_layer_stride()

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

Definition at line 146 of file layout.hpp.

◆ has_full_outer_stride()

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

Definition at line 150 of file layout.hpp.

◆ has_full_inner_stride()

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

Definition at line 153 of file layout.hpp.

◆ layer_index() [1/2]

template<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::Layout< I, S, D, L, O >::layer_index ( index_type l,
index_type s ) const
inlinenodiscardconstexpr

Definition at line 154 of file layout.hpp.

◆ layer_index() [2/2]

template<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::Layout< I, S, D, L, O >::layer_index ( index_type l) const
inlinenodiscardconstexpr

Definition at line 160 of file layout.hpp.

◆ convert_to_standard_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
standard_stride_type batmat::matrix::Layout< I, S, D, L, O >::convert_to_standard_stride ( auto s)
inlinestatic

Definition at line 164 of file layout.hpp.

◆ operator()() [1/2]

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

Definition at line 173 of file layout.hpp.

◆ operator()() [2/2]

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

Definition at line 181 of file layout.hpp.

◆ size()

template<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::Layout< I, S, D, L, O >::size ( ) const
inlinenodiscard

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

Definition at line 187 of file layout.hpp.

◆ padded_size()

template<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::Layout< I, S, D, L, O >::padded_size ( ) const
inlinenodiscard

Definition at line 188 of file layout.hpp.

Member Data Documentation

◆ storage_order

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

Definition at line 57 of file layout.hpp.

◆ is_column_major

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

Definition at line 58 of file layout.hpp.

◆ is_row_major

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

Definition at line 59 of file layout.hpp.

◆ inner_stride

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
std::integral_constant<index_type, 1> batmat::matrix::Layout< I, S, D, L, O >::inner_stride {}
staticconstexpr

Definition at line 60 of file layout.hpp.

◆ depth

template<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::Layout< I, S, D, L, O >::depth

Definition at line 70 of file layout.hpp.

◆ rows

template<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::Layout< I, S, D, L, O >::rows

Definition at line 71 of file layout.hpp.

◆ cols

template<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::Layout< I, S, D, L, O >::cols

Definition at line 72 of file layout.hpp.

◆ outer_stride

template<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::Layout< I, S, D, L, O >::outer_stride

Definition at line 73 of file layout.hpp.

◆ batch_size

template<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::Layout< I, S, D, L, O >::batch_size

Definition at line 74 of file layout.hpp.

◆ layer_stride

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
layer_stride_type batmat::matrix::Layout< I, S, D, L, O >::layer_stride

Definition at line 75 of file layout.hpp.


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