Multiply a one-dimensional single-precision complex floating-point ndarray
xby a constantalphaand add the result to a one-dimensional single-precision complex floating-point ndarrayy.
var caxpy = require( '@stdlib/blas/base/ndarray/caxpy' );Multiplies a one-dimensional single-precision complex floating-point ndarray x by a constant alpha and adds the result to a one-dimensional single-precision complex floating-point ndarray y.
var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var x = new Complex64Vector( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var y = new Complex64Vector( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
var alpha = scalar2ndarray( new Complex64( 1.0, 2.0 ), {
'dtype': 'complex64'
});
var z = caxpy( [ x, y, alpha ] );
// returns <ndarray>[ <Complex64>[ -2.0, 5.0 ], <Complex64>[ -4.0, 11.0 ], <Complex64>[ -6.0, 17.0 ] ]
var bool = ( z === y );
// returns trueThe 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.
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var caxpy = require( '@stdlib/blas/base/ndarray/caxpy' );
var opts = {
'dtype': 'float32'
};
var x = new Complex64Vector( discreteUniform( 10, 0, 100, opts ) );
console.log( ndarray2array( x ) );
var y = new Complex64Vector( discreteUniform( 10, 0, 10, opts ) );
console.log( ndarray2array( y ) );
var alpha = scalar2ndarray( new Complex64( 1.0, 2.0 ), {
'dtype': 'complex64'
});
var out = caxpy( [ x, y, alpha ] );
console.log( ndarray2array( out ) );