Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

dscal

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

Usage

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

dscal( arrays )

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

var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );

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

var alpha = scalar2ndarray( 5.0, {
    'dtype': 'float64'
});

var y = dscal( [ x, alpha ] );
// returns <ndarray>[ 5.0, 10.0, 15.0, 20.0, 25.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/discrete-uniform' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var dscal = require( '@stdlib/blas/base/ndarray/dscal' );

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

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

var alpha = scalar2ndarray( 5.0, opts );

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