Applies a plane rotation.
var drot = require( '@stdlib/blas/base/drot' );
Applies a plane rotation.
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
drot( x.length, x, 1, y, 1, 1.0, 0.0 );
// x => <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
// y => <Float64Array>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
The function has the following parameters:
- N: number of indexed elements.
- x: first input
Float64Array
. - strideX: index increment for
x
. - y: second input
Float64Array
. - strideY: index increment for
y
. - c: double precision cosine.
- s: double precision sin.
The N
and stride parameters determine how values in the strided arrays are accessed at runtime. For example, to apply plane rotation for the strided arrays
in reverse order.
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
drot( x.length, x, 2, y, 2, 0.707, 0.707 );
// x => <Float64Array>[ 5.656, 2.0, 8.484, 4.0, 11.312, 6.0 ]
// y => <Float64Array>[ 4.242, 8.0, 4.241999999999999, 10.0, 4.241999999999999, 12.0 ]
Note that indexing is relative to the first index. To introduce an offset, use typed array
views.
Applies a plane rotation.
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
drot.ndarray( x.length, x, 1, 0, y, 1, 0, 1.0, 0.0 );
// x => <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
// y => <Float64Array>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
The function has the following additional parameters:
- offsetX: starting index for
x
. - offsetY: starting index for
y
.
While typed array
views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, for offset of two in x rotate every other value in x
starting from the second value,...,
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
drot.ndarray( 4, x, 0, 2, y, 0, 2, 0.707, 0.707 );
// x => <Float64Array>[ 1.0, 2.0, -2.998188273612, 4.0, 5.0, 6.0 ]
// y => <Float64Array>[ 7.0, 8.0, -8.994564820835999, 10.0, 11.0, 12.0 ]
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var drot = require( '@stdlib/blas/base/drot' );
var opts = {
'dtype': 'float64'
};
var x = discreteUniform( 10, 0, 500, opts );
console.log( x );
var y = discreteUniform( x.length, 0, 255, opts );
console.log( y );
// Applies a plane rotation :
drot( x.length, x, 1, y, 1, 0.707, 0.707 );
console.log( x );
console.log( y );
@stdlib/blas/drot
: interchange two double-precision floating-point vectors.