repl.txt (3724B)
1 2 {{alias}}( shape, strides, offset, order, idx, mode ) 3 Converts a linear index to an array of subscripts. 4 5 When provided a stride array containing negative strides, if an `offset` is 6 greater than `0`, the function interprets the linear index as an index into 7 the underlying data buffer for the array, thus returning subscripts from the 8 perspective of that buffer. If an `offset` is equal to `0`, the function 9 treats the linear index as an index into an array view, thus returning 10 subscripts from the perspective of that view. In short, from the perspective 11 of a view, view data is always ordered. 12 13 Parameters 14 ---------- 15 shape: ArrayLike 16 Array shape. 17 18 strides: ArrayLike 19 Stride array. 20 21 offset: integer 22 Location of the first indexed value based on the stride array. 23 24 order: string 25 Specifies whether an array is row-major (C-style) or column-major 26 (Fortran-style). 27 28 idx: integer 29 Linear index. 30 31 mode: string 32 Specifies how to handle a linear index which exceeds array dimensions. 33 If equal to 'throw', the function throws an error when a linear index 34 exceeds array dimensions. If equal to 'wrap', the function wraps around 35 a linear index exceeding array dimensions using modulo arithmetic. If 36 equal to 'clamp', the function sets a linear index exceeding array 37 dimensions to either `0` (minimum linear index) or the maximum linear 38 index. Default: 'throw'. 39 40 Returns 41 ------- 42 out: Array 43 Subscripts. 44 45 Examples 46 -------- 47 > var d = [ 3, 3, 3 ]; 48 > var s = [ 9, 3, 1 ]; 49 > var out = {{alias}}( d, s, 0, 'row-major', 17, 'throw' ) 50 [ 1, 2, 2 ] 51 52 53 {{alias}}.assign( shape, strides, offset, order, idx, mode, out ) 54 Converts a linear index to an array of subscripts and assigns results to a 55 provided output array. 56 57 When provided a stride array containing negative strides, if an `offset` is 58 greater than `0`, the function interprets the linear index as an index into 59 the underlying data buffer for the array, thus returning subscripts from the 60 perspective of that buffer. If an `offset` is equal to `0`, the function 61 treats the linear index as an index into an array view, thus returning 62 subscripts from the perspective of that view. In short, from the perspective 63 of a view, view data is always ordered. 64 65 Parameters 66 ---------- 67 shape: ArrayLike 68 Array shape. 69 70 strides: ArrayLike 71 Stride array. 72 73 offset: integer 74 Location of the first indexed value based on the stride array. 75 76 order: string 77 Specifies whether an array is row-major (C-style) or column-major 78 (Fortran-style). 79 80 idx: integer 81 Linear index. 82 83 mode: string 84 Specifies how to handle a linear index which exceeds array dimensions. 85 If equal to 'throw', the function throws an error when a linear index 86 exceeds array dimensions. If equal to 'wrap', the function wraps around 87 a linear index exceeding array dimensions using modulo arithmetic. If 88 equal to 'clamp', the function sets a linear index exceeding array 89 dimensions to either `0` (minimum linear index) or the maximum linear 90 index. Default: 'throw'. 91 92 out: Array|TypedArray|Object 93 Output object. 94 95 Returns 96 ------- 97 out: Array|TypedArray|Object 98 Subscripts. 99 100 Examples 101 -------- 102 > var d = [ 3, 3, 3 ]; 103 > var s = [ 9, 3, 1 ]; 104 > var out = [ 0, 0, 0 ]; 105 > var sub = {{alias}}.assign( d, s, 0, 'row-major', 17, 'throw', out ) 106 [ 1, 2, 2 ] 107 > var bool = ( sub === out ) 108 true 109 110 See Also 111 -------- 112