summaryrefslogtreecommitdiff
path: root/src/shape.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shape.rs')
-rw-r--r--src/shape.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/shape.rs b/src/shape.rs
index d626aee6..ebc497cf 100644
--- a/src/shape.rs
+++ b/src/shape.rs
@@ -128,6 +128,20 @@ impl Shape {
stride.reverse();
stride
}
+
+ pub fn is_contiguous(&self, stride: &[usize]) -> bool {
+ if self.0.len() != stride.len() {
+ return false;
+ }
+ let mut acc = 1;
+ for (&stride, &dim) in stride.iter().zip(self.0.iter()).rev() {
+ if stride != acc {
+ return false;
+ }
+ acc *= dim;
+ }
+ true
+ }
}
#[cfg(test)]