@@ -124,7 +124,35 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
124
124
}
125
125
}
126
126
127
- /// Return an uniquely owned copy of the array
127
+ /// Return an uniquely owned copy of the array.
128
+ ///
129
+ /// For performance, the memory layout of the resulting array is arbitrary.
130
+ /// If you need a particular layout, you can allocate a new array with the
131
+ /// desired memory layout and [`.assign()`](#method.assign) the data.
132
+ /// Alternatively, you can collect an iterator, like this for a result in
133
+ /// standard layout:
134
+ ///
135
+ /// ```
136
+ /// # use ndarray::prelude::*;
137
+ /// # let arr = Array::from_shape_vec((2, 2).f(), vec![1, 2, 3, 4]).unwrap();
138
+ /// # let owned = {
139
+ /// Array::from_shape_vec(arr.raw_dim(), arr.iter().cloned().collect()).unwrap()
140
+ /// # };
141
+ /// # assert!(owned.is_standard_layout());
142
+ /// # assert_eq!(arr, owned);
143
+ /// ```
144
+ ///
145
+ /// or this for a result in column-major (Fortran) layout:
146
+ ///
147
+ /// ```
148
+ /// # use ndarray::prelude::*;
149
+ /// # let arr = Array::from_shape_vec((2, 2), vec![1, 2, 3, 4]).unwrap();
150
+ /// # let owned = {
151
+ /// Array::from_shape_vec(arr.raw_dim().f(), arr.t().iter().cloned().collect()).unwrap()
152
+ /// # };
153
+ /// # assert!(owned.t().is_standard_layout());
154
+ /// # assert_eq!(arr, owned);
155
+ /// ```
128
156
pub fn to_owned ( & self ) -> Array < A , D >
129
157
where A : Clone
130
158
{
0 commit comments