Skip to content

Latest commit

 

History

History
119 lines (73 loc) · 2.71 KB

File metadata and controls

119 lines (73 loc) · 2.71 KB

gcopy

Copy values from a one-dimensional ndarray x into a one-dimensional ndarray y.

Usage

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

gcopy( arrays )

Copies values from a one-dimensional ndarray x into a one-dimensional ndarray y.

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

var xbuf = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
var x = new ndarray( 'generic', xbuf, [ 5 ], [ 1 ], 0, 'row-major' );

var ybuf = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
var y = new ndarray( 'generic', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );

var z = gcopy( [ x, y ] );
// returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]

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

The function has the following parameters:

  • arrays: array-like object containing an input ndarray and an output ndarray.

Examples

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

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

var xbuf = discreteUniform( 10, 0, 100, opts );
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );

var ybuf = discreteUniform( xbuf.length, 0, 10, opts );
var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( y ) );

var out = gcopy( [ x, y ] );
console.log( ndarray2array( out ) );