Apply a plane rotation to two one-dimensional single-precision floating-point ndarrays.
var srot = require( '@stdlib/blas/base/ndarray/srot' );Applies a plane rotation to two one-dimensional single-precision floating-point ndarrays.
var Float32Vector = require( '@stdlib/ndarray/vector/float32' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var x = new Float32Vector( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
var y = new Float32Vector( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
var c = scalar2ndarray( 0.8, {
'dtype': 'float32'
});
var s = scalar2ndarray( 0.6, {
'dtype': 'float32'
});
var z = srot( [ x, y, c, s ] );
// x => <ndarray>[ ~4.4, ~5.8, ~7.2, ~8.6, 10 ]
// y => <ndarray>[ ~4.2, ~4.4, ~4.6, ~4.8, 5 ]
var bool = ( z === y );
// returns trueThe function has the following parameters:
-
arrays: array-like object containing the following ndarrays:
- a one-dimensional input ndarray.
- a one-dimensional output ndarray.
- a zero-dimensional ndarray containing the cosine of the angle of rotation.
- a zero-dimensional ndarray containing the sine of the angle of rotation.
var discreteUniform = require( '@stdlib/random/discrete-uniform' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var srot = require( '@stdlib/blas/base/ndarray/srot' );
var opts = {
'dtype': 'float32'
};
var x = discreteUniform( [ 10 ], 0, 100, opts );
console.log( ndarray2array( x ) );
var y = discreteUniform( [ 10 ], 0, 100, opts );
console.log( ndarray2array( y ) );
var c = scalar2ndarray( 0.8, opts );
var s = scalar2ndarray( 0.6, opts );
var z = srot( [ x, y, c, s ] );
console.log( ndarray2array( z ) );