Skip to content

Latest commit

 

History

History
131 lines (78 loc) · 3.2 KB

File metadata and controls

131 lines (78 loc) · 3.2 KB

gxsy

Subtract the second one-dimensional ndarray from the first one-dimensional ndarray and assign the results to the second ndarray.

This BLAS extension implements the operation

$$\mathbf{y} = \mathbf{x} - \mathbf{y}$$

This API is a specialized version of the package @stdlib/blas/ext/base/ndarray/gaxpby with α = 1 and β = -1 and performs element-wise subtraction between two vectors.

Usage

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

gxsy( arrays )

Subtracts the second one-dimensional ndarray from the first one-dimensional ndarray and assigns the results to the second ndarray.

var vector = require( '@stdlib/ndarray/vector/ctor' );

var x = vector( [ 1.0, 2.0, 3.0, 4.0, 5.0 ], 'generic' );
var y = vector( [ 5.0, 4.0, 3.0, 2.0, 1.0 ], 'generic' );

gxsy( [ x, y ] );
// y => <ndarray>[ -4.0, -2.0, 0.0, 2.0, 4.0 ]

The function has the following parameters:

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

    • a one-dimensional input ndarray.
    • a one-dimensional output ndarray.

Notes

  • The output ndarray is modified in-place (i.e., the output ndarray is mutated).

Examples

var discreteUniform = require( '@stdlib/random/discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var gxsy = require( '@stdlib/blas/ext/base/ndarray/gxsy' );

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

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

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

gxsy( [ x, y ] );
console.log( ndarray2array( y ) );