|
| 1 | + |
| 2 | +{{alias}}( arrays, fcn ) |
| 3 | + Applies a unary callback to elements in an input ndarray and assigns results |
| 4 | + to elements in an output ndarray. |
| 5 | + |
| 6 | + Each provided "ndarray" should be an `object` with the following properties: |
| 7 | + |
| 8 | + - dtype: data type. |
| 9 | + - data: data buffer. |
| 10 | + - shape: dimensions. |
| 11 | + - strides: stride lengths. |
| 12 | + - offset: index offset. |
| 13 | + - order: specifies whether an ndarray is row-major (C-style) or column- |
| 14 | + major (Fortran-style). |
| 15 | + |
| 16 | + Parameters |
| 17 | + ---------- |
| 18 | + arrays: ArrayLikeObject<ndarray> |
| 19 | + Array-like object containing one input ndarray and one output array. |
| 20 | + |
| 21 | + fcn: Function |
| 22 | + Unary callback. |
| 23 | + |
| 24 | + Examples |
| 25 | + -------- |
| 26 | + // Define ndarray data and meta data... |
| 27 | + > var xbuf = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0, -3.0, -4.0 ] ); |
| 28 | + > var ybuf = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); |
| 29 | + > var dtype = 'float64'; |
| 30 | + > var shape = [ 2, 2 ]; |
| 31 | + > var sx = [ 2, 1 ]; |
| 32 | + > var sy = [ 2, 1 ]; |
| 33 | + > var ox = 0; |
| 34 | + > var oy = 0; |
| 35 | + > var order = 'row-major'; |
| 36 | + |
| 37 | + // Using ndarrays... |
| 38 | + > var x = {{alias:@stdlib/ndarray/ctor}}( dtype, xbuf, shape, sx, ox, order ); |
| 39 | + > var y = {{alias:@stdlib/ndarray/ctor}}( dtype, ybuf, shape, sy, oy, order ); |
| 40 | + > {{alias}}( [ x, y ], {{alias:@stdlib/math/base/special/abs}} ); |
| 41 | + > y.data |
| 42 | + <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ] |
| 43 | + |
| 44 | + // Using minimal ndarray-like objects... |
| 45 | + > x = { |
| 46 | + ... 'dtype': dtype, |
| 47 | + ... 'data': xbuf, |
| 48 | + ... 'shape': shape, |
| 49 | + ... 'strides': sx, |
| 50 | + ... 'offset': ox, |
| 51 | + ... 'order': order |
| 52 | + ... }; |
| 53 | + > y = { |
| 54 | + ... 'dtype': dtype, |
| 55 | + ... 'data': ybuf, |
| 56 | + ... 'shape': shape, |
| 57 | + ... 'strides': sy, |
| 58 | + ... 'offset': oy, |
| 59 | + ... 'order': order |
| 60 | + ... }; |
| 61 | + > {{alias}}( [ x, y ], {{alias:@stdlib/math/base/special/abs}} ); |
| 62 | + > y.data |
| 63 | + <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ] |
| 64 | + |
| 65 | + See Also |
| 66 | + -------- |
| 67 | + |
0 commit comments