Skip to content

Latest commit

 

History

History
125 lines (78 loc) · 2.96 KB

File metadata and controls

125 lines (78 loc) · 2.96 KB

zscal

Multiply a one-dimensional double-precision complex floating-point ndarray by a scalar constant.

Usage

var zscal = require( '@stdlib/blas/base/ndarray/zscal' );

zscal( arrays )

Multiplies a one-dimensional double-precision complex floating-point ndarray by a scalar constant.

var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );

var x = new Complex128Vector( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );

var alpha = scalar2ndarray( new Complex128( 2.0, 0.0 ), {
    'dtype': 'complex128'
});

var y = zscal( [ x, alpha ] );
// returns <ndarray>[ <Complex128>[ 2.0, 4.0 ], <Complex128>[ 6.0, 8.0 ], <Complex128>[ 10.0, 12.0 ] ]

var bool = ( y === x );
// returns true

The function has the following parameters:

  • arrays: array-like object containing the following ndarrays:

    • a one-dimensional input ndarray.
    • a zero-dimensional ndarray containing a scalar constant.

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var zscal = require( '@stdlib/blas/base/ndarray/zscal' );

var opts = {
    'dtype': 'float64'
};

var x = new Complex128Vector( discreteUniform( 10, 0, 100, opts ) );
console.log( ndarray2array( x ) );

var alpha = scalar2ndarray( new Complex128( 2.0, 0.0 ), {
    'dtype': 'complex128'
});

var out = zscal( [ x, alpha ] );
console.log( ndarray2array( out ) );