MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::block_matrix_view< S > Class Template Reference

Read-only, row-major view of a rows x cols matrix stored as blocks of the scheme S, cols / S::block_size blocks per row. More...

#include <block_matrix_view.hpp>

Public Types

using scheme_type = S
using value_type = float
using size_type = std::size_t
using const_reference = float
using reference = float

Public Member Functions

 block_matrix_view (size_type rows, size_type cols, std::span< const std::byte > bytes)
 View bytes as a rows x cols matrix.
size_type num_rows () const noexcept
size_type num_cols () const noexcept
size_type size () const noexcept
size_type blocks_per_row () const noexcept
std::span< const std::byte > bytes () const noexcept
 The encoded bytes of the whole matrix, row after row.
float operator() (size_type r, size_type c) const
 Element (r, c), decoded.
std::span< const std::byte > block (size_type r, size_type b) const
 The encoded bytes of block b of row r.
std::span< const std::byte > row (size_type r) const
 The encoded bytes of row r: blocks_per_row() consecutive blocks.
void decode_row (size_type r, float *dst) const
 Decode row r into cols floats at dst.

Static Public Attributes

static constexpr size_type block_size = S::block_size
static constexpr size_type block_bytes = S::block_bytes

Detailed Description

template<BlockScheme S>
class mtl::block_matrix_view< S >

Read-only, row-major view of a rows x cols matrix stored as blocks of the scheme S, cols / S::block_size blocks per row.

Member Typedef Documentation

◆ const_reference

template<BlockScheme S>
using mtl::mat::block_matrix_view< S >::const_reference = float

◆ reference

template<BlockScheme S>
using mtl::mat::block_matrix_view< S >::reference = float

◆ scheme_type

template<BlockScheme S>
using mtl::mat::block_matrix_view< S >::scheme_type = S

◆ size_type

template<BlockScheme S>
using mtl::mat::block_matrix_view< S >::size_type = std::size_t

◆ value_type

template<BlockScheme S>
using mtl::mat::block_matrix_view< S >::value_type = float

Constructor & Destructor Documentation

◆ block_matrix_view()

template<BlockScheme S>
mtl::mat::block_matrix_view< S >::block_matrix_view ( size_type rows,
size_type cols,
std::span< const std::byte > bytes )
inline

View bytes as a rows x cols matrix.

Throws std::invalid_argument unless cols is a multiple of the block size and bytes holds exactly rows * (cols / block_size) blocks.

The byte count is computed with overflow checks. The shape usually comes from a file header, and a product that wrapped would let a huge rows validate against a small span and every later access read past it. A shape whose byte or element count does not fit in size_t is rejected.

Member Function Documentation

◆ block()

template<BlockScheme S>
std::span< const std::byte > mtl::mat::block_matrix_view< S >::block ( size_type r,
size_type b ) const
inline

The encoded bytes of block b of row r.

◆ blocks_per_row()

template<BlockScheme S>
size_type mtl::mat::block_matrix_view< S >::blocks_per_row ( ) const
inlinenoexcept

◆ bytes()

template<BlockScheme S>
std::span< const std::byte > mtl::mat::block_matrix_view< S >::bytes ( ) const
inlinenoexcept

The encoded bytes of the whole matrix, row after row.

What the aliasing guards compare a y against (detail::storage_overlaps, #855).

◆ decode_row()

template<BlockScheme S>
void mtl::mat::block_matrix_view< S >::decode_row ( size_type r,
float * dst ) const
inline

Decode row r into cols floats at dst.

◆ num_cols()

template<BlockScheme S>
size_type mtl::mat::block_matrix_view< S >::num_cols ( ) const
inlinenoexcept

◆ num_rows()

template<BlockScheme S>
size_type mtl::mat::block_matrix_view< S >::num_rows ( ) const
inlinenoexcept

◆ operator()()

template<BlockScheme S>
float mtl::mat::block_matrix_view< S >::operator() ( size_type r,
size_type c ) const
inline

Element (r, c), decoded.

One element if the scheme can do that, the enclosing block otherwise.

◆ row()

template<BlockScheme S>
std::span< const std::byte > mtl::mat::block_matrix_view< S >::row ( size_type r) const
inline

The encoded bytes of row r: blocks_per_row() consecutive blocks.

◆ size()

template<BlockScheme S>
size_type mtl::mat::block_matrix_view< S >::size ( ) const
inlinenoexcept

Member Data Documentation

◆ block_bytes

template<BlockScheme S>
size_type mtl::mat::block_matrix_view< S >::block_bytes = S::block_bytes
staticconstexpr

◆ block_size

template<BlockScheme S>
size_type mtl::mat::block_matrix_view< S >::block_size = S::block_size
staticconstexpr

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