repl.txt (3524B)
1 2 {{alias}}( N, x, strideX, out, strideOut ) 3 Computes the sum of double-precision floating-point strided array elements, 4 ignoring `NaN` values and using an improved Kahan–Babuška algorithm. 5 6 The `N` and `stride` parameters determine which elements are accessed at 7 runtime. 8 9 Indexing is relative to the first index. To introduce an offset, use a typed 10 array view. 11 12 If `N <= 0`, the function returns a sum equal to `0.0`. 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 out: Float64Array 26 Output array. 27 28 strideOut: integer 29 Index increment for `out`. 30 31 Returns 32 ------- 33 out: Float64Array 34 Output array whose first element is the sum and whose second element is 35 the number of non-NaN elements. 36 37 Examples 38 -------- 39 // Standard Usage: 40 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); 41 > var out = new {{alias:@stdlib/array/float64}}( 2 ); 42 > {{alias}}( x.length, x, 1, out, 1 ) 43 <Float64Array>[ 1.0, 3 ] 44 45 // Using `N` and `stride` parameters: 46 > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] ); 47 > out = new {{alias:@stdlib/array/float64}}( 2 ); 48 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 49 > {{alias}}( N, x, 2, out, 1 ) 50 <Float64Array>[ 1.0, 3 ] 51 52 // Using view offsets: 53 > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0, NaN, NaN ] ); 54 > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); 55 > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); 56 > out = new {{alias:@stdlib/array/float64}}( 2 ); 57 > {{alias}}( N, x1, 2, out, 1 ) 58 <Float64Array>[ 1.0, 3 ] 59 60 {{alias}}.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut ) 61 Computes the sum of double-precision floating-point strided array elements, 62 ignoring `NaN` values and using an improved Kahan–Babuška algorithm and 63 alternative indexing semantics. 64 65 While typed array views mandate a view offset based on the underlying 66 buffer, the `offset` parameter supports indexing semantics based on a 67 starting index. 68 69 Parameters 70 ---------- 71 N: integer 72 Number of indexed elements. 73 74 x: Float64Array 75 Input array. 76 77 strideX: integer 78 Index increment for `x`. 79 80 offsetX: integer 81 Starting index for `x`. 82 83 out: Float64Array 84 Output array. 85 86 strideOut: integer 87 Index increment for `out`. 88 89 offsetOut: integer 90 Starting index for `out`. 91 92 Returns 93 ------- 94 out: Float64Array 95 Output array whose first element is the sum and whose second element is 96 the number of non-NaN elements. 97 98 Examples 99 -------- 100 // Standard Usage: 101 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); 102 > var out = new {{alias:@stdlib/array/float64}}( 2 ); 103 > {{alias}}.ndarray( x.length, x, 1, 0, out, 1, 0 ) 104 <Float64Array>[ 1.0, 3 ] 105 106 // Using offset parameter: 107 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0, NaN, NaN ] ); 108 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 109 > out = new {{alias:@stdlib/array/float64}}( 2 ); 110 > {{alias}}.ndarray( N, x, 2, 1, out, 1, 0 ) 111 <Float64Array>[ 1.0, 3 ] 112 113 See Also 114 -------- 115