Skip to content

Latest commit

 

History

History
120 lines (74 loc) · 2.93 KB

File metadata and controls

120 lines (74 loc) · 2.93 KB

scopy

Copy values from a one-dimensional single-precision floating-point ndarray x into a one-dimensional single-precision floating-point ndarray y.

Usage

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

scopy( arrays )

Copies values from a one-dimensional single-precision floating-point ndarray x into a one-dimensional single-precision floating-point ndarray y.

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

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

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

var z = scopy( [ 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 scopy = require( '@stdlib/blas/base/ndarray/scopy' );

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

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 = scopy( [ x, y ] );
console.log( ndarray2array( out ) );