repl.txt (2614B)
1 2 {{alias}}( N, x, stride ) 3 Computes the sum of absolute values (L1 norm) of double-precision floating- 4 point strided array elements, ignoring `NaN` values and using ordinary 5 recursive summation. 6 7 The `N` and `stride` parameters determine which elements in `x` are accessed 8 at runtime. 9 10 Indexing is relative to the first index. To introduce an offset, use a typed 11 array view. 12 13 If `N <= 0`, the function returns `0.0`. 14 15 Parameters 16 ---------- 17 N: integer 18 Number of indexed elements. 19 20 x: Float64Array 21 Input array. 22 23 stride: integer 24 Index increment. 25 26 Returns 27 ------- 28 out: number 29 Sum. 30 31 Examples 32 -------- 33 // Standard Usage: 34 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); 35 > {{alias}}( x.length, x, 1 ) 36 5.0 37 38 // Using `N` and `stride` parameters: 39 > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] ); 40 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 41 > var stride = 2; 42 > {{alias}}( N, x, stride ) 43 5.0 44 45 // Using view offsets: 46 > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); 47 > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); 48 > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); 49 > stride = 2; 50 > {{alias}}( N, x1, stride ) 51 5.0 52 53 {{alias}}.ndarray( N, x, stride, offset ) 54 Computes the sum of absolute values (L1 norm) of double-precision floating- 55 point strided array elements, ignoring `NaN` values and using ordinary 56 recursive summation alternative indexing semantics. 57 58 While typed array views mandate a view offset based on the underlying 59 buffer, the `offset` parameter supports indexing semantics based on a 60 starting index. 61 62 Parameters 63 ---------- 64 N: integer 65 Number of indexed elements. 66 67 x: Float64Array 68 Input array. 69 70 stride: integer 71 Index increment. 72 73 offset: integer 74 Starting index. 75 76 Returns 77 ------- 78 out: number 79 Sum. 80 81 Examples 82 -------- 83 // Standard Usage: 84 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); 85 > {{alias}}.ndarray( x.length, x, 1, 0 ) 86 5.0 87 88 // Using offset parameter: 89 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); 90 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 91 > {{alias}}.ndarray( N, x, 2, 1 ) 92 5.0 93 94 See Also 95 -------- 96