Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "array/filled/docs/types/index.d"

Index

Type aliases

Functions

Type aliases

ArrayOrTypedArray

ArrayOrTypedArray: Array<any> | RealOrComplexTypedArray

Array or typed array.

Functions

Export assignment filledarray

  • Creates a filled array.

    The function recognizes 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

    Parameters

    • Optional dtype: DataType

      data type (default: 'float64')

    Returns ArrayOrTypedArray

    filled array

    Example

    var arr = filledarray();
    // returns <Float64Array>

    Example

    var arr = filledarray( 'float32' );
    // returns <Float32Array>
  • Creates a filled array having a specified length.

    Parameters

    • value: any

      fill value

    • length: number

      array length

    • Optional dtype: DataType

      data type (default: 'float64')

    Returns ArrayOrTypedArray

    filled array

    Example

    var arr = filledarray( 1.0, 5 );
    // returns <Float64Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ]

    Example

    var arr = filledarray( 1.0, 5, 'float32' );
    // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ]
  • Creates a filled array from another array.

    Parameters

    • value: any

      fill value

    • array: Collection

      typed array or array-like object

    • Optional dtype: DataType

      data type (default: 'float64')

    Returns ArrayOrTypedArray

    filled array

    Example

    var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] );
    // returns <Float64Array>[ 1.0, 1.0, 1.0 ]

    Example

    var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' );
    // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
  • Creates a filled array from an iterable.

    Parameters

    Returns ArrayOrTypedArray

    filled array

    Example

    var iterConstant = require( `@stdlib/iter/constant` );
    
    var it = iterConstant( 3.0, {
        'iter': 3
    });
    var arr = filledarray( 1.0, it );
    // returns <Float64Array>[ 1.0, 1.0, 1.0 ]

    Example

    var iterConstant = require( `@stdlib/iter/constant` );
    
    var it = iterConstant( 3.0, {
        'iter': 3
    });
    var arr = filledarray( 1.0, it, 'float32' );
    // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
  • Returns a filled typed array view of an ArrayBuffer.

    Notes

    • Creating a generic array from an ArrayBuffer is not supported.

    Parameters

    • value: any

      fill value

    • buffer: ArrayBuffer

      ArrayBuffer

    • byteOffset: number

      byte offset

    • length: number

      view length

    • Optional dtype: DataType

      data type (default: 'float64')

    Returns RealOrComplexTypedArray

    filled array

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    
    var buf = new ArrayBuffer( 32 );
    var arr = filledarray( 1.0, buf, 8, 2 );
    // returns <Float64Array>[ 1.0, 1.0 ]

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    
    var buf = new ArrayBuffer( 32 );
    var arr = filledarray( 1.0, buf, 8, 2, 'float32' );
    // returns <Float32Array>[ 1.0, 1.0 ]
  • Returns a filled typed array view of an ArrayBuffer.

    Notes

    • Creating a generic array from an ArrayBuffer is not supported.

    Parameters

    • value: any

      fill value

    • buffer: ArrayBuffer

      ArrayBuffer

    • byteOffset: number

      byte offset

    • Optional dtype: DataType

      data type (default: 'float64')

    Returns RealOrComplexTypedArray

    filled array

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    
    var buf = new ArrayBuffer( 32 );
    var arr = filledarray( 1.0, buf, 8 );
    // returns <Float64Array>[ 1.0, 1.0, 1.0 ]

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    
    var buf = new ArrayBuffer( 32 );
    var arr = filledarray( 1.0, buf, 8, 'float32' );
    // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
  • Returns a filled typed array view of an ArrayBuffer.

    Notes

    • Creating a generic array from an ArrayBuffer is not supported.

    Parameters

    • value: any

      fill value

    • buffer: ArrayBuffer

      ArrayBuffer

    • Optional dtype: DataType

      data type (default: 'float64')

    Returns RealOrComplexTypedArray

    filled array

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    
    var buf = new ArrayBuffer( 32 );
    var arr = filledarray( 1.0, buf );
    // returns <Float64Array>[ 1.0, 1.0, 1.0, 1.0 ]

    Example

    var ArrayBuffer = require( `@stdlib/array/buffer` );
    
    var buf = new ArrayBuffer( 32 );
    var arr = filledarray( 1.0, buf, 'float32' );
    // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]