Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "ndarray/from-scalar/docs/types/index.d"

Index

Functions

scalar2ndarray

  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns float64ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1.0, {
        'dtype': 'float64'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'float64'
    
    var v = x.get();
    // returns 1.0
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns float32ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1.0, {
        'dtype': 'float32'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'float32'
    
    var v = x.get();
    // returns 1.0
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Notes

    • If provided a number, the function returns a zero-dimensional ndarray containing a complex number whose real component equals the provided scalar value and whose imaginary component is zero.

    Parameters

    Returns complex128ndarray

    zero-dimensional ndarray

    Example

    var Complex128 = require( '@stdlib/complex/float64/ctor' );
    var real = require( '@stdlib/complex/float64/real' );
    var imag = require( '@stdlib/complex/float64/imag' );
    
    var v = new Complex128( 1.0, 2.0 );
    
    var x = scalar2ndarray( v, {
        'dtype': 'complex128'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'complex128'
    
    var v = x.get();
    // returns <Complex128>
    
    var re = real( v );
    // returns 1.0
    
    var im = imag( v );
    // returns 2.0
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Notes

    • If provided a number, the function returns a zero-dimensional ndarray containing a complex number whose real component equals the provided scalar value and whose imaginary component is zero.

    Parameters

    Returns complex64ndarray

    zero-dimensional ndarray

    Example

    var Complex64 = require( '@stdlib/complex/float64/ctor' );
    var realf = require( '@stdlib/complex/float32/real' );
    var imagf = require( '@stdlib/complex/float32/imag' );
    
    var v = new Complex64( 1.0, 2.0 );
    
    var x = scalar2ndarray( v, {
        'dtype': 'complex64'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'complex64'
    
    var v = x.get();
    // returns <Complex64>
    
    var re = realf( v );
    // returns 1.0
    
    var im = imagf( v );
    // returns 2.0
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    • value: boolean

      scalar value

    • options: BoolOptions

      options

    Returns boolndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( true, {
        'dtype': bool'
    };
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'bool'
    
    var v = x.get();
    // returns true
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns int32ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': int32'
    };
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'int32'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns int16ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': int16'
    };
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'int16'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    • value: number

      scalar value

    • options: Int8Options

      options

    Returns int8ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': int8' )
    }
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'int8'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns uint32ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': uint32'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'uint32'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns uint16ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': uint16'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'uint16'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns uint8ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': uint8'
    };
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'uint8'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Parameters

    Returns uint8cndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1, {
        'dtype': uint8c'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'uint8c'
    
    var v = x.get();
    // returns 1
  • Returns a zero-dimensional ndarray containing a provided scalar value.

    Notes

    • If a dtype option is not provided and value

      • is a number, the default data type is the default real-valued floating-point data type.
      • is a boolean, the default data type is the default boolean data type.
      • is a complex number object of a known complex data type, the data type is the same as the provided value.
      • is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type.
      • is any other value type, the default data type is 'generic'.

    Parameters

    • value: any

      scalar value

    • Optional options: Options

      options

    Returns ndarray

    zero-dimensional ndarray

    Example

    var x = scalar2ndarray( 1.0, {
        'dtype': generic'
    });
    // returns <ndarray>
    
    var sh = x.shape;
    // returns []
    
    var dt = x.dtype;
    // returns 'generic'
    
    var v = x.get();
    // returns 1.0