Interchange two one-dimensional double-precision floating-point ndarrays.
var dswap = require( '@stdlib/blas/base/ndarray/dswap' );Interchanges two one-dimensional double-precision floating-point ndarrays.
var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
var x = new Float64Vector( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
var y = new Float64Vector( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
var z = dswap( [ x, y ] );
// x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
// y => <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
var bool = ( z === y );
// returns trueThe function has the following parameters:
-
arrays: array-like object containing the following ndarrays:
- first one-dimensional input ndarray.
- second one-dimensional input ndarray.
var discreteUniform = require( '@stdlib/random/discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var dswap = require( '@stdlib/blas/base/ndarray/dswap' );
var opts = {
'dtype': 'float64'
};
var x = discreteUniform( [ 10 ], 0, 100, opts );
console.log( ndarray2array( x ) );
var y = discreteUniform( [ 10 ], 0, 100, opts );
console.log( ndarray2array( y ) );
var out = dswap( [ x, y ] );
console.log( ndarray2array( x ) );
console.log( ndarray2array( out ) );