You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is safe for ArrayView instances to have aliasing elements. It would be good to add support for this in ArrayView::from_shape. I'm not sure whether we should support all possible types of aliasing, but it would be good to at least add support for stride 0 for axes with length greater than 1. (Views like this are often the result of broadcasting.)
The text was updated successfully, but these errors were encountered:
I'm referring to the case where there exists an element such that multiple different indices can be used to access that element. This is situation is safe for ArrayView but not for ArrayViewMut. This typically occurs with axes that have zero stride as a result of broadcasting, but it would be nice to support aliasing in ArrayView::from_shape for manually-created views.
For example, consider
externcrate ndarray;use ndarray::prelude::*;fnmain(){let a = ArrayView1::from(&[1,2,3]);let b = a.broadcast((2,3)).unwrap();println!("{:?}", b);}
The elements are aliased in the sense that e.g. b[(0,0)] and b[(1,0)] refer to the same element.
It would be nice to obtain b directly without broadcasting like this:
externcrate ndarray;use ndarray::prelude::*;fnmain(){let b = ArrayView::from_shape((2,3).strides((0,1)),&[1,2,3]).unwrap();println!("{:?}", b);}
but that currently exits with "thread 'main' panicked at 'called Result::unwrap() on an Err value: ShapeError/Unsupported: unsupported operation', src/libcore/result.rs:997:5".
It is safe for
ArrayView
instances to have aliasing elements. It would be good to add support for this inArrayView::from_shape
. I'm not sure whether we should support all possible types of aliasing, but it would be good to at least add support for stride 0 for axes with length greater than 1. (Views like this are often the result of broadcasting.)The text was updated successfully, but these errors were encountered: