1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
{{alias}}( [dtype] )
Creates a typed 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
The default typed array data type is `float64`.
Parameters
----------
dtype: string (optional)
Data type. Default: 'float64'.
Returns
-------
out: TypedArray
A typed array.
Examples
--------
> var arr = {{alias}}()
<Float64Array>
> arr = {{alias}}( 'float32' )
<Float32Array>
{{alias}}( length[, dtype] )
Returns a typed array having a specified length.
Parameters
----------
length: integer
Typed array length.
dtype: string (optional)
Data type. Default: 'float64'.
Returns
-------
out: TypedArray
A typed array.
Examples
--------
> var arr = {{alias}}( 5 )
<Float64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0 ]
> arr = {{alias}}( 5, 'int32' )
<Int32Array>[ 0, 0, 0, 0, 0 ]
{{alias}}( typedarray[, dtype] )
Creates a typed array from another typed array.
Parameters
----------
typedarray: TypedArray
Typed array from which to generate another typed array.
dtype: string (optional)
Data type. Default: 'float64'.
Returns
-------
out: TypedArray
A typed array.
Examples
--------
> var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] );
> var arr2 = {{alias}}( arr1, 'float32' )
<Float32Array>[ 0.5, 0.5, 0.5 ]
{{alias}}( obj[, dtype] )
Creates a typed array from an array-like object or iterable.
Parameters
----------
obj: Object
Array-like object or iterable from which to generate a typed array.
dtype: string (optional)
Data type. Default: 'float64'.
Returns
-------
out: TypedArray
A typed array.
Examples
--------
> var arr1 = [ 0.5, 0.5, 0.5 ];
> var arr2 = {{alias}}( arr1, 'float32' )
<Float32Array>[ 0.5, 0.5, 0.5 ]
{{alias}}( buffer[, byteOffset[, length]][, dtype] )
Returns a typed array view of an ArrayBuffer.
Parameters
----------
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}}( buf, 0, 4, 'float32' )
<Float32Array>[ 0.0, 0.0, 0.0, 0.0 ]
See Also
--------
|