Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

zaxpy

Multiply a one-dimensional double-precision complex floating-point ndarray x by a constant alpha and add the result to a one-dimensional double-precision complex floating-point ndarray y.

Usage

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

zaxpy( arrays )

Multiplies a one-dimensional double-precision complex floating-point ndarray x by a constant alpha and adds the result to a one-dimensional double-precision complex floating-point ndarray y.

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 y = new Complex128Vector( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );

var alpha = scalar2ndarray( new Complex128( 1.0, 2.0 ), {
    'dtype': 'complex128'
});
var z = zaxpy( [ x, y, alpha ] );
// returns <ndarray>[ <Complex128>[ -2.0, 5.0 ], <Complex128>[ -4.0, 11.0 ], <Complex128>[ -6.0, 17.0 ] ]

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

The function has the following parameters:

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

    • a one-dimensional input ndarray.
    • a one-dimensional output 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 zaxpy = require( '@stdlib/blas/base/ndarray/zaxpy' );

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

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

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

var alpha = scalar2ndarray( new Complex128( 1.0, 2.0 ), {
    'dtype': 'complex128'
});
var out = zaxpy( [ x, y, alpha ] );
console.log( ndarray2array( out ) );