Skip to content

Commit f46938f

Browse files
committed
ENH: implement stride offset checked specifically in Ix3
1 parent 02df153 commit f46938f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/dimension/dimension_trait.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,26 @@ unsafe impl Dimension for Dim<[Ix; 3]> {
659659
stride_offset(i, s) + stride_offset(j, t) + stride_offset(k, u)
660660
}
661661

662+
/// Return stride offset for this dimension and index.
663+
#[inline]
664+
fn stride_offset_checked(&self, strides: &Self, index: &Self) -> Option<isize>
665+
{
666+
let m = get!(self, 0);
667+
let n = get!(self, 1);
668+
let l = get!(self, 2);
669+
let i = get!(index, 0);
670+
let j = get!(index, 1);
671+
let k = get!(index, 2);
672+
let s = get!(strides, 0);
673+
let t = get!(strides, 1);
674+
let u = get!(strides, 2);
675+
if i < m && j < n && k < l {
676+
Some(stride_offset(i, s) + stride_offset(j, t) + stride_offset(k, u))
677+
} else {
678+
None
679+
}
680+
}
681+
662682
#[inline]
663683
fn _fastest_varying_stride_order(&self) -> Self {
664684
let mut stride = *self;

0 commit comments

Comments
 (0)