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

Classes

struct  is_index_arg
struct  is_index_arg< all_t >
struct  is_index_arg< range >

Concepts

concept  SliceIndex

Functions

template<typename... Args>
constexpr std::size_t count_kept_dims ()
template<std::size_t M, std::size_t N, typename... Args>
void slice_layout (const shape< N > &ext, const std::array< std::size_t, N > &strides, shape< M > &new_shape, std::array< std::size_t, M > &new_strides, std::size_t &base_offset, Args... args)
 The shape, strides and base offset of a slice of an array with the given extents and strides.

Function Documentation

◆ count_kept_dims()

template<typename... Args>
std::size_t mtl::array::detail_slice::count_kept_dims ( )
constexpr

◆ slice_layout()

template<std::size_t M, std::size_t N, typename... Args>
void mtl::array::detail_slice::slice_layout ( const shape< N > & ext,
const std::array< std::size_t, N > & strides,
shape< M > & new_shape,
std::array< std::size_t, M > & new_strides,
std::size_t & base_offset,
Args... args )

The shape, strides and base offset of a slice of an array with the given extents and strides.

Every argument is checked, in every build (#856):

  • a range is clamped to the extent, as NumPy clamps it: range(2, 10) of 3 rows is the one row 2, and a range that starts past the end is empty;
  • step 0 throws std::invalid_argument (it divided by zero);
  • an integer index outside [0, extent) throws std::out_of_range (it addressed memory past the array).