pub fn is_injective_layout(dims: &[usize], strides: &[isize]) -> boolExpand description
Decide whether distinct logical output positions map to distinct offsets.
Axes are analysed in ascending |stride| order. An axis whose stride
exceeds the offset span already covered by all smaller-stride axes is
separated: it can never alias them, so it does not need enumeration.
Only the interleaved block of smaller-stride axes that precede the last
non-separated axis is checked exactly, by enumerating its offsets once
with incremental traversal. The answer is exact whenever that block holds
at most [EXACT_BLOCK_BUDGET] logical elements, independent of the total
destination size (issues #255 and #256). Larger interleaved blocks, and
metadata whose spans cannot be represented, are conservatively rejected.
ยงExamples
use strided_basic::execution::is_injective_layout;
assert!(is_injective_layout(&[2, 3], &[1, 2]));
assert!(!is_injective_layout(&[2, 3], &[0, 1]));
// Interleaved but injective: 2000 = 2 (mod 3) keeps the rows apart.
assert!(is_injective_layout(&[3, 1500], &[2000, 3]));