-
-
Notifications
You must be signed in to change notification settings - Fork 514
Description
I'm working on implementing conversions between nalgebra
and ndarray
types. This looks fairly straightforward, but I have two questions:
-
Does
nalgebra
support negative strides? From what I can tell, the answer is "no", but will you please confirm? -
Does
nalgebra
allow using strides that result in multiple indices pointing to the same element?ndarray
allows this for immutable views (ArrayView
) but not for mutable views (ArrayViewMut
) due to Rust's aliasing rules. I'm somewhat surprised thatnalgebra
's mutable slices currently allow this:extern crate nalgebra as na; use na::DMatrixSliceMut; fn main() { let slice = &mut [1, 2, 3]; let m = DMatrixSliceMut::from_slice_with_strides_mut(slice, 2, 3, 0, 1); // Prints: // ┌ ┐ // │ 1 2 3 │ // │ 1 2 3 │ // └ ┘ println!("{}", m); }
This should be fine fine as long as
nalgebra
doesn't allow getting mutable references simultaneously for two different indices (e.g. with something likesplit_at
). I'm just surprised at the current behavior, so I'd like to make sure it's intentional and not a bug.