Questions about compatibility between nalgebra and ndarray
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
I'm working on implementing conversions between `nalgebra` and `ndarray` types. This looks fairly straightforward, but I have two questions:
1. Does `nalgebra` support negative strides? From what I can tell, the answer is "no", but will you please confirm?
2. 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 that `nalgebra`'s mutable slices currently allow this:
```rust
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 like [`split_at`](https://docs.rs/ndarray/0.12.0/ndarray/type.ArrayViewMut.html#method.split_at)). I'm just surprised at the current behavior, so I'd like to make sure it's intentional and not a bug.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.