156 lines
3.5 KiB
Plaintext
156 lines
3.5 KiB
Plaintext
|
|
||
|
{{alias}}( [dtype] )
|
||
|
Creates a filled array.
|
||
|
|
||
|
The function supports the following data types:
|
||
|
|
||
|
- float64: double-precision floating-point numbers (IEEE 754)
|
||
|
- float32: single-precision floating-point numbers (IEEE 754)
|
||
|
- 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
|
||
|
----------
|
||
|
dtype: string (optional)
|
||
|
Data type. Default: 'float64'.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
out: TypedArray|Array
|
||
|
Output array.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var arr = {{alias}}()
|
||
|
<Float64Array>
|
||
|
> arr = {{alias}}( 'float32' )
|
||
|
<Float32Array>
|
||
|
|
||
|
|
||
|
{{alias}}( value, length[, dtype] )
|
||
|
Returns a filled array having a specified length.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
value: any
|
||
|
Fill value.
|
||
|
|
||
|
length: integer
|
||
|
Array length.
|
||
|
|
||
|
dtype: string (optional)
|
||
|
Data type. Default: 'float64'.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
out: TypedArray|Array
|
||
|
Output array.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var arr = {{alias}}( 1.0, 5 )
|
||
|
<Float64Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ]
|
||
|
> arr = {{alias}}( 1, 5, 'int32' )
|
||
|
<Int32Array>[ 1, 1, 1, 1, 1 ]
|
||
|
|
||
|
|
||
|
{{alias}}( value, array[, dtype] )
|
||
|
Creates a filled array from another array (or array-like object).
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
value: any
|
||
|
Fill value.
|
||
|
|
||
|
array: ArrayLikeObject
|
||
|
Array from which to generate another array.
|
||
|
|
||
|
dtype: string (optional)
|
||
|
Data type. Default: 'float64'.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
out: TypedArray|Array
|
||
|
Output array.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] )
|
||
|
<Float64Array>[ 2.0, 2.0, 2.0 ]
|
||
|
> var arr2 = {{alias}}( 1.0, arr1, 'float32' )
|
||
|
<Float32Array>[ 1.0, 1.0, 1.0 ]
|
||
|
|
||
|
|
||
|
{{alias}}( value, iterable[, dtype] )
|
||
|
Creates a filled array from an iterable.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
value: any
|
||
|
Fill value.
|
||
|
|
||
|
iterable: Object
|
||
|
Iterable from which to generate an array.
|
||
|
|
||
|
dtype: string (optional)
|
||
|
Data type. Default: 'float64'.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
out: TypedArray|Array
|
||
|
Output array.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} );
|
||
|
> var arr2 = {{alias}}( 1.0, arr1, 'float32' )
|
||
|
<Float32Array>[ 1.0, 1.0, 1.0 ]
|
||
|
|
||
|
|
||
|
{{alias}}( value, buffer[, byteOffset[, length]][, dtype] )
|
||
|
Returns a filled typed array view of an ArrayBuffer.
|
||
|
|
||
|
The 'generic' array data type is *not* supported.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
value: any
|
||
|
Fill value.
|
||
|
|
||
|
buffer: ArrayBuffer
|
||
|
Underlying ArrayBuffer.
|
||
|
|
||
|
byteOffset: integer (optional)
|
||
|
Integer byte offset specifying the location of the first typed array
|
||
|
element. Default: 0.
|
||
|
|
||
|
length: integer (optional)
|
||
|
View length. If not provided, the view spans from the byteOffset to
|
||
|
the end of the underlying ArrayBuffer.
|
||
|
|
||
|
dtype: string (optional)
|
||
|
Data type. Default: 'float64'.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
out: TypedArray
|
||
|
A typed array.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var buf = new {{alias:@stdlib/array/buffer}}( 16 );
|
||
|
> var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' )
|
||
|
<Float32Array>[ 1.0, 1.0, 1.0, 1.0 ]
|
||
|
|
||
|
See Also
|
||
|
--------
|
||
|
|