diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/README.md b/lib/node_modules/@stdlib/blas/base/drotmg/README.md new file mode 100755 index 000000000000..141b817a5fcd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/README.md @@ -0,0 +1,119 @@ + + +# drotmg + +> Constructs the parameters for a modified Givens plane rotation. + +
+ +## Usage + +```javascript +var drotmg = require( '@stdlib/blas/base/drotmg' ); +``` + +#### drotmg( d1, d2, x1, y1 ) + +Constructs a Givens plane rotation provided four double-precision floating-point values `d1`, `d2`, `x1` and `y1`. + +```javascript +var out = drotmg( 3.0, 4.0, 1.5, 2.5 ); +// returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +``` + +The function has the following parameters: + +- **d1**: scaling factor for the first vector component. +- **d2**: scaling factor for the second vector component. +- **x1**: first component of the first vector. +- **y1**: first component of the second vector. + +#### drotmg.assign( d1, d2, x1, y1, out, stride, offset ) + +Constructs a Givens plane rotation provided four double-precision floating-point values `d1`, `d2`, `x1` and `y1` and assigns results to an output array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 5 ); + +var y = drotmg.assign( 3.0, 4.0, 1.5, 2.5, out, 1, 0 ); +// returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + +var bool = ( y === out ); +// returns true +``` + +
+ + + +
+ +## Notes + +- `drotmg()` corresponds to the [BLAS][blas] level 1 function [`drotmg`][drotmg]. + +
+ + + +
+ +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var drotmg = require( '@stdlib/blas/base/drotmg' ); + +var param; +var i; +for ( i = 0; i < 100; i++ ) { + d1 = discreteUniform( -5, 5 ); + d2 = discreteUniform( -5, 5 ); + x1 = discreteUniform( -5, 5 ); + y1 = discreteUniform( -5, 5 ); + param = drotmg( d1, d2, x1, y1 ); + console.log( param ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/drotmg/benchmark/benchmark.js new file mode 100755 index 000000000000..4c2bf7bc611c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/benchmark/benchmark.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nanf' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var drotmg = require( './../lib' ); + + +// VARIABLES // + +var OPTS = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var param; + var d1; + var d2; + var x1; + var y1; + var i; + + d1 = discreteUniform( 100, -5, 5, OPTS ); + d2 = discreteUniform( 100, -5, 5, OPTS ); + x1 = discreteUniform( 100, -5, 5, OPTS ); + y1 = discreteUniform( 100, -5, 5, OPTS ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + param = drotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ] ); + if ( isnan( param[ i%5 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( param[ i%5 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':assign', function benchmark( b ) { + var param; + var d1; + var d2; + var x1; + var y1; + var z; + var i; + + d1 = discreteUniform( 100, -5, 5, OPTS ); + d2 = discreteUniform( 100, -5, 5, OPTS ); + x1 = discreteUniform( 100, -5, 5, OPTS ); + y1 = discreteUniform( 100, -5, 5, OPTS ); + param = new Float64Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = drotmg.assign( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], param, 1, 0 ); + if ( typeof z !=='object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( isnan( z[ i%5 ] ) ) { + b.fail( 'should return the output array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/drotmg/docs/repl.txt new file mode 100755 index 000000000000..8921fdf15c16 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/docs/repl.txt @@ -0,0 +1,73 @@ + +{{alias}}( d1, d2, x1, y1 ) + Constructs the parameters for a modified Givens plane rotation from four + double-precision floating-point numbers. + + Parameters + ---------- + d1: float + Scaling factor for the first vector component. + + d2: float + Scaling factor for the second vector component. + + x1: float + First component of the first vector. + + y1: float + First component of the second vector. + + Returns + ------- + out: Float64Array + Computed values. + + Examples + -------- + > var out = {{alias}}( 3.0, 4.0, 1.5, 2.5 ) + [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + + +{{alias}}.assign( d1, d2, x1, y1, out, stride, offset ) + Constructs the parameters for a modified Givens plane rotation from four + double-precision floating-point numbers and assigns the results to an + output array. + + Parameters + ---------- + d1: float + Scaling factor for the first vector component. + + d2: float + Scaling factor for the second vector component. + + x1: float + First component of the first vector. + + y1: float + First component of the second vector. + + out: Float64Array + Output array. + + stride: integer + Output array stride. + + offset: integer + Output array index offset. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 5 ); + > var y = {{alias}}.assign( 3.0, 4.0, 1.5, 2.5, out, 1, 0 ) + [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + > var bool = ( y === out ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/drotmg/docs/types/index.d.ts new file mode 100755 index 000000000000..1fc4fffcca8a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/docs/types/index.d.ts @@ -0,0 +1,100 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Inteface describing `drotmg`. +*/ +interface Routine { + /** + * Constructs the parameters for a modified Givens plane rotation. + * + * @param d1 - scaling factor for the first vector component + * @param d2 - scaling factor for the second vector component + * @param x1 - first component of the first vector + * @param y1 - first component of the second vector + * @returns - output array containing the rotation parameters + * + * @example + * var out = drotmg( 3.0, 4.0, 1.5, 2.5 ); + * // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + * + * @example + * var out = drotmg( 3.0, 5.0, 1.0, 2.0 ); + * // returns [ 1.0, 0.3, 0.0, 0.0, 0.5 ] + */ + ( d1: number, d2: number, x1: number, y1: number ): Float64Array; + + /** + * Constructs the parameters for a modified Givens plane rotation. + * + * @param d1 - scaling factor for the first vector component + * @param d2 - scaling factor for the second vector component + * @param x1 - first component of the first vector + * @param y1 - first component of the second vector + * @param out - output array + * @param stride - index increment + * @param offset - starting index + * @returns - output array containing the rotation parameters + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 5 ); + * + * var y = drotmg.assign( 3.0, 4.0, 1.5, 2.5, out, 1, 0 ); + * // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + * + * var bool = (y === out); + * // returns true + */ + assign( d1: number, d2: number, x1: number, y1: number, out: Float64Array, stride: number, offset: number ): Float64Array; +} + +/** +* Constructs the parameters for a modified Givens plane rotation. +* +* @param d1 - scaling factor for the first vector component +* @param d2 - scaling factor for the second vector component +* @param x1 - first component of the first vector +* @param y1 - first component of the second vector +* @param out - output array +* @param stride - index increment +* @param offset - starting index +* @returns - output array containing the rotation parameters +* +* @example +* var out = drotmg( 3.0, 4.0, 1.5, 2.5 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 4 ); +* var y = drotg.assign( 3.0, 4.0, 1.5, 2.5 out, 1, 0 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* +* var bool = (y === out); +* // returns true +*/ +declare var drotmg: Routine; + +// EXPORTS // + +export = drotmg; diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/drotmg/docs/types/test.ts new file mode 100755 index 000000000000..181c97d1309a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/docs/types/test.ts @@ -0,0 +1,158 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import drotmg = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + drotmg( 0.0, 1.0, 2.0, 3.0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided an argument which is not a number... +{ + drotmg( true, 1.0, 2.0, 3.0 ); // $ExpectError + drotmg( false, 1.0, 2.0, 3.0 ); // $ExpectError + drotmg( null, 1.0, 2.0, 3.0 ); // $ExpectError + drotmg( undefined, 1.0, 2.0, 3.0 ); // $ExpectError + drotmg( '5', 1.0, 2.0, 3.0 ); // $ExpectError + drotmg( [], 1.0, 2.0, 3.0 ); // $ExpectError + drotmg( {}, 1.0, 2.0, 3.0 ); // $ExpectError + + drotmg( 0.0, true, 2.0, 3.0 ); // $ExpectError + drotmg( 0.0, false, 2.0, 3.0 ); // $ExpectError + drotmg( 0.0, null, 2.0, 3.0 ); // $ExpectError + drotmg( 0.0, undefined, 2.0, 3.0 ); // $ExpectError + drotmg( 0.0, '5', 2.0, 3.0 ); // $ExpectError + drotmg( 0.0, [], 2.0, 3.0 ); // $ExpectError + drotmg( 0.0, {}, 2.0, 3.0 ); // $ExpectError + + drotmg( 0.0, 1.0, true, 3.0 ); // $ExpectError + drotmg( 0.0, 1.0, false, 3.0 ); // $ExpectError + drotmg( 0.0, 1.0, null, 3.0 ); // $ExpectError + drotmg( 0.0, 1.0, undefined, 3.0 ); // $ExpectError + drotmg( 0.0, 1.0, '5', 3.0 ); // $ExpectError + drotmg( 0.0, 1.0, [], 3.0 ); // $ExpectError + drotmg( 0.0, 1.0, {}, 3.0 ); // $ExpectError + + drotmg( 0.0, 1.0, 2.0, true ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, false ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, null ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, undefined ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, '5' ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, [] ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + drotmg(); // $ExpectError + drotmg( 0.0 ); // $ExpectError + drotmg( 0.0, 1.0 ); // $ExpectError + drotmg( 0.0, 1.0, 2.0 ); // $ExpectError + drotmg( 0.0, 1.0, 2.0, 3.0, 4.0 ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a Float64Array... +{ + const out = new Float64Array( 5 ); + + drotmg.assign( 0.0, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `assign` method is provided a first, second, third or fourth argument which is not a number... +{ + const out = new Float64Array( 5 ); + + drotmg.assign( true, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( false, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( null, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( undefined, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( '5', 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( [], 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( {}, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + + drotmg.assign( 0.0, true, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, false, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, null, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, undefined, 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, [], 3.0, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError + + drotmg.assign( 0.0, 2.0, true, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, false, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, null, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, undefined, 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, '5', 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, [], 4.0, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, {}, 4.0, out, 1, 0 ); // $ExpectError + + drotmg.assign( 0.0, 2.0, 3.0, true, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, 3.0, false, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, 3.0, null, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, 3.0, undefined, out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, 3.0, '5', out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, 3.0, [], out, 1, 0 ); // $ExpectError + drotmg.assign( 0.0, 2.0, 3.0, {}, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... +{ + const out = new Float64Array( 5 ); + + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, '5', 0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, true, 0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, false, 0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, null, 0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, [], 0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, {}, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a seventh argument which is not a number... +{ + const out = new Float64Array( 5 ); + + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, '5' ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, true ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, false ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, null ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, [] ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const out = new Float64Array( 5 ); + + drotmg.assign(); // $ExpectError + drotmg.assign( 1.0 ); // $ExpectError + drotmg.assign( 1.0, 2.0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, out ); // $ExpectError + drotmg.assign( 1.0, 2.0, out, 1 ); // $ExpectError + drotmg.assign( 1.0, 2.0, out, 1, 0, 1 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, out ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, out, 1, 0, 1 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1 ); // $ExpectError + drotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, 0, 1 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/examples/index.js b/lib/node_modules/@stdlib/blas/base/drotmg/examples/index.js new file mode 100755 index 000000000000..1b9ac62c87e1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var drotmg = require( './../lib' ); + +var param; +var i; +var d1; +var d2; +var x1; +var y1; +for ( i = 0; i < 100; i++ ) { + d1 = discreteUniform( -5, 5 ); + d2 = discreteUniform( -5, 5 ); + x1 = discreteUniform( -5, 5 ); + y1 = discreteUniform( -5, 5 ); + param = drotmg( d1, d2, x1, y1 ); + console.log( param ); +} diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/drotmg/lib/assign.js new file mode 100755 index 000000000000..a18981a66c9a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/lib/assign.js @@ -0,0 +1,201 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var abs = require( '@stdlib/math/base/special/abs' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// VARIABLES // + +var GAM = 4096.0; +var GAM_SQ = 16777216.0; +var RGAM_SQ = 5.9604645e-8; + + +// MAIN // + +/** +* Construct the parameters for a modified Givens plane rotation. +* +* @param {number} d1 - scaling factor for the first vector component +* @param {number} d2 - scaling factor for the second vector component +* @param {number} x1 - first component of the first vector +* @param {number} y1 - first component of the second vector +* @param {Float64Array} param - output array +* @param {integer} stride - index increment +* @param {NonNegativeInteger} offset - starting index +* @returns {Float64Array} - output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = drotmg( 3.0, 4.0, 1.5, 2.5, new Float64Array( 5 ), 1, 0 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +*/ +function drotmg( d1, d2, x1, y1, param, stride, offset ) { + var flag; + var temp; + var ad1; + var ad2; + var h11; + var h12; + var h21; + var h22; + var p1; + var p2; + var q1; + var q2; + var u; + + if ( isnan( d1 ) || isnan( d2 ) || isnan( x1 ) || isnan( y1 ) ) { + param[ offset ] = NaN; + param[ offset + stride ] = NaN; + param[ offset + ( 2 * stride ) ] = NaN; + param[ offset + ( 3 * stride ) ] = NaN; + param[ offset + ( 4 * stride ) ] = NaN; + return param; + } + + if ( d1 < 0.0 ) { + flag = -1.0; + h11 = 0.0; + h12 = 0.0; + h21 = 0.0; + h22 = 0.0; + d1 = 0.0; + d2 = 0.0; + x1 = 0.0; + } else { + p2 = d2 * y1; + if ( p2 === 0.0 ) { + flag = -2.0; + param[ offset ] = flag; + return param; + } + p1 = d1 * x1; + q2 = p2 * y1; + q1 = p1 * x1; + ad1 = abs( q1 ); + ad2 = abs( q2 ); + + if ( ad1 > ad2 ) { + h21 = -y1 / x1; + h12 = p2 / p1; + u = 1 - ( h12 * h21 ); + if ( u > 0.0 ) { + flag = 0.0; + d1 /= u; + d2 /= u; + x1 *= u; + } + } else if ( q2 < 0.0 ) { + flag = -1.0; + h11 = 0.0; + h12 = 0.0; + h21 = 0.0; + h22 = 0.0; + d1 = 0.0; + d2 = 0.0; + x1 = 0.0; + } else { + flag = 1.0; + h11 = p1 / p2; + h22 = x1 / y1; + u = 1 + ( h11 * h22 ); + temp = d2 / u; + d2 = d1 / u; + d1 = temp; + x1 = y1 * u; + } + if ( d1 !== 0.0 ) { + while ( ( d1 < RGAM_SQ ) || ( d1 > GAM_SQ ) ) { + if ( flag === 0.0 ) { + h11 = 1.0; + h22 = 1.0; + flag = -1.0; + } else { + h21 = -1.0; + h12 = 1.0; + flag = -1.0; + } + if ( d1 < RGAM_SQ ) { + d1 *= GAM * GAM; + x1 /= GAM; + h11 /= GAM; + h12 /= GAM; + } else { + d1 /= GAM * GAM; + x1 *= GAM; + h11 *= GAM; + h12 *= GAM; + } + } + } + + if ( d2 !== 0.0 ) { + while ( ( abs( d2 ) < RGAM_SQ ) || ( abs( d2 ) > GAM_SQ ) ) { + if ( flag === 0.0 ) { + h11 = 1.0; + h22 = 1.0; + flag = -1.0; + } else { + h21 = -1.0; + h12 = 1.0; + flag = -1.0; + } + if ( abs( d2 ) < RGAM_SQ ) { + d2 *= GAM * GAM; + h21 /= GAM; + h22 /= GAM; + } else { + d2 /= GAM * GAM; + h21 *= GAM; + h22 *= GAM; + } + } + } + } + + param[ offset ] = flag; + + if ( flag < 0.0 ) { + param[ offset + stride ] = h11; + param[ offset + ( 2 * stride ) ] = h21; + param[ offset + ( 3 * stride ) ] = h12; + param[ offset + ( 4 * stride ) ] = h22; + } else if ( flag === 0.0 ) { + param[ offset + ( 2 * stride ) ] = h21; + param[ offset + ( 3 * stride ) ] = h12; + } else { + param[ offset + stride ] = h11; + param[ offset + ( 4 * stride ) ] = h22; + } + + param[ offset ] = flag; + + return param; +} + + +// EXPORTS // + +module.exports = drotmg; diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/lib/index.js b/lib/node_modules/@stdlib/blas/base/drotmg/lib/index.js new file mode 100755 index 000000000000..d5a6d372c084 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/lib/index.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Construct the parameters for a modified Givens plane rotation. +* +* @module @stdlib/blas/base/drotmg +* +* @example +* var drotmg = require( '@stdlib/blas/base/drotmg' ); +* +* var out = drotmg( 3.0, 4.0, 1.5, 2.5 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* +* var out = drotmg( 4.0, 6.0, 2.0, 1.0 ); +* // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float32' ); +* var drotmg = require( '@stdlib/blas/base/drotmg' ); +* +* var out = new Float64Array( 5 ); +* +* var y = drotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float64Array( 5 ), 1, 0 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* +* var bool = ( y === out ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/lib/main.js b/lib/node_modules/@stdlib/blas/base/drotmg/lib/main.js new file mode 100755 index 000000000000..acf7320d6d52 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/lib/main.js @@ -0,0 +1,50 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Float64Array = require( '@stdlib/array/float64' ); +var fcn = require( './assign.js' ); + + +// MAIN // + +/** +* Constructs the parameters for a modified Givens plane rotation. +* +* @param {number} d1 - scaling factor for the first vector component +* @param {number} d2 - scaling factor for the second vector component +* @param {number} x1 - first component of the first vector +* @param {number} y1 - first component of the second vector +* @returns {Float64Array} output array containing the rotation parameters +* +* @example +* var out = drotmg( 3.0, 4.0, 1.5, 2.5 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +*/ +function drotmg( d1, d2, x1, y1 ) { + var out = new Float64Array( 5 ); + return fcn( d1, d2, x1, y1, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = drotmg; diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/package.json b/lib/node_modules/@stdlib/blas/base/drotmg/package.json new file mode 100755 index 000000000000..2cc899354339 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/blas/base/drotmg", + "version": "0.0.0", + "description": "Construct a Givens plane rotation.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "drotmg", + "parameters", + "modified", + "givens", + "rotation", + "matrix", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "float64", + "float", + "single", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/drotmg/test/test.assign.js new file mode 100755 index 000000000000..830d9a2c5fd9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/test/test.assign.js @@ -0,0 +1,277 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var drotmg = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotmg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( drotmg.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes parameters for a modified Givens plane rotation', function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var e; + var i; + var j; + + expected = [ + [ 1.0, 0.375, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.0, 0.0, -0.5, 0.125, 0.0 ], + [ 0.0, 0.0, -0.25, 0.1, 0.0 ], + [ 1.0, 0.625, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 0.0, 0.0, 0.0, 0.0 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ] + ]; + values = [ + [ 3.0, 4.0, 1.0, 2.0 ], + [ -3.0, 2.0, 2.0, 3.0 ], + [ 4.0, 1.0, 2.0, 1.0 ], + [ 5.0, 2.0, 4.0, 1.0 ], + [ 5.0, 4.0, 1.0, 2.0 ], + [ -5.0, 4.0, 1.0, 2.0 ], + [ 5.0, 4.0, -1.0, 2.0 ], + [ 5.0, 4.0, 1.0, -2.0 ], + [ 5.0, 0.0, 1.0, 2.0 ], + [ 5.0, 3.0, 0.0, 2.0 ], + [ 5.0, 3.0, 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + e = new Float64Array( expected[i] ); + out = new Float64Array( 5 ); + drotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = abs( out[j] - e[j] ); + tol = 1.5 * EPS * abs( e[j] ); + t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function returns an array of NaNs if provided a rotation elimination parameter equal to NaN', function test(t) { + var actual; + var i; + + actual = drotmg( NaN, 1.0, 2.0, 3.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, 3.0, 4.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, 2.0, NaN, 3.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, 2.0, 3.0, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, 3.0, 4.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, NaN, 4.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, 2.0, NaN, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, 2.0, NaN, 4.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, 3.0, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, 2.0, 3.0, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, NaN, 4.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, NaN, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, 3.0, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, 2.0, NaN, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, NaN, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function supports providing a positive stride', function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + expected = new Float64Array( [ 1.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5 ] ); + out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = drotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 0 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = abs( out[i] - expected[i] ); + tol = 1.5 * EPS * abs( expected[i] ); + t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports providing a negative stride', function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + expected = new Float64Array( [ 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 1.0 ] ); + out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = drotmg( 3.0, 4.0, 1.0, 2.0, out, -2, 8 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = abs( out[i] - expected[i] ); + tol = 1.5 * EPS * abs( expected[i] ); + t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports providing a positive offset', function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + expected = new Float64Array( [ 0.0, 1.0, 0.375, 0.0, 0.0, 0.5 ] ); + out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = drotmg( 3.0, 4.0, 1.0, 2.0, out, 1, 1 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = abs( out[i] - expected[i] ); + tol = 1.5 * EPS * abs( expected[i] ); + t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports providing both a stride and offset', function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + expected = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5 ] ); // eslint-disable-line max-len + out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = drotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 2 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = abs( out[i] - expected[i] ); + tol = 1.5 * EPS * abs( expected[i] ); + t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/test/test.js b/lib/node_modules/@stdlib/blas/base/drotmg/test/test.js new file mode 100755 index 000000000000..6e659efe0dc6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/test/test.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var drotmg = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotmg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( hasOwnProp( drotmg, 'assign' ), true, 'has property' ); + t.strictEqual( typeof drotmg.assign, 'function', 'has method' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotmg/test/test.main.js b/lib/node_modules/@stdlib/blas/base/drotmg/test/test.main.js new file mode 100755 index 000000000000..6c910c2f0e74 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotmg/test/test.main.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nanf' ); +var drotmg = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotmg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( drotmg.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function constructs the parameters for a modified Givens plane rotation', function test( t ) { + var expected; + var values; + var out; + var i; + + expected = [ + [ 1.0, 0.375, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.0, 0.0, -0.5, 0.125, 0.0 ], + [ 0.0, 0.0, -0.25, 0.1, 0.0 ], + [ 1.0, 0.625, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 0.0, 0.0, 0.0, 0.0 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ] + ]; + values = [ + [ 3.0, 4.0, 1.0, 2.0 ], + [ -3.0, 2.0, 2.0, 3.0 ], + [ 4.0, 1.0, 2.0, 1.0 ], + [ 5.0, 2.0, 4.0, 1.0 ], + [ 5.0, 4.0, 1.0, 2.0 ], + [ -5.0, 4.0, 1.0, 2.0 ], + [ 5.0, 4.0, -1.0, 2.0 ], + [ 5.0, 4.0, 1.0, -2.0 ], + [ 5.0, 0.0, 1.0, 2.0 ], + [ 5.0, 3.0, 0.0, 2.0 ], + [ 5.0, 3.0, 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + expected[i] = new Float64Array( expected[i] ); + out = drotmg( values[i][0], values[i][1], values[i][2], values[i][3] ); + t.deepEqual( out, expected[i], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns an array of NaNs if provided a rotational elimination parameter equal to NaN', function test(t) { + var actual; + var i; + + actual = drotmg( NaN, 1.0, 2.0, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, 3.0, 4.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, 2.0, NaN, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, 2.0, 3.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, 3.0, 4.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, NaN, 4.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, 2.0, NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, 2.0, NaN, 4.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, 3.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, 2.0, 3.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, NaN, 4.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( 1.0, NaN, NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, 3.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, 2.0, NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = drotmg( NaN, NaN, NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + t.end(); +});