repl.txt (2967B)
1 2 {{alias}}( arrays, shape, strides, fcn ) 3 Applies a binary callback to strided input array elements and assigns 4 results to elements in a strided output array. 5 6 The `shape` and `strides` parameters determine which elements in the strided 7 input and output arrays are accessed at runtime. 8 9 Indexing is relative to the first index. To introduce an offset, use typed 10 array views. 11 12 Parameters 13 ---------- 14 arrays: ArrayLikeObject<ArrayLikeObject> 15 Array-like object containing two strided input arrays and one strided 16 output array. 17 18 shape: ArrayLikeObject<integer> 19 Array-like object containing a single element, the number of indexed 20 elements. 21 22 strides: ArrayLikeObject<integer> 23 Array-like object containing the stride lengths for the strided input 24 and output arrays. 25 26 fcn: Function 27 Binary callback. 28 29 Examples 30 -------- 31 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 32 > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 33 > var z = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 34 > var shape = [ x.length ]; 35 > var strides = [ 1, 1, 1 ]; 36 > function f( x, y ) { return x + y; }; 37 > {{alias}}( [ x, y, z ], shape, strides, f ); 38 > z 39 <Float64Array>[ 2.0, 4.0, 6.0, 8.0 ] 40 41 42 {{alias}}.ndarray( arrays, shape, strides, offsets, fcn ) 43 Applies a binary callback to strided input array elements and assigns 44 results to elements in a strided output array using alternative indexing 45 semantics. 46 47 While typed array views mandate a view offset based on the underlying 48 buffer, the `offsets` parameter supports indexing semantics based on 49 starting indices. 50 51 Parameters 52 ---------- 53 arrays: ArrayLikeObject<ArrayLikeObject> 54 Array-like object containing two strided input arrays and one strided 55 output array. 56 57 shape: ArrayLikeObject<integer> 58 Array-like object containing a single element, the number of indexed 59 elements. 60 61 strides: ArrayLikeObject<integer> 62 Array-like object containing the stride lengths for the strided input 63 and output arrays. 64 65 offsets: ArrayLikeObject<integer> 66 Array-like object containing the starting indices (i.e., index offsets) 67 for the strided input and output arrays. 68 69 fcn: Function 70 Binary callback. 71 72 Examples 73 -------- 74 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 75 > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 76 > var z = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 77 > var shape = [ x.length ]; 78 > var strides = [ 1, 1, 1 ]; 79 > var offsets = [ 0, 0, 0 ]; 80 > function f( x, y ) { return x + y; }; 81 > {{alias}}.ndarray( [ x, y, z ], shape, strides, offsets, f ); 82 > z 83 <Float64Array>[ 2.0, 4.0, 6.0, 8.0 ] 84 85 See Also 86 -------- 87