|
Stratax 0.4.0rc1
|
Headers: include/stratax/indexing/Indexing.hpp and Normalize.hpp.
stratax::indexing::offset(strides, indices) computes the sum of each normalized index times its element stride. It is unchecked: the index container must have exactly one component per stride, all components must address valid storage, and arithmetic must be representable. Strides may be canonical or describe a view; the result is a physical element offset, not necessarily a logical flat position. Cost is O(r).
stratax::indexing::normalize_index(index, size) accepts a signed index in [-size, size) and returns its unsigned nonnegative equivalent. It handles negative indices without overflowing at ptrdiff_t minimum and throws Exceptions::IndexError when out of range. Empty extents reject every index. Cost is O(1).
Owning Matrix/Tensor operator() uses unchecked offsets. Their at overloads normalize and validate first. ArrayView operator() validates rank but leaves component bounds as preconditions. The reserved bounds_checking config flag does not change these contracts. See ArrayView and Validation.