UNPKG

@stdlib/array

Version:
45 lines (34 loc) 1.24 kB
{{alias}}( length[, dtype] ) Returns an array filled with ones and having a specified length. The function supports the following data types: - float64: double-precision floating-point numbers (IEEE 754). - float32: single-precision floating-point numbers (IEEE 754). - complex128: double-precision complex floating-point numbers. - complex64: single-precision complex floating-point numbers. - int32: 32-bit two's complement signed integers. - uint32: 32-bit unsigned integers. - int16: 16-bit two's complement signed integers. - uint16: 16-bit unsigned integers. - int8: 8-bit two's complement signed integers. - uint8: 8-bit unsigned integers. - uint8c: 8-bit unsigned integers clamped to 0-255. - generic: generic JavaScript values. The default array data type is `float64`. Parameters ---------- length: integer Array length. dtype: string (optional) Data type. Default: 'float64'. Returns ------- out: TypedArray|Array Output array. Examples -------- > var arr = {{alias}}( 2 ) <Float64Array>[ 1.0, 1.0 ] > arr = {{alias}}( 2, 'float32' ) <Float32Array>[ 1.0, 1.0 ] See Also --------