|
1 | 1 |
|
2 | | -{{alias}}( x, [ options, ]fcn[, thisArg] ) |
| 2 | +{{alias}}( x[, options], fcn[, thisArg] ) |
3 | 3 | Applies a callback function to elements in an input ndarray and assigns |
4 | | - results to elements in an output ndarray. |
5 | | - |
6 | | - The function accepts the following options: |
7 | | - |
8 | | - - dtype: output ndarray data type. Defaults to match the input ndarray |
9 | | - if not specified. |
| 4 | + results to elements in a new output ndarray. |
10 | 5 |
|
11 | 6 | The callback function is provided the following arguments: |
12 | 7 |
|
|
22 | 17 | options: Object (optional) |
23 | 18 | Function options. |
24 | 19 |
|
| 20 | + options.dtype: string (optional) |
| 21 | + Output ndarray data type. Overrides using the input array's inferred |
| 22 | + data type. |
| 23 | + |
25 | 24 | fcn: Function |
26 | 25 | Callback function. |
27 | 26 |
|
|
30 | 29 |
|
31 | 30 | Examples |
32 | 31 | -------- |
33 | | - // Define ndarray data and meta data... |
34 | | - > var buffer = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); |
35 | | - > var dtype = 'float64'; |
36 | | - > var shape = [ 2, 2 ]; |
37 | | - > var strides = [ 2, 1 ]; |
38 | | - > var offset = 0; |
39 | | - > var order = 'row-major'; |
40 | | - |
41 | | - // Define a callback function: |
| 32 | + > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); |
42 | 33 | > function f( v ) { return v*10.0; }; |
43 | | - |
44 | | - // Using ndarray... |
45 | | - > var x = {{alias:@stdlib/ndarray/ctor}}( dtype, buffer, shape, strides, offset, order ); |
46 | 34 | > var y = {{alias}}( x, f ); |
47 | | - > y.data |
48 | | - <Float64Array>[ 10.0, 20.0, 30.0, 40.0 ] |
| 35 | + > {{alias:@stdlib/ndarray/to-array}}( y ) |
| 36 | + [ [ 10.0, 20.0 ], [ 30.0, 40.0 ] ] |
49 | 37 |
|
50 | 38 | See Also |
51 | 39 | -------- |
0 commit comments