Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "array/zeros-like/docs/types/index.d"

Index

Functions

Functions

Export assignment zerosLike

  • zerosLike(x: Array<any>): Array<number>
  • zerosLike<T>(x: T): T
  • zerosLike<T>(x: AnyArray, dtype: T): NumericAndGenericDataTypeMap<number>[T]
  • Creates a zero-filled array having the same length and data type as a provided input array.

    Parameters

    • x: Array<any>

      input array from which to derive the output array length

    Returns Array < number >

    zero-filled array

    Example

    var zeros = require( '@stdlib/array/zeros' );
    
    var x = zeros( 2, 'generic' );
    // returns [ 0, 0 ]
    
    var y = zerosLike( x );
    // returns [ 0, 0 ]
  • Creates a zero-filled array having the same length and data type as a provided input array.

    Type parameters

    Parameters

    • x: T

      input array from which to derive the output array length

    Returns T

    zero-filled array

    Example

    var zeros = require( '@stdlib/array/zeros' );
    
    var x = zeros( 2, 'float64' );
    // returns <Float64Array>[ 0.0, 0.0 ]
    
    var y = zerosLike( x );
    // returns <Float64Array>[ 0.0, 0.0 ]
  • Creates a zero-filled array having the same length as a provided input array.

    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

    Type parameters

    Parameters

    • x: AnyArray

      input array from which to derive the output array length

    • dtype: T

      data type

    Returns NumericAndGenericDataTypeMap < number > [ T ]

    zero-filled array

    Example

    var zeros = require( '@stdlib/array/zeros' );
    
    var x = zeros( 2, 'float64' );
    // returns <Float64Array>[ 0.0, 0.0 ]
    
    var y = zerosLike( x, 'float32' );
    // returns <Float32Array>[ 0.0, 0.0 ]