[bug] Reshape does not work with views
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
In my use case I take a (sub-)view of a matrix and then reshape that view. Unfortunately that gives wrong results and reshape does not take the view into account.
Here is an example which shows the failure:
```
fn test_shape() {
let m1 = nalgebra::DMatrix::from_row_slice(
3,
4,
&[
1.0, 2.0, 3.0, 4.0, //
5.0, 6.0, 7.0, 8.0, //
9.0, 10.0, 11.0, 12.0, //
],
);
let m2 = m1.view((0, 0), (2, 3));
let m3 = m2.reshape_generic(nalgebra::Dyn(6), nalgebra::Dyn(1));
assert_eq!(m3[(0, 0)], 1.0);
assert_eq!(m3[(1, 0)], 5.0);
assert_eq!(m3[(2, 0)], 2.0); // it's 9 instead
assert_eq!(m3[(3, 0)], 6.0); // it's 2 instead
assert_eq!(m3[(4, 0)], 3.0); // it's 6 instead
assert_eq!(m3[(5, 0)], 7.0); // it's 10 instead
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.