@@ -124,7 +124,36 @@ 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
+ /// If the input array is contiguous and its strides are positive, then the
130
+ /// output array will have the same memory layout. Otherwise, the layout of
131
+ /// the output array is unspecified. If you need a particular layout, you
132
+ /// can allocate a new array with the desired memory layout and
133
+ /// [`.assign()`](#method.assign) the data. Alternatively, you can collect
134
+ /// an iterator, like this for a result in standard layout:
135
+ ///
136
+ /// ```
137
+ /// # use ndarray::prelude::*;
138
+ /// # let arr = Array::from_shape_vec((2, 2).f(), vec![1, 2, 3, 4]).unwrap();
139
+ /// # let owned = {
140
+ /// Array::from_shape_vec(arr.raw_dim(), arr.iter().cloned().collect()).unwrap()
141
+ /// # };
142
+ /// # assert!(owned.is_standard_layout());
143
+ /// # assert_eq!(arr, owned);
144
+ /// ```
145
+ ///
146
+ /// or this for a result in column-major (Fortran) layout:
147
+ ///
148
+ /// ```
149
+ /// # use ndarray::prelude::*;
150
+ /// # let arr = Array::from_shape_vec((2, 2), vec![1, 2, 3, 4]).unwrap();
151
+ /// # let owned = {
152
+ /// Array::from_shape_vec(arr.raw_dim().f(), arr.t().iter().cloned().collect()).unwrap()
153
+ /// # };
154
+ /// # assert!(owned.t().is_standard_layout());
155
+ /// # assert_eq!(arr, owned);
156
+ /// ```
128
157
pub fn to_owned ( & self ) -> Array < A , D >
129
158
where A : Clone
130
159
{
0 commit comments