MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::recursion Namespace Reference

Classes

struct  min_dim_test
 Stops recursion when min(rows, cols) <= threshold. More...
struct  max_dim_test
 Stops recursion when max(rows, cols) <= threshold. More...
struct  max_dim_test_static
 Compile-time threshold version of max_dim_test. More...
class  recursator
 Wraps a matrix and provides quad-tree subdivision for block-recursive algorithms. More...

Functions

constexpr bool is_power_of_2 (std::size_t n)
 True if n is a power of 2.
constexpr std::size_t first_part (std::size_t n)
 Largest power of 2 that is <= n (for n >= 1).
constexpr std::size_t outer_bound (std::size_t n)
 Smallest power of 2 that is >= n.
template<typename Matrix, typename Function, typename BaseCaseTest>
void for_each (recursator< Matrix > rec, Function &&fn, const BaseCaseTest &is_base)
 Recursively apply function to all base-case sub-regions of the recursator.
constexpr std::uint64_t lsb_mask (unsigned n)
 Create a mask with the lowest N bits set.
constexpr std::uint64_t row_major_mask (unsigned k)
 Row-major mask for block size K: interleaved bit pattern, the bits [i + k, i + 2k) for i = 0, 2k, 4k, ... below 64.
constexpr std::uint64_t col_major_mask (unsigned k)
 Column-major mask for block size K: complement of row-major.

Variables

constexpr std::uint64_t morton_z_mask = UINT64_C(0x5555555555555555)
 Morton Z-order mask: alternating bits for row/column interleaving Bit 0 = column, Bit 1 = row, Bit 2 = column, Bit 3 = row, ...
constexpr std::uint64_t morton_mask = ~morton_z_mask
 Complement of morton_z_mask (row bits in Z-order).
constexpr std::uint64_t doppled_2_row_mask = row_major_mask(1)
 Doppled row-major: blocks of 2 bits for row indices.
constexpr std::uint64_t doppled_2_col_mask = col_major_mask(1)
constexpr std::uint64_t doppled_4_row_mask = row_major_mask(2)
 Doppled with block size 4.
constexpr std::uint64_t doppled_4_col_mask = col_major_mask(2)
constexpr std::uint64_t doppled_16_row_mask = row_major_mask(4)
 Doppled with block size 16.
constexpr std::uint64_t doppled_16_col_mask = col_major_mask(4)
constexpr std::uint64_t doppled_32_row_mask = row_major_mask(5)
 Doppled with block size 32.
constexpr std::uint64_t doppled_32_col_mask = col_major_mask(5)
constexpr std::uint64_t doppled_64_row_mask = row_major_mask(6)
 Doppled with block size 64.
constexpr std::uint64_t doppled_64_col_mask = col_major_mask(6)
constexpr std::uint64_t doppled_128_row_mask = row_major_mask(7)
 Doppled with block size 128.
constexpr std::uint64_t doppled_128_col_mask = col_major_mask(7)

Function Documentation

◆ col_major_mask()

std::uint64_t mtl::recursion::col_major_mask ( unsigned k)
constexpr

Column-major mask for block size K: complement of row-major.

◆ first_part()

std::size_t mtl::recursion::first_part ( std::size_t n)
constexpr

Largest power of 2 that is <= n (for n >= 1).

◆ for_each()

template<typename Matrix, typename Function, typename BaseCaseTest>
void mtl::recursion::for_each ( recursator< Matrix > rec,
Function && fn,
const BaseCaseTest & is_base )

Recursively apply function to all base-case sub-regions of the recursator.

◆ is_power_of_2()

bool mtl::recursion::is_power_of_2 ( std::size_t n)
constexpr

True if n is a power of 2.

◆ lsb_mask()

std::uint64_t mtl::recursion::lsb_mask ( unsigned n)
constexpr

Create a mask with the lowest N bits set.

◆ outer_bound()

std::size_t mtl::recursion::outer_bound ( std::size_t n)
constexpr

Smallest power of 2 that is >= n.

Above the largest power of 2 a size_t holds (2^63 on 64-bit) there is none: std::bit_ceil is undefined there, so it is rejected (issue 877).

◆ row_major_mask()

std::uint64_t mtl::recursion::row_major_mask ( unsigned k)
constexpr

Row-major mask for block size K: interleaved bit pattern, the bits [i + k, i + 2k) for i = 0, 2k, 4k, ... below 64.

For K=1: 0xAAAA... (odd bits set – row index bits) For K=2: 0xCCCC... (pairs of bits for row) For K >= 32 there is one block, clipped at bit 63 (K = 33: bits 33..63); for K >= 64 none (0). K = 0 has no blocks and the loop did not advance: it is rejected, which in a constant expression is a compile error (issue 877).

Variable Documentation

◆ doppled_128_col_mask

std::uint64_t mtl::recursion::doppled_128_col_mask = col_major_mask(7)
inlineconstexpr

◆ doppled_128_row_mask

std::uint64_t mtl::recursion::doppled_128_row_mask = row_major_mask(7)
inlineconstexpr

Doppled with block size 128.

◆ doppled_16_col_mask

std::uint64_t mtl::recursion::doppled_16_col_mask = col_major_mask(4)
inlineconstexpr

◆ doppled_16_row_mask

std::uint64_t mtl::recursion::doppled_16_row_mask = row_major_mask(4)
inlineconstexpr

Doppled with block size 16.

◆ doppled_2_col_mask

std::uint64_t mtl::recursion::doppled_2_col_mask = col_major_mask(1)
inlineconstexpr

◆ doppled_2_row_mask

std::uint64_t mtl::recursion::doppled_2_row_mask = row_major_mask(1)
inlineconstexpr

Doppled row-major: blocks of 2 bits for row indices.

◆ doppled_32_col_mask

std::uint64_t mtl::recursion::doppled_32_col_mask = col_major_mask(5)
inlineconstexpr

◆ doppled_32_row_mask

std::uint64_t mtl::recursion::doppled_32_row_mask = row_major_mask(5)
inlineconstexpr

Doppled with block size 32.

◆ doppled_4_col_mask

std::uint64_t mtl::recursion::doppled_4_col_mask = col_major_mask(2)
inlineconstexpr

◆ doppled_4_row_mask

std::uint64_t mtl::recursion::doppled_4_row_mask = row_major_mask(2)
inlineconstexpr

Doppled with block size 4.

◆ doppled_64_col_mask

std::uint64_t mtl::recursion::doppled_64_col_mask = col_major_mask(6)
inlineconstexpr

◆ doppled_64_row_mask

std::uint64_t mtl::recursion::doppled_64_row_mask = row_major_mask(6)
inlineconstexpr

Doppled with block size 64.

◆ morton_mask

std::uint64_t mtl::recursion::morton_mask = ~morton_z_mask
inlineconstexpr

Complement of morton_z_mask (row bits in Z-order).

◆ morton_z_mask

std::uint64_t mtl::recursion::morton_z_mask = UINT64_C(0x5555555555555555)
inlineconstexpr

Morton Z-order mask: alternating bits for row/column interleaving Bit 0 = column, Bit 1 = row, Bit 2 = column, Bit 3 = row, ...