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
Suppose I have an arbitrary array; any model of ownership, any number of dimensions, possibly non-contiguous, with strides in whatever order. How do I get an owned array in standard layout? And could it be better documented?
Based on the documentation of ArrayBase alone, it seems to me that the following is the only safe bet:
Yeah, that's the simplest way, I think. The other obvious things to try (.to_owned() and .map()/.mapv()) don't alter the layout of contiguous arrays, so they don't help in this case.
Something like this might be faster for handling contiguous arrays in standard layout, but you'd have to benchmark to know for sure:
It would be nice in the future to provide a more concise way to convert between memory layouts, possibly using something like the Cow-like types described in #390.
Activity
jturner314 commentedon Apr 27, 2018
Yeah, that's the simplest way, I think. The other obvious things to try (
.to_owned()
and.map()
/.mapv()
) don't alter the layout of contiguous arrays, so they don't help in this case.Something like this might be faster for handling contiguous arrays in standard layout, but you'd have to benchmark to know for sure:
If your element type is
Copy
, an alternative approach is to allocate a new array with::uninitialized()
and then.assign()
the data.I've created #442. What do you think?
jturner314 commentedon May 4, 2018
Resolved by #442.
It would be nice in the future to provide a more concise way to convert between memory layouts, possibly using something like the
Cow
-like types described in #390.