Copy values from a one-dimensional ndarray
xinto a one-dimensional ndarrayy.
var gcopy = require( '@stdlib/blas/base/ndarray/gcopy' );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 trueThe function has the following parameters:
- arrays: array-like object containing an input ndarray and an output ndarray.
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 ) );