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_nd Namespace Reference

Functions

template<typename Order, std::size_t N, std::size_t K, typename F>
void walk_offsets (const shape< N > &sh, const std::array< std::array< std::size_t, N >, K > &st, F &&f)
 Calls f(off) for every element of an array of shape sh, in Order's index order – c_order: the last index fastest; f_order: the first – where off[k] is the element's offset under the strides st[k].

Function Documentation

◆ walk_offsets()

template<typename Order, std::size_t N, std::size_t K, typename F>
void mtl::array::detail_nd::walk_offsets ( const shape< N > & sh,
const std::array< std::array< std::size_t, N >, K > & st,
F && f )

Calls f(off) for every element of an array of shape sh, in Order's index order – c_order: the last index fastest; f_order: the first – where off[k] is the element's offset under the strides st[k].

One walk serves several arrays of one shape (a copy, a broadcast, an axis reduction). The innermost dimension is a plain loop; the outer ones advance an odometer, so there is no index array to build or check per element (#856).