repl.txt (3563B)
1 2 {{alias}}( [dtype] ) 3 Creates a filled array. 4 5 The function supports the following data types: 6 7 - float64: double-precision floating-point numbers (IEEE 754) 8 - float32: single-precision floating-point numbers (IEEE 754) 9 - int32: 32-bit two's complement signed integers 10 - uint32: 32-bit unsigned integers 11 - int16: 16-bit two's complement signed integers 12 - uint16: 16-bit unsigned integers 13 - int8: 8-bit two's complement signed integers 14 - uint8: 8-bit unsigned integers 15 - uint8c: 8-bit unsigned integers clamped to 0-255 16 - generic: generic JavaScript values 17 18 The default array data type is `float64`. 19 20 Parameters 21 ---------- 22 dtype: string (optional) 23 Data type. Default: 'float64'. 24 25 Returns 26 ------- 27 out: TypedArray|Array 28 Output array. 29 30 Examples 31 -------- 32 > var arr = {{alias}}() 33 <Float64Array> 34 > arr = {{alias}}( 'float32' ) 35 <Float32Array> 36 37 38 {{alias}}( value, length[, dtype] ) 39 Returns a filled array having a specified length. 40 41 Parameters 42 ---------- 43 value: any 44 Fill value. 45 46 length: integer 47 Array length. 48 49 dtype: string (optional) 50 Data type. Default: 'float64'. 51 52 Returns 53 ------- 54 out: TypedArray|Array 55 Output array. 56 57 Examples 58 -------- 59 > var arr = {{alias}}( 1.0, 5 ) 60 <Float64Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ] 61 > arr = {{alias}}( 1, 5, 'int32' ) 62 <Int32Array>[ 1, 1, 1, 1, 1 ] 63 64 65 {{alias}}( value, array[, dtype] ) 66 Creates a filled array from another array (or array-like object). 67 68 Parameters 69 ---------- 70 value: any 71 Fill value. 72 73 array: ArrayLikeObject 74 Array from which to generate another array. 75 76 dtype: string (optional) 77 Data type. Default: 'float64'. 78 79 Returns 80 ------- 81 out: TypedArray|Array 82 Output array. 83 84 Examples 85 -------- 86 > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) 87 <Float64Array>[ 2.0, 2.0, 2.0 ] 88 > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) 89 <Float32Array>[ 1.0, 1.0, 1.0 ] 90 91 92 {{alias}}( value, iterable[, dtype] ) 93 Creates a filled array from an iterable. 94 95 Parameters 96 ---------- 97 value: any 98 Fill value. 99 100 iterable: Object 101 Iterable from which to generate an array. 102 103 dtype: string (optional) 104 Data type. Default: 'float64'. 105 106 Returns 107 ------- 108 out: TypedArray|Array 109 Output array. 110 111 Examples 112 -------- 113 > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); 114 > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) 115 <Float32Array>[ 1.0, 1.0, 1.0 ] 116 117 118 {{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) 119 Returns a filled typed array view of an ArrayBuffer. 120 121 The 'generic' array data type is *not* supported. 122 123 Parameters 124 ---------- 125 value: any 126 Fill value. 127 128 buffer: ArrayBuffer 129 Underlying ArrayBuffer. 130 131 byteOffset: integer (optional) 132 Integer byte offset specifying the location of the first typed array 133 element. Default: 0. 134 135 length: integer (optional) 136 View length. If not provided, the view spans from the byteOffset to 137 the end of the underlying ArrayBuffer. 138 139 dtype: string (optional) 140 Data type. Default: 'float64'. 141 142 Returns 143 ------- 144 out: TypedArray 145 A typed array. 146 147 Examples 148 -------- 149 > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); 150 > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) 151 <Float32Array>[ 1.0, 1.0, 1.0, 1.0 ] 152 153 See Also 154 -------- 155