How do you turn an ndarray::ArrayView into a new ndarray?

86 Views Asked by At

How do you efficiently take a view of an ndarray and create a new ndarray from it, like array[1..5, 3..6]?

1

There are 1 best solutions below

4
Chayim Friedman On BEST ANSWER

The docs of ArrayBase have a nice conversion table. The way to convert from ArrayView and ArrayViewMut to Array is view.to_owned().

To slice an owned array into an owned array, though, have a more efficient implementation: slice_move() or slice_collapse().