repl.txt (2482B)
1 2 {{alias}}( shape, idx[, options] ) 3 Converts a linear index to an array of subscripts. 4 5 Parameters 6 ---------- 7 shape: ArrayLike 8 Array shape. 9 10 idx: integer 11 Linear index. 12 13 options: Object (optional) 14 Options. 15 16 options.order: string (optional) 17 Specifies whether an array is row-major (C-style) or column-major 18 (Fortran style). Default: 'row-major'. 19 20 options.mode: string (optional) 21 Specifies how to handle a linear index which exceeds array dimensions. 22 If equal to 'throw', the function throws an error when a linear index 23 exceeds array dimensions. If equal to 'wrap', the function wraps around 24 a linear index exceeding array dimensions using modulo arithmetic. If 25 equal to 'clamp', the function sets a linear index exceeding array 26 dimensions to either `0` (minimum linear index) or the maximum linear 27 index. Default: 'throw'. 28 29 Returns 30 ------- 31 out: Array<integer> 32 Subscripts. 33 34 Examples 35 -------- 36 > var d = [ 3, 3, 3 ]; 37 > var s = {{alias}}( d, 17 ) 38 [ 1, 2, 2 ] 39 40 41 {{alias}}.assign( shape, idx[, options], out ) 42 Converts a linear index to an array of subscripts and assigns results to a 43 provided output array. 44 45 Parameters 46 ---------- 47 shape: ArrayLike 48 Array shape. 49 50 idx: integer 51 Linear index. 52 53 options: Object (optional) 54 Options. 55 56 options.order: string (optional) 57 Specifies whether an array is row-major (C-style) or column-major 58 (Fortran style). Default: 'row-major'. 59 60 options.mode: string (optional) 61 Specifies how to handle a linear index which exceeds array dimensions. 62 If equal to 'throw', the function throws an error when a linear index 63 exceeds array dimensions. If equal to 'wrap', the function wraps around 64 a linear index exceeding array dimensions using modulo arithmetic. If 65 equal to 'clamp', the function sets a linear index exceeding array 66 dimensions to either `0` (minimum linear index) or the maximum linear 67 index. Default: 'throw'. 68 69 out: Array|TypedArray|Object 70 Output array. 71 72 Returns 73 ------- 74 out: Array|TypedArray|Object 75 Subscripts. 76 77 Examples 78 -------- 79 > var d = [ 3, 3, 3 ]; 80 > var out = [ 0, 0, 0 ]; 81 > var s = {{alias}}.assign( d, 17, out ) 82 [ 1, 2, 2 ] 83 > var bool = ( s === out ) 84 true 85 86 See Also 87 -------- 88