repl.txt (4008B)
1 2 {{alias}}( N, x, strideX, y, strideY, fcn ) 3 Applies a unary function accepting and returning double-precision floating- 4 point numbers to each element in a double-precision floating-point strided 5 input array and assigns each result to an element in a double-precision 6 floating-point strided output array. 7 8 The `N` and `stride` parameters determine which elements in `x` and `y` are 9 accessed at runtime. 10 11 Indexing is relative to the first index. To introduce an offset, use typed 12 array views. 13 14 Parameters 15 ---------- 16 N: integer 17 Number of indexed elements. 18 19 x: Float64Array 20 Input array. 21 22 strideX: integer 23 Index increment for `x`. 24 25 y: Float64Array 26 Destination array. 27 28 strideY: integer 29 Index increment for `y`. 30 31 fcn: Function 32 Unary function to apply. 33 34 Returns 35 ------- 36 y: Float64Array 37 Input array `y`. 38 39 Examples 40 -------- 41 // Standard usage: 42 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 43 > var y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 44 > {{alias}}( x.length, x, 1, y, 1, {{alias:@stdlib/math/base/special/identity}} ) 45 <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ] 46 47 // Using `N` and `stride` parameters: 48 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 49 > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 50 > {{alias}}( N, x, 2, y, -1, {{alias:@stdlib/math/base/special/identity}} ) 51 <Float64Array>[ 3.0, 1.0, 0.0, 0.0 ] 52 53 // Using view offsets: 54 > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 55 > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 56 > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); 57 > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); 58 > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); 59 > {{alias}}( N, x1, -2, y1, 1, {{alias:@stdlib/math/base/special/identity}} ) 60 <Float64Array>[ 4.0, 2.0 ] 61 > y0 62 <Float64Array>[ 0.0, 0.0, 4.0, 2.0 ] 63 64 65 {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, fcn ) 66 Applies a unary function accepting and returning double-precision floating- 67 point numbers to each element in a double-precision floating-point strided 68 input array and assigns each result to an element in a double-precision 69 floating-point strided output array using alternative indexing semantics. 70 71 While typed array views mandate a view offset based on the underlying 72 buffer, the `offsetX` and `offsetY` parameters support indexing semantics 73 based on starting indices. 74 75 Parameters 76 ---------- 77 N: integer 78 Number of indexed elements. 79 80 x: Float64Array 81 Input array. 82 83 strideX: integer 84 Index increment for `x`. 85 86 offsetX: integer 87 Starting index for `x`. 88 89 y: Float64Array 90 Destination array. 91 92 strideY: integer 93 Index increment for `y`. 94 95 offsetY: integer 96 Starting index for `y`. 97 98 fcn: Function 99 Unary function to apply. 100 101 Returns 102 ------- 103 y: Float64Array 104 Input array `y`. 105 106 Examples 107 -------- 108 // Standard usage: 109 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 110 > var y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 111 > {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0, {{alias:@stdlib/math/base/special/identity}} ) 112 <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ] 113 114 // Advanced indexing: 115 > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); 116 > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); 117 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 118 > {{alias}}.ndarray( N, x, 2, 1, y, -1, y.length-1, {{alias:@stdlib/math/base/special/identity}} ) 119 <Float64Array>[ 0.0, 0.0, 4.0, 2.0 ] 120 121 See Also 122 -------- 123