repl.txt (2336B)
1 2 {{alias}}( N, x, stride ) 3 Computes the maximum value of a sorted strided array. 4 5 The input strided array must be sorted in either strictly ascending or 6 descending order. 7 8 The `N` and `stride` parameters determine which elements in `x` are accessed 9 at runtime. 10 11 Indexing is relative to the first index. To introduce an offset, use a typed 12 array view. 13 14 If `N <= 0`, the function returns `NaN`. 15 16 Parameters 17 ---------- 18 N: integer 19 Number of indexed elements. 20 21 x: Array<number>|TypedArray 22 Sorted input array. 23 24 stride: integer 25 Index increment. 26 27 Returns 28 ------- 29 out: number 30 Maximum value. 31 32 Examples 33 -------- 34 // Standard Usage: 35 > var x = [ 1.0, 2.0, 3.0 ]; 36 > {{alias}}( x.length, x, 1 ) 37 3.0 38 39 // Using `N` and `stride` parameters: 40 > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; 41 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 42 > var stride = 2; 43 > {{alias}}( N, x, stride ) 44 2.0 45 46 // Using view offsets: 47 > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 3.0 ] ); 48 > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); 49 > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); 50 > stride = 2; 51 > {{alias}}( N, x1, stride ) 52 3.0 53 54 {{alias}}.ndarray( N, x, stride, offset ) 55 Computes the maximum value of a sorted strided array using alternative 56 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: Array<number>|TypedArray 68 Sorted input array. 69 70 stride: integer 71 Index increment. 72 73 offset: integer 74 Starting index. 75 76 Returns 77 ------- 78 out: number 79 Maximum value. 80 81 Examples 82 -------- 83 // Standard Usage: 84 > var x = [ 1.0, 2.0, 3.0 ]; 85 > {{alias}}.ndarray( x.length, x, 1, 0 ) 86 3.0 87 88 // Using offset parameter: 89 > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, 3.0 ]; 90 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 91 > {{alias}}.ndarray( N, x, 2, 1 ) 92 3.0 93 94 See Also 95 -------- 96