File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,23 @@ where
335
335
}
336
336
}
337
337
338
+ /// Create an array with values created by the function `f`.
339
+ ///
340
+ /// `f` is called with the *linear index* (one dimensional) of the element
341
+ /// to create; the elements are visited in memory order.
342
+ ///
343
+ /// **Panics** if the product of non-zero axis lengths overflows `isize`.
344
+ pub fn from_shape_fn_memory_order < Sh , F > ( shape : Sh , f : F ) -> Self
345
+ where
346
+ Sh : ShapeBuilder < Dim = D > ,
347
+ F : FnMut ( usize ) -> A ,
348
+ {
349
+ let shape = shape. into_shape ( ) ;
350
+ let len = size_of_shape_checked_unwrap ! ( & shape. dim) ;
351
+ let v = to_vec_mapped ( 0 ..len, f) ;
352
+ unsafe { Self :: from_shape_vec_unchecked ( shape, v) }
353
+ }
354
+
338
355
/// Create an array with the given shape from a vector. (No cloning of
339
356
/// elements needed.)
340
357
///
You can’t perform that action at this time.
0 commit comments