From ec6bf9d0cac78d8d7ed4445c73e0af3f570d2369 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 12 Jan 2025 10:31:35 +0530 Subject: [PATCH 01/12] feat: add /blas/base/srotmg --- .../@stdlib/blas/base/srotmg/README.md | 119 +++++++++++ .../blas/base/srotmg/benchmark/benchmark.js | 96 +++++++++ .../@stdlib/blas/base/srotmg/docs/repl.txt | 70 +++++++ .../blas/base/srotmg/docs/types/index.d.ts | 91 +++++++++ .../blas/base/srotmg/docs/types/test.ts | 155 +++++++++++++++ .../blas/base/srotmg/examples/index.js | 29 +++ .../@stdlib/blas/base/srotmg/lib/assign.js | 101 ++++++++++ .../@stdlib/blas/base/srotmg/lib/index.js | 61 ++++++ .../@stdlib/blas/base/srotmg/lib/main.js | 50 +++++ .../@stdlib/blas/base/srotmg/package.json | 75 +++++++ .../blas/base/srotmg/test/test.assign.js | 186 ++++++++++++++++++ .../@stdlib/blas/base/srotmg/test/test.js | 40 ++++ .../blas/base/srotmg/test/test.main.js | 129 ++++++++++++ 13 files changed, 1202 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/README.md b/lib/node_modules/@stdlib/blas/base/srotmg/README.md new file mode 100644 index 000000000000..e2dc687bc00a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/README.md @@ -0,0 +1,119 @@ + + +# srotmg + +> Constructs the parameters for a modified Givens plane rotation. + +
+ +## Usage + +```javascript +var srotmg = require( '@stdlib/blas/base/srotmg' ); +``` + +#### srotmg( d1, d2, x1, y1 ) + +Constructs a Givens plane rotation provided two single-precision floating-point values `d1` and `d2`. + +```javascript +var out = srotmg( -3.0, -4.0, 1.5, 2.5 ); +// returns [ 0.6000000238418579, 0.800000011920929, 2, 1.5, 2.5 ] +``` + +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. + +#### srotmg.assign( d1, d2, x1, y1, out, stride, offset ) + +Constructs a Givens plane rotation provided two single-precision floating-point values `d1` and `d2` and assigns results to an output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var out = new Float32Array( 5 ); + +var y = srotmg.assign( -3.0, -4.0, 1.5, 2.5, out, 1, 0 ); +// returns [ 0.6000000238418579, 0.800000011920929, 2, 1.5, 2.5 ] + +var bool = ( y === out ); +// returns true +``` + +
+ + + +
+ +## Notes + +- `srotmg()` corresponds to the [BLAS][blas] level 1 function [`srotmg`][srotmg]. + +
+ + + +
+ +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var srotmg = require( '@stdlib/blas/base/srotmg' ); + +var out; +var i; +for ( i = 0; i < 100; i++ ) { + d1 = discreteUniform( -5, 5 ); + d2 = discreteUniform( -5, 5 ); + x1 = discreteUniform( -5, 5 ); + y1 = discreteUniform( -5, 5 ); + out = srotmg( d1, d2, x1, y1 ); + console.log( out ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js new file mode 100644 index 000000000000..1ece259339b8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var pkg = require( './../package.json' ).name; +var srotmg = require( './../lib' ); + + +// VARIABLES // + +var OPTS = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + 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++ ) { + out = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ] ); + if ( isnanf( out[ i%5 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( out[ i%5 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':assign', function benchmark( b ) { + var out; + 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 ); + out = new Float32Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = srotmg.assign( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], out, 1, 0 ); + if ( typeof z !=='object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( isnanf( 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/srotmg/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt new file mode 100644 index 000000000000..83c9fc785f52 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt @@ -0,0 +1,70 @@ + +{{alias}}( d1, d2, x1, y1 ) + Constructs the parameters for a modified Givens plane rotation. + + 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: Float32Array + Computed values. + + Examples + -------- + > var out = {{alias}}( 1.0, 1.0, 1.0, 0.0 ) + [ -2.0, 0.0, 0.0, 1.0, 0.0 ] + + +{{alias}}.assign( d1, d2, x1. y1, out, stride, offset ) + Constructs the parameters for a modified Givens plane rotation. + + 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: Float32Array + Output array. + + stride: integer + Output array stride. + + offset: integer + Output array index offset. + + Returns + ------- + out: Float32Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float32}}( 5 ); + > var y = {{alias}}.assign( 1.0, 1.0, 1.0, 0.0, out, 1, 0 ) + [ -2.0, 0.0, 0.0, 1.0, 0.0 ] + > var bool = ( y === out ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts new file mode 100644 index 000000000000..0a171b78637f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -0,0 +1,91 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2023 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 `srotmg`. +*/ +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 Float32Array = require( '@stdlib/array/float32' ); + * + * var out = srotmg( 1.0, 1.0, 1.0, 0.0 ); + * // returns [ 0.0, 1.0, 0.0, 1.0, 0.0 ] + */ + ( d1: number, d2: number, x1: number, y1: number ): Float32Array; + + /** + * 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 Float32Array = require( '@stdlib/array/float32' ); + * + * var out = srotmg( 1.0, 1.0, 1.0, 0.0 ); + * // returns [ 0.0, 1.0, 0.0, 1.0, 0.0 ] + * + * var bool = (y === out); + * // returns true + */ + assign( d1: number, d2: number, x1: number, y1: number, out: Float32Array, stride: number, offset: number ): Float32Array; +} + +/** +* 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 Float32Array = require( '@stdlib/array/float32' ); +* +* var out = srotmg( 1.0, 1.0, 1.0, 0.0 ); +* // returns [ 0.0, 1.0, 0.0, 1.0, 0.0 ] +* +* var bool = (y === out); +* // returns true +*/ +declare var srotmg: Routine; + +// EXPORTS // + +export = srotmg; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts new file mode 100644 index 000000000000..b4c6159ef5c0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts @@ -0,0 +1,155 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2023 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 srotmg = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + srotmg( 0.0, 1.0, 2.0, 3.0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided an argument which is not a number... +{ + srotmg( true, 1.0, 2.0, 3.0 ); // $ExpectError + srotmg( false, 1.0, 2.0, 3.0 ); // $ExpectError + srotmg( null, 1.0, 2.0, 3.0 ); // $ExpectError + srotmg( undefined, 1.0, 2.0, 3.0 ); // $ExpectError + srotmg( '5', 1.0, 2.0, 3.0 ); // $ExpectError + srotmg( [], 1.0, 2.0, 3.0 ); // $ExpectError + srotmg( {}, 1.0, 2.0, 3.0 ); // $ExpectError + + srotmg( 0.0, true, 2.0, 3.0 ); // $ExpectError + srotmg( 0.0, false, 2.0, 3.0 ); // $ExpectError + srotmg( 0.0, null, 2.0, 3.0 ); // $ExpectError + srotmg( 0.0, undefined, 2.0, 3.0 ); // $ExpectError + srotmg( 0.0, '5', 2.0, 3.0 ); // $ExpectError + srotmg( 0.0, [], 2.0, 3.0 ); // $ExpectError + srotmg( 0.0, {}, 2.0, 3.0 ); // $ExpectError + + srotmg( 0.0, 1.0, true, 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, false, 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, null, 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, undefined, 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, '5', 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, [], 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, {}, 3.0 ); // $ExpectError + + srotmg( 0.0, 1.0, 2.0, true ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, false ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, null ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, undefined ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, '5' ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, [] ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + srotmg(); // $ExpectError + srotmg( 0.0 ); // $ExpectError + srotmg( 0.0, 1.0 ); // $ExpectError + srotmg( 0.0, 1.0, 2.0 ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, 3.0, 4.0 ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a Float32Array... +{ + const out = new Float32Array( 5 ); + + srotmg.assign( 0.0, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the `assign` method is provided a first or second argument which is not a number... +{ + const out = new Float32Array( 5 ); + + srotmg.assign( true, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( false, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( null, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( undefined, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( '5', 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( [], 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( {}, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + + srotmg.assign( 0.0, true, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, false, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, null, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, undefined, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, [], 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError + + srotmg.assign( 0.0, 2.0 ,true, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0 ,false, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0 ,null, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0 ,undefined, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0 ,'5', 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0 ,[], 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0 ,{}, 4.0, out, 1, 0 ); // $ExpectError + + srotmg.assign( 0.0, true, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, false, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, null, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, undefined, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, [], 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... +{ + const out = new Float32Array( 5 ); + + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, '5', 0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, true, 0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, false, 0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, null, 0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, [], 0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, {}, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... +{ + const out = new Float32Array( 5 ); + + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, '5' ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, true ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, false ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, null ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, [] ); // $ExpectError + srotmg.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 Float32Array( 5 ); + + srotmg.assign(); // $ExpectError + srotmg.assign( 1.0 ); // $ExpectError + srotmg.assign( 1.0, 2.0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, out ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out ); // $ExpectError + srotmg.assign( 1.0, 2.0, out, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, out, 1, 0, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out, 1, 0, 1 ); // $ExpectError +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js new file mode 100644 index 000000000000..7603e6d2bbd2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 srotmg = require( './../lib' ); + +var out; +var i; +for ( i = 0; i < 100; i++ ) { + out = srotmg( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ), discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + console.log( out ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js new file mode 100644 index 000000000000..eeee64f713d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -0,0 +1,101 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 absf = require( '@stdlib/math/base/special/absf' ); +var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var abs2f = require('@stdlib/math/base/special/abs2f'); + +// 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 +* @param {Float32Array} out - output array +* @returns {Float32Array} - output array containing the rotation parameters +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var out = srotmg( -3.0, -4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); +* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +*/ +function srotmg( d1, d2, x1, y1, out, stride, offset ) { + var ad1; + var ad2; + var c; + var s; + var param; + var r; + if ( isnan(d1) || isnan(d2) || isnan(x1) || isnan(y1) ){ + c = NaN; + s = NaN; + param = NaN; + x1 = NaN; + y1 = NaN; + } else { + if ( d1 == 0.0 ) { + c = 0.0; + s = 1.0; + x1 = 0.0; + y1 = 0.0; + param = 0.0; + }else{ + ad1 = absf(d1); + ad2 = absf(d2); + if ( ad1 > ad2 ) { + r = float64ToFloat32(d1 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d2 / d1))))); + c = float64ToFloat32(d1 / r); + s = float64ToFloat32(d2 / r); + param = 1.0; + } else { + r = float64ToFloat32(d2 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d1 / d2))))); + c = float64ToFloat32(d1 / r); + s = float64ToFloat32(d2 / r); + param = 2.0; + } + } + if (d2 == 0.0 ) { + c = 1.0; + s = 0.0; + param = 0.0; + } + } + out[ offset ] = c; + out[ offset + stride ] = s; + out[ offset + ( 2 * stride ) ] = param; + out[ offset + ( 3 * stride ) ] = x1; + out[ offset + ( 4 * stride ) ] = y1; + + return out; +} + + + +// EXPORTS // + +module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js new file mode 100644 index 000000000000..cfb4744477af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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'; + +/** +* Constructs the parameters for a modified Givens plane rotation. +* +* @module @stdlib/blas/base/srotmg +* +* @example +* var srotmg = require( '@stdlib/blas/base/srotmg' ); +* +* var out = srotmg( 3.0, -4.0, 1.5, 2.5 ); +* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var srotmg = require( '@stdlib/blas/base/srotmg' ); +* +* var out = new Float32Array( 5 ); +* +* var y = srotmg.assign( 3.0, -4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); +* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +* +* 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/srotmg/lib/main.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js new file mode 100644 index 000000000000..34c08740c131 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js @@ -0,0 +1,50 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 Float32Array = require( '@stdlib/array/float32' ); +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 {Float32Array} output array containing the rotation parameters +* +* @example +* var out = srotmg( -3.0, -4.0, 1.5, 2.5 ); +* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +*/ +function srotmg( d1, d2, x1, y1 ) { + var out = new Float32Array( 5 ); + return fcn( d1, d2, x1, y1, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/package.json b/lib/node_modules/@stdlib/blas/base/srotmg/package.json new file mode 100644 index 000000000000..e939baedee91 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/blas/base/srotmg", + "version": "0.0.0", + "description": "Constructs the parameters for a modified 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", + "srotmg", + "parameters", + "modified", + "givens", + "rotation", + "matrix", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "float32", + "float", + "single", + "float32array" + ] + } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js new file mode 100644 index 000000000000..59b69eb5955c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -0,0 +1,186 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 Float32Array = require( '@stdlib/array/float32' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var srotmg = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof srotmg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( srotmg.length, 7, '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 = [ + [ 0.8944271802902222, 0.4472135901451111, 1.0, 1.0, 3.0 ], + [ 0.3162277638912201, 0.9486832618713379, 2.0, -4.0, -5.0 ], + [ 0.7071067690849304, 0.7071067690849304, 2.0, 2.0, 6.0 ], + [ 0.6, 0.8, 2.0, -2.0, -4.0 ], + [ 0.6, 0.8, 2.0, 1.5, 2.5 ], + [ 0.906183123588562, 0.4228854477405548, 1.0, -1.50, -2.50 ], + [ 0.4472135901451111, 0.8944271802902222, 2.0, 3.50, -7.50 ], + [ 0.800000011920929, 0.6000000238418579, 1.0, 4.50, -9.50 ] + ]; + values = [ + [ 4.0, 2.0, 1.0, 3.0 ], + [ 1.0, 3.0, -4.0, -5.0 ], + [ 5.0, 5.0, 2.0, 6.0 ], + [ 6.0, 8.0, -2.0, -4.0 ], + [ -3.0, -4.0, 1.5, 2.5 ], + [ -7.5, -3.5, -1.5, -2.5 ], + [ 10.0, 20.0, 3.5, -7.5 ], + [ -8.0, -6.0, 4.5, -9.5 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + expected[i] = new Float32Array( expected[i] ); + out = new Float32Array( 5 ); + srotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); // eslint-disable-line max-len + t.deepEqual( out, expected[i], 'returns expected value' ); + } + + 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 = srotmg( NaN, 1.0, 2.0, 3.0, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, NaN, 2.0, 3.0, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, NaN, 3.0, 4.0, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, NaN, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + actual = srotmg( NaN, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + actual = srotmg( NaN, 1.0, 2.0, NaN, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function supports providing a positive stride', function test(t) { + var expected; + var actual; + var out; + + expected = new Float32Array( [ 0.857492983341217, 0.0, 0.5144957900047302, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0 ] ); + out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, 2, 0 ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing a negative stride', function test(t) { + var expected; + var actual; + var out; + + expected = new Float32Array( [ 1.0, 0.0, 0.5144957900047302, 0.0, 0.857492983341217, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, -2, 4 ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing an offset', function test(t) { + var expected; + var actual; + var out; + + expected = new Float32Array( [ 0.0, 0.857492983341217, 0.5144957900047302, 1.0, 1.0, 2.0 ] ); + out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, 1, 1 ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing both a stride and offset', function test(t) { + var expected; + var actual; + var out; + + expected = new Float32Array( [ 0.0, 0.0, 0.857492983341217, 0.0, 0.5144957900047302, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0 ] ); // eslint-disable-line max-len + out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, 2, 2 ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js new file mode 100644 index 000000000000..ca2c67527a0c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 srotmg = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof srotmg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( hasOwnProp( srotmg, 'assign' ), true, 'has property' ); + t.strictEqual( typeof srotmg.assign, 'function', 'has method' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js new file mode 100644 index 000000000000..b0270ef84adc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 Float32Array = require( '@stdlib/array/float32' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var srotmg = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof srotmg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( srotmg.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 = [ + [ 0.8944271802902222, 0.4472135901451111, 1.0, 1.0, 3.0 ], + [ 0.3162277638912201, 0.9486832618713379, 2.0, -4.0, -5.0 ], + [ 0.7071067690849304, 0.7071067690849304, 2.0, 2.0, 6.0 ], + [ 0.6, 0.8, 2.0, -2.0, -4.0 ], + [ 0.6, 0.8, 2.0, 1.5, 2.5 ], + [ 0.906183123588562, 0.4228854477405548, 1.0, -1.50, -2.50 ], + [ 0.4472135901451111, 0.8944271802902222, 2.0, 3.50, -7.50 ], + [ 0.800000011920929, 0.6000000238418579, 1.0, 4.50, -9.50 ] + ]; + values = [ + [ 4.0, 2.0, 1.0, 3.0 ], + [ 1.0, 3.0, -4.0, -5.0 ], + [ 5.0, 5.0, 2.0, 6.0 ], + [ 6.0, 8.0, -2.0, -4.0 ], + [ -3.0, -4.0, 1.5, 2.5 ], + [ -7.5, -3.5, -1.5, -2.5 ], + [ 10.0, 20.0, 3.5, -7.5 ], + [ -8.0, -6.0, 4.5, -9.5 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + expected[i] = new Float32Array( expected[i] ); + out = srotmg( float64ToFloat32( values[i][0] ), float64ToFloat32( values[i][1] ), float64ToFloat32( values[i][2] ), float64ToFloat32( values[i][3] ) , out, 1, 0 ); // eslint-disable-line max-len + 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 = srotmg( NaN, 1.0, 2.0, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, NaN, 2.0, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, 2.0, NaN, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, 2.0, 3.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, NaN, 3.0, 4.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, NaN, NaN, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, 2.0, NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + actual = srotmg( NaN, 2.0, NaN, 3.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + actual = srotmg( NaN, 1.0, 2.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + actual = srotmg( 1.0, NaN, 3.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + t.end(); +}); From 1dd0e1bf7a10eb1eb311de3d8d3f8fe47ae0837c Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 12 Jan 2025 05:15:17 +0000 Subject: [PATCH 02/12] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/srotmg/README.md | 2 +- .../@stdlib/blas/base/srotmg/benchmark/benchmark.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/test/test.js | 2 +- lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/README.md b/lib/node_modules/@stdlib/blas/base/srotmg/README.md index e2dc687bc00a..0b6bc5a12346 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/README.md +++ b/lib/node_modules/@stdlib/blas/base/srotmg/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2023 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js index 1ece259339b8..11ea1b18cd22 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts index 0a171b78637f..a8710eb1efc2 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts index b4c6159ef5c0..113d63e88cdc 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js index 7603e6d2bbd2..554c8922453b 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js index eeee64f713d7..5f7f9becd5a8 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js index cfb4744477af..99390f0320e0 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js index 34c08740c131..0c0dac169119 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js index 59b69eb5955c..f7e80b0c7fd3 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js index ca2c67527a0c..bbe1a2bd4a0c 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js index b0270ef84adc..1d93ea3f6b3e 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. From f1277dab0854b0c2f034b611dfbff3794f50ff62 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 12 Jan 2025 13:23:46 +0530 Subject: [PATCH 03/12] fix: assign.js Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js index 5f7f9becd5a8..14b42b291f32 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -82,7 +82,7 @@ function srotmg( d1, d2, x1, y1, out, stride, offset ) { if (d2 == 0.0 ) { c = 1.0; s = 0.0; - param = 0.0; + param = 1.0; } } out[ offset ] = c; From 6d31c53502bf684fbf94762e0c5f4809340c34a7 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 12 Jan 2025 13:24:56 +0530 Subject: [PATCH 04/12] fix: complete test.assign.js Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../blas/base/srotmg/test/test.assign.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js index f7e80b0c7fd3..85e8fc04898e 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -129,6 +129,37 @@ tape( 'the function returns an array of NaNs if provided a rotation elimination t.end(); }); +tape( 'the function returns an array of zeros except s equals to 1 if provided scaling factor for the first vector component equal to 0', function test(t) { + var actual; + var i; + actual = srotmg( 0.0, 1.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + if ( i === 1 ) { + t.strictEqual( actual[ i ], 1.0, 'returns expected value' ); + } else { + t.strictEqual( actual[ i ], 0.0, 'returns expected value' ); + } + } + t.end(); +}); + +tape( 'the function returns an array with c, s value equal to 0 and param value value equal to 1 if provided scaling factor for the second vector component equal to 0', function test(t) { + var actual; + var i; + + actual = srotmg( 1.0, 0.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < ( actual.length - 2 ); i++ ) { + if ( i === 1 ) { + t.strictEqual( actual[ i ], 0.0, 'returns expected value' ); + } else { + t.strictEqual( actual[ i ], 1.0, 'returns expected value' ); + } + } + console.log(actual); + t.end(); +}); + + tape( 'the function supports providing a positive stride', function test(t) { var expected; var actual; From 69e5000b07c0191a0f2de46ec428aba57a2d72c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 12 Jan 2025 08:00:49 +0000 Subject: [PATCH 05/12] fix: resolve lint errors --- .../blas/base/srotmg/benchmark/benchmark.js | 8 +- .../blas/base/srotmg/docs/types/index.d.ts | 2 +- .../blas/base/srotmg/docs/types/test.ts | 2 +- .../@stdlib/blas/base/srotmg/lib/assign.js | 97 +++++++++---------- .../blas/base/srotmg/test/test.assign.js | 15 ++- 5 files changed, 61 insertions(+), 63 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js index 11ea1b18cd22..f4d27f3e1db8 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js @@ -69,15 +69,15 @@ bench( pkg+':assign', function benchmark( b ) { var out; var d1; var d2; - var x1; - var y1; + 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 ); + x1 = discreteUniform( 100, -5, 5, OPTS ); + y1 = discreteUniform( 100, -5, 5, OPTS ); out = new Float32Array( 5 ); b.tic(); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts index a8710eb1efc2..bbc8fbcbc4e5 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -88,4 +88,4 @@ declare var srotmg: Routine; // EXPORTS // -export = srotmg; \ No newline at end of file +export = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts index 113d63e88cdc..98bfe3b67793 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts @@ -152,4 +152,4 @@ import srotmg = require( './index' ); srotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, out, 1, 0, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, 3.0, out, 1, 0, 1 ); // $ExpectError -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js index 14b42b291f32..657972c9fd7c 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -22,9 +22,9 @@ var absf = require( '@stdlib/math/base/special/absf' ); var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var abs2f = require('@stdlib/math/base/special/abs2f'); +var abs2f = require( '@stdlib/math/base/special/abs2f' ); // MAIN // @@ -45,57 +45,56 @@ var abs2f = require('@stdlib/math/base/special/abs2f'); * // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] */ function srotmg( d1, d2, x1, y1, out, stride, offset ) { - var ad1; - var ad2; - var c; - var s; - var param; - var r; - if ( isnan(d1) || isnan(d2) || isnan(x1) || isnan(y1) ){ - c = NaN; - s = NaN; - param = NaN; - x1 = NaN; - y1 = NaN; - } else { - if ( d1 == 0.0 ) { - c = 0.0; - s = 1.0; - x1 = 0.0; - y1 = 0.0; - param = 0.0; - }else{ - ad1 = absf(d1); - ad2 = absf(d2); - if ( ad1 > ad2 ) { - r = float64ToFloat32(d1 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d2 / d1))))); - c = float64ToFloat32(d1 / r); - s = float64ToFloat32(d2 / r); - param = 1.0; - } else { - r = float64ToFloat32(d2 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d1 / d2))))); - c = float64ToFloat32(d1 / r); - s = float64ToFloat32(d2 / r); - param = 2.0; - } - } - if (d2 == 0.0 ) { - c = 1.0; - s = 0.0; - param = 1.0; - } - } - out[ offset ] = c; - out[ offset + stride ] = s; - out[ offset + ( 2 * stride ) ] = param; - out[ offset + ( 3 * stride ) ] = x1; - out[ offset + ( 4 * stride ) ] = y1; + var param; + var ad1; + var ad2; + var c; + var s; + var r; + if ( isnan(d1) || isnan(d2) || isnan(x1) || isnan(y1) ) { + c = NaN; + s = NaN; + param = NaN; + x1 = NaN; + y1 = NaN; + } else { + if ( d1 == 0.0 ) { + c = 0.0; + s = 1.0; + x1 = 0.0; + y1 = 0.0; + param = 0.0; + } else { + ad1 = absf(d1); + ad2 = absf(d2); + if ( ad1 > ad2 ) { + r = float64ToFloat32(d1 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d2 / d1))))); + c = float64ToFloat32(d1 / r); + s = float64ToFloat32(d2 / r); + param = 1.0; + } else { + r = float64ToFloat32(d2 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d1 / d2))))); + c = float64ToFloat32(d1 / r); + s = float64ToFloat32(d2 / r); + param = 2.0; + } + } + if (d2 == 0.0 ) { + c = 1.0; + s = 0.0; + param = 1.0; + } + } + out[ offset ] = c; + out[ offset + stride ] = s; + out[ offset + ( 2 * stride ) ] = param; + out[ offset + ( 3 * stride ) ] = x1; + out[ offset + ( 4 * stride ) ] = y1; - return out; + return out; } - // EXPORTS // module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js index 85e8fc04898e..08335efbbf7b 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -90,12 +90,12 @@ tape( 'the function returns an array of NaNs if provided a rotation elimination t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } @@ -105,24 +105,24 @@ tape( 'the function returns an array of NaNs if provided a rotation elimination t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, NaN, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( NaN, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 1.0, 2.0, NaN, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( NaN, 1.0, 2.0, NaN, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } @@ -159,7 +159,6 @@ tape( 'the function returns an array with c, s value equal to 0 and param value t.end(); }); - tape( 'the function supports providing a positive stride', function test(t) { var expected; var actual; From fbefa23447cd9bfefabdd437f3e3b0783afca6f0 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 1 Mar 2025 14:04:21 +0530 Subject: [PATCH 06/12] fix: update files --- .../blas/base/srotmg/docs/types/index.d.ts | 24 ++- .../blas/base/srotmg/docs/types/test.ts | 29 +-- .../@stdlib/blas/base/srotmg/lib/assign.js | 196 +++++++++++++----- .../@stdlib/blas/base/srotmg/lib/index.js | 11 +- .../@stdlib/blas/base/srotmg/lib/main.js | 4 +- 5 files changed, 191 insertions(+), 73 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts index bbc8fbcbc4e5..6981d54a5b70 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -32,10 +32,12 @@ interface Routine { * @returns - output array containing the rotation parameters * * @example - * var Float32Array = require( '@stdlib/array/float32' ); + * var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); + * // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] * - * var out = srotmg( 1.0, 1.0, 1.0, 0.0 ); - * // returns [ 0.0, 1.0, 0.0, 1.0, 0.0 ] + * @example + * var out = srotmg( 4.0, 6.0, 2.0, 1.0 ); + * // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] */ ( d1: number, d2: number, x1: number, y1: number ): Float32Array; @@ -54,8 +56,10 @@ interface Routine { * @example * var Float32Array = require( '@stdlib/array/float32' ); * - * var out = srotmg( 1.0, 1.0, 1.0, 0.0 ); - * // returns [ 0.0, 1.0, 0.0, 1.0, 0.0 ] + * var out = new Float32Array( 5 ); + * + * var y = srotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); + * // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] * * var bool = (y === out); * // returns true @@ -75,11 +79,17 @@ interface Routine { * @param offset - starting index * @returns - output array containing the rotation parameters * +@example +* var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var out = srotmg( 1.0, 1.0, 1.0, 0.0 ); -* // returns [ 0.0, 1.0, 0.0, 1.0, 0.0 ] +* var out = new Float32Array( 5 ); +* +* var y = srotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] * * var bool = (y === out); * // returns true diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts index 98bfe3b67793..a4864e2a1995 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts @@ -77,7 +77,7 @@ import srotmg = require( './index' ); srotmg.assign( 0.0, 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectType Float32Array } -// The compiler throws an error if the `assign` method is provided a first or second argument which is not a number... +// 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 Float32Array( 5 ); @@ -105,16 +105,16 @@ import srotmg = require( './index' ); srotmg.assign( 0.0, 2.0 ,[], 4.0, out, 1, 0 ); // $ExpectError srotmg.assign( 0.0, 2.0 ,{}, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, true, 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, false, 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, null, 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, undefined, 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, [], 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, true, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, false, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, null, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, undefined, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, '5', out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, [], out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, {}, out, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... +// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... { const out = new Float32Array( 5 ); @@ -126,7 +126,7 @@ import srotmg = require( './index' ); srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, {}, 0 ); // $ExpectError } -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... +// The compiler throws an error if the `assign` method is provided a seventh argument which is not a number... { const out = new Float32Array( 5 ); @@ -145,11 +145,14 @@ import srotmg = require( './index' ); srotmg.assign(); // $ExpectError srotmg.assign( 1.0 ); // $ExpectError srotmg.assign( 1.0, 2.0 ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0 ); // $ExpectError srotmg.assign( 1.0, 2.0, out ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0, out ); // $ExpectError srotmg.assign( 1.0, 2.0, out, 1 ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, out, 1, 0, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, 3.0, out, 1, 0, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, 0, 1 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js index 657972c9fd7c..327e039a3754 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -20,78 +20,180 @@ // MODULES // -var absf = require( '@stdlib/math/base/special/absf' ); -var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var abs2f = require( '@stdlib/math/base/special/abs2f' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); + + +// VARIABLES // + +var GAM = 4096.0; +var GAM_SQ = 16777216.0; +var RGAM_SQ = 5.9604645e-8; + // MAIN // /** -* Constructs the parameters for a modified Givens plane rotation. +* 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 {Float32Array} out - output array -* @returns {Float32Array} - output array containing the rotation parameters +* @param {Float64Array} param - output array +* @param {integer} stride - index increment +* @param {NonNegativeInteger} offset - starting index +* @returns {Float64Array} - output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var out = srotmg( -3.0, -4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); -* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +* var out = srotmg( 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 srotmg( d1, d2, x1, y1, out, stride, offset ) { - var param; +function srotmg( d1, d2, x1, y1, param, stride, offset ) { + var flag; + var temp; var ad1; var ad2; - var c; - var s; - var r; - if ( isnan(d1) || isnan(d2) || isnan(x1) || isnan(y1) ) { - c = NaN; - s = NaN; - param = NaN; - x1 = NaN; - y1 = NaN; + var h11; + var h12; + var h21; + var h22; + var p1; + var p2; + var q1; + var q2; + var u; + + if ( isnanf( d1 ) || isnanf( d2 ) || isnanf( x1 ) || isnanf( 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 { - if ( d1 == 0.0 ) { - c = 0.0; - s = 1.0; + p2 = d2 * y1; + if ( p2 === 0.0 ) { + flag = -2.0; + param[ offset ] = flag; + return param; + } + p1 = float64ToFloat32( d1 * x1 ); + q2 = float64ToFloat32( p2 * y1 ); + q1 = float64ToFloat32( p1 * x1 ); + ad1 = absf( q1 ); + ad2 = absf( q2 ); + + if ( ad1 > ad2 ) { + h21 = float64ToFloat32( -y1 / x1 ); + h12 = float64ToFloat32( p2 / p1 ); + u = float64ToFloat32( 1 - float64ToFloat32( h12 * h21 ) ); + if ( u > 0.0 ) { + flag = 0.0; + d1 = float64ToFloat32( d1 / u ); + d2 = float64ToFloat32( d2 / u ); + x1 = float64ToFloat32( 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; - y1 = 0.0; - param = 0.0; } else { - ad1 = absf(d1); - ad2 = absf(d2); - if ( ad1 > ad2 ) { - r = float64ToFloat32(d1 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d2 / d1))))); - c = float64ToFloat32(d1 / r); - s = float64ToFloat32(d2 / r); - param = 1.0; - } else { - r = float64ToFloat32(d2 * sqrtf(float64ToFloat32(1 + abs2f(float64ToFloat32(d1 / d2))))); - c = float64ToFloat32(d1 / r); - s = float64ToFloat32(d2 / r); - param = 2.0; + flag = 1.0; + h11 = float64ToFloat32( p1 / p2 ); + h22 = float64ToFloat32( x1 / y1 ); + u = float64ToFloat32( 1 + float64ToFloat32( h11 * h22 ) ); + temp = float64ToFloat32( d2 / u ); + d2 = float64ToFloat32( d1 / u ); + d1 = temp; + x1 = float64ToFloat32( 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 = float64ToFloat32( d1 * GAM * GAM ); + x1 = float64ToFloat32( x1 / GAM ); + h11 = float64ToFloat32( h11 / GAM ); + h12 = float64ToFloat32( h12 / GAM ); + } else { + d1 = float64ToFloat32( d1 / GAM * GAM ); + x1 = float64ToFloat32( x1 * GAM ); + h11 = float64ToFloat32( h11 * GAM ); + h12 = float64ToFloat32( h12 * GAM ); + } } } - if (d2 == 0.0 ) { - c = 1.0; - s = 0.0; - param = 1.0; + + if ( d2 !== 0.0 ) { + while ( ( absf( d2 ) < RGAM_SQ ) || ( absf( 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 ( absf( d2 ) < RGAM_SQ ) { + d2 = float64ToFloat32( d2 * GAM * GAM ); + h21 = float64ToFloat32( h21 / GAM ); + h22 = float64ToFloat32( h22 / GAM ); + } else { + d2 = float64ToFloat32( d2 / GAM * GAM ); + h21 = float64ToFloat32( h21 * GAM ); + h22 = float64ToFloat32( h22 * GAM ); + } + } } } - out[ offset ] = c; - out[ offset + stride ] = s; - out[ offset + ( 2 * stride ) ] = param; - out[ offset + ( 3 * stride ) ] = x1; - out[ offset + ( 4 * stride ) ] = y1; - return out; + 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; } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js index 99390f0320e0..b76d2b0f68db 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js @@ -26,8 +26,11 @@ * @example * var srotmg = require( '@stdlib/blas/base/srotmg' ); * -* var out = srotmg( 3.0, -4.0, 1.5, 2.5 ); -* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +* var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* +* var out = srotmg( 4.0, 6.0, 2.0, 1.0 ); +* // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -35,8 +38,8 @@ * * var out = new Float32Array( 5 ); * -* var y = srotmg.assign( 3.0, -4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); -* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +* var y = srotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] * * var bool = ( y === out ); * // returns true diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js index 0c0dac169119..5d716dbf2c27 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js @@ -36,8 +36,8 @@ var fcn = require( './assign.js' ); * @returns {Float32Array} output array containing the rotation parameters * * @example -* var out = srotmg( -3.0, -4.0, 1.5, 2.5 ); -* // returns [ 0.6, 0.8, 2.0, 1.5, 2.5 ] +* var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] */ function srotmg( d1, d2, x1, y1 ) { var out = new Float32Array( 5 ); From cadf4dc826be6b92d0793bff9a1bb28bf2059313 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 1 Mar 2025 18:06:17 +0530 Subject: [PATCH 07/12] fix: update files --- .../@stdlib/blas/base/srotmg/docs/repl.txt | 8 +- .../@stdlib/blas/base/srotmg/lib/assign.js | 8 +- .../blas/base/srotmg/test/test.assign.js | 194 ++++++++++++------ .../blas/base/srotmg/test/test.main.js | 104 +++++++--- 4 files changed, 210 insertions(+), 104 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt index 83c9fc785f52..69b857733f12 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt @@ -23,8 +23,8 @@ Examples -------- - > var out = {{alias}}( 1.0, 1.0, 1.0, 0.0 ) - [ -2.0, 0.0, 0.0, 1.0, 0.0 ] + > 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 ) @@ -61,8 +61,8 @@ Examples -------- > var out = new {{alias:@stdlib/array/float32}}( 5 ); - > var y = {{alias}}.assign( 1.0, 1.0, 1.0, 0.0, out, 1, 0 ) - [ -2.0, 0.0, 0.0, 1.0, 0.0 ] + > 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 diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js index 327e039a3754..580bd027f1de 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -41,16 +41,16 @@ var RGAM_SQ = 5.9604645e-8; * @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 {Float32Array} param - output array * @param {integer} stride - index increment * @param {NonNegativeInteger} offset - starting index -* @returns {Float64Array} - output array +* @returns {Float32Array} - output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var out = srotmg( 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 out = srotmg( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] */ function srotmg( d1, d2, x1, y1, param, stride, offset ) { var flag; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js index 08335efbbf7b..79e39801cf39 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -22,6 +22,7 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var srotmg = require( './../lib/assign.js' ); @@ -42,37 +43,54 @@ tape( 'the function has an arity of 7', function test( t ) { tape( 'the function constructs the 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 = [ - [ 0.8944271802902222, 0.4472135901451111, 1.0, 1.0, 3.0 ], - [ 0.3162277638912201, 0.9486832618713379, 2.0, -4.0, -5.0 ], - [ 0.7071067690849304, 0.7071067690849304, 2.0, 2.0, 6.0 ], - [ 0.6, 0.8, 2.0, -2.0, -4.0 ], - [ 0.6, 0.8, 2.0, 1.5, 2.5 ], - [ 0.906183123588562, 0.4228854477405548, 1.0, -1.50, -2.50 ], - [ 0.4472135901451111, 0.8944271802902222, 2.0, 3.50, -7.50 ], - [ 0.800000011920929, 0.6000000238418579, 1.0, 4.50, -9.50 ] + [ 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 = [ - [ 4.0, 2.0, 1.0, 3.0 ], - [ 1.0, 3.0, -4.0, -5.0 ], - [ 5.0, 5.0, 2.0, 6.0 ], - [ 6.0, 8.0, -2.0, -4.0 ], - [ -3.0, -4.0, 1.5, 2.5 ], - [ -7.5, -3.5, -1.5, -2.5 ], - [ 10.0, 20.0, 3.5, -7.5 ], - [ -8.0, -6.0, 4.5, -9.5 ] + [ 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 Float32Array( expected[i] ); + e = new Float32Array( expected[i] ); out = new Float32Array( 5 ); - srotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); // eslint-disable-line max-len - t.deepEqual( out, expected[i], 'returns expected value' ); + srotmg( float64ToFloat32( values[i][0] ), float64ToFloat32( values[i][1] ), float64ToFloat32( values[i][2] ), float64ToFloat32( 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(); }); @@ -80,137 +98,179 @@ tape( 'the function returns an array of NaNs if provided a rotation elimination var actual; var i; - actual = srotmg( NaN, 1.0, 2.0, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( NaN, 1.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 2.0, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, NaN, 3.0, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, NaN, 3.0, 4.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( NaN, NaN, 3.0, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, NaN, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 4 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 2.0, NaN, 3.0, new Float32Array( 4 ), 1, 0 ); + + actual = srotmg( NaN, 2.0, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 1.0, 2.0, NaN, new Float32Array( 4 ), 1, 0 ); + + actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 4 ), 1, 0 ); + + actual = srotmg( NaN, 2.0, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - t.end(); -}); -tape( 'the function returns an array of zeros except s equals to 1 if provided scaling factor for the first vector component equal to 0', function test(t) { - var actual; - var i; - actual = srotmg( 0.0, 1.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, NaN, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { - if ( i === 1 ) { - t.strictEqual( actual[ i ], 1.0, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], 0.0, 'returns expected value' ); - } + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - t.end(); -}); -tape( 'the function returns an array with c, s value equal to 0 and param value value equal to 1 if provided scaling factor for the second vector component equal to 0', function test(t) { - var actual; - var i; + actual = srotmg( 1.0, NaN, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } - actual = srotmg( 1.0, 0.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); - for ( i = 0; i < ( actual.length - 2 ); i++ ) { - if ( i === 1 ) { - t.strictEqual( actual[ i ], 0.0, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], 1.0, 'returns expected value' ); - } + actual = srotmg( NaN, NaN, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, 2.0, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, NaN, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - console.log(actual); 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 Float32Array( [ 0.857492983341217, 0.0, 0.5144957900047302, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0 ] ); + expected = new Float32Array( [ 1.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5 ] ); out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, 2, 0 ); + actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 0 ); t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, '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 Float32Array( [ 1.0, 0.0, 0.5144957900047302, 0.0, 0.857492983341217, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 1.0 ] ); + out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, -2, 4 ); + actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, -2, 8 ); t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, '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 an offset', function test(t) { var expected; var actual; + var delta; + var tol; var out; + var i; - expected = new Float32Array( [ 0.0, 0.857492983341217, 0.5144957900047302, 1.0, 1.0, 2.0 ] ); + expected = new Float32Array( [ 0.0, 1.0, 0.375, 0.0, 0.0, 0.5 ] ); out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, 1, 1 ); + actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 1, 1 ); t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, '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 Float32Array( [ 0.0, 0.0, 0.857492983341217, 0.0, 0.5144957900047302, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0 ] ); // eslint-disable-line max-len + expected = new Float32Array( [ 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 Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = srotmg( 5.0, 3.0, 1.0, 2.0, out, 2, 2 ); + actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 2 ); t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, '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/srotmg/test/test.main.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js index 1d93ea3f6b3e..0760bd410c1a 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js @@ -43,34 +43,52 @@ tape( 'the function has an arity of 4', function test( t ) { tape( 'the function constructs the 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 = [ - [ 0.8944271802902222, 0.4472135901451111, 1.0, 1.0, 3.0 ], - [ 0.3162277638912201, 0.9486832618713379, 2.0, -4.0, -5.0 ], - [ 0.7071067690849304, 0.7071067690849304, 2.0, 2.0, 6.0 ], - [ 0.6, 0.8, 2.0, -2.0, -4.0 ], - [ 0.6, 0.8, 2.0, 1.5, 2.5 ], - [ 0.906183123588562, 0.4228854477405548, 1.0, -1.50, -2.50 ], - [ 0.4472135901451111, 0.8944271802902222, 2.0, 3.50, -7.50 ], - [ 0.800000011920929, 0.6000000238418579, 1.0, 4.50, -9.50 ] + [ 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 = [ - [ 4.0, 2.0, 1.0, 3.0 ], - [ 1.0, 3.0, -4.0, -5.0 ], - [ 5.0, 5.0, 2.0, 6.0 ], - [ 6.0, 8.0, -2.0, -4.0 ], - [ -3.0, -4.0, 1.5, 2.5 ], - [ -7.5, -3.5, -1.5, -2.5 ], - [ 10.0, 20.0, 3.5, -7.5 ], - [ -8.0, -6.0, 4.5, -9.5 ] + [ 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 Float32Array( expected[i] ); - out = srotmg( float64ToFloat32( values[i][0] ), float64ToFloat32( values[i][1] ), float64ToFloat32( values[i][2] ), float64ToFloat32( values[i][3] ) , out, 1, 0 ); // eslint-disable-line max-len - t.deepEqual( out, expected[i], 'returns expected value' ); + e = new Float32Array( expected[i] ); + srotmg( float64ToFloat32( values[i][0] ), float64ToFloat32( values[i][1] ), float64ToFloat32( values[i][2] ), float64ToFloat32( values[i][3] ) ); + 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(); }); @@ -79,49 +97,77 @@ tape( 'the function returns an array of NaNs if provided a rotational eliminatio var actual; var i; - actual = srotmg( NaN, 1.0, 2.0, 3.0 ); + actual = srotmg( NaN, 1.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 2.0, 3.0 ); + actual = srotmg( 1.0, NaN, 3.0, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, 3.0 ); + actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, 3.0, NaN ); + actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, NaN, 3.0, 4.0 ); + actual = srotmg( NaN, NaN, 3.0, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, NaN, 3.0 ); + actual = srotmg( 1.0, NaN, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, NaN ); + actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 2.0, NaN, 3.0 ); + + actual = srotmg( NaN, 2.0, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, 2.0, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 1.0, 2.0, NaN ); + + actual = srotmg( NaN, NaN, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 3.0, NaN ); + + actual = srotmg( 1.0, NaN, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, NaN, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, 2.0, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + actual = srotmg( NaN, NaN, NaN, NaN, new Float32Array( 5 ), 1, 0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } From e5bd843f6c5aaeaa0266379b0bc6e95e66c1cc44 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 2 Mar 2025 23:09:16 +0530 Subject: [PATCH 08/12] fix: file errors --- .../@stdlib/blas/base/srotmg/README.md | 12 +- .../blas/base/srotmg/benchmark/benchmark.js | 0 .../@stdlib/blas/base/srotmg/docs/repl.txt | 10 +- .../blas/base/srotmg/docs/types/index.d.ts | 26 ++-- .../blas/base/srotmg/docs/types/test.ts | 32 ++-- .../blas/base/srotmg/examples/index.js | 10 +- .../@stdlib/blas/base/srotmg/lib/assign.js | 4 +- .../@stdlib/blas/base/srotmg/lib/index.js | 10 +- .../@stdlib/blas/base/srotmg/lib/main.js | 10 +- .../@stdlib/blas/base/srotmg/package.json | 144 +++++++++--------- .../blas/base/srotmg/test/test.assign.js | 22 +-- .../@stdlib/blas/base/srotmg/test/test.js | 0 .../blas/base/srotmg/test/test.main.js | 6 +- 13 files changed, 149 insertions(+), 137 deletions(-) mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/README.md mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/package.json mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/test/test.js mode change 100644 => 100755 lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/README.md b/lib/node_modules/@stdlib/blas/base/srotmg/README.md old mode 100644 new mode 100755 index 0b6bc5a12346..cb3cb3c2d099 --- a/lib/node_modules/@stdlib/blas/base/srotmg/README.md +++ b/lib/node_modules/@stdlib/blas/base/srotmg/README.md @@ -32,11 +32,11 @@ var srotmg = require( '@stdlib/blas/base/srotmg' ); #### srotmg( d1, d2, x1, y1 ) -Constructs a Givens plane rotation provided two single-precision floating-point values `d1` and `d2`. +Constructs a Givens plane rotation provided four single-precision floating-point values `d1`, `d2`, `x1` and `y1`. ```javascript -var out = srotmg( -3.0, -4.0, 1.5, 2.5 ); -// returns [ 0.6000000238418579, 0.800000011920929, 2, 1.5, 2.5 ] +var out = srotmg( 5.0, 4.0, 1.0, -2.0 ); +// returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] ``` The function has the following parameters: @@ -48,15 +48,15 @@ The function has the following parameters: #### srotmg.assign( d1, d2, x1, y1, out, stride, offset ) -Constructs a Givens plane rotation provided two single-precision floating-point values `d1` and `d2` and assigns results to an output array. +Constructs a Givens plane rotation provided two single-precision floating-point values `d1`, `d2`, `x1` and `y1` and assigns results to an output array. ```javascript var Float32Array = require( '@stdlib/array/float32' ); var out = new Float32Array( 5 ); -var y = srotmg.assign( -3.0, -4.0, 1.5, 2.5, out, 1, 0 ); -// returns [ 0.6000000238418579, 0.800000011920929, 2, 1.5, 2.5 ] +var y = srotmg.assign( 5.0, 4.0, 1.0, -2.0, out, 1, 0 ); +// returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] var bool = ( y === out ); // returns true diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js old mode 100644 new mode 100755 diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt old mode 100644 new mode 100755 index 69b857733f12..b2ad218411dd --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt @@ -23,11 +23,11 @@ Examples -------- - > var out = {{alias}}( 3.0, 4.0, 1.5, 2.5 ) - [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + > var out = {{alias}}( 5.0, 4.0, 1.0, -2.0 ) + [ 1.0, -0.625, 0.0, 0.0, -0.5 ] -{{alias}}.assign( d1, d2, x1. y1, out, stride, offset ) +{{alias}}.assign( d1, d2, x1, y1, out, stride, offset ) Constructs the parameters for a modified Givens plane rotation. Parameters @@ -61,8 +61,8 @@ Examples -------- > var out = new {{alias:@stdlib/array/float32}}( 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 y = {{alias}}.assign( 5.0, 4.0, 1.0, -2.0, out, 1, 0 ) + [ 1.0, -0.625, 0.0, 0.0, -0.5 ] > var bool = ( y === out ) true diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts old mode 100644 new mode 100755 index 6981d54a5b70..5f139aa22240 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -22,7 +22,7 @@ * Inteface describing `srotmg`. */ interface Routine { - /** + /** * Constructs the parameters for a modified Givens plane rotation. * * @param d1 - scaling factor for the first vector component @@ -32,16 +32,16 @@ interface Routine { * @returns - output array containing the rotation parameters * * @example - * var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); - * // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + * var out = srotmg( 5.0, 4.0, 1.0, -2.0 ); + * // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] * * @example * var out = srotmg( 4.0, 6.0, 2.0, 1.0 ); * // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] */ - ( d1: number, d2: number, x1: number, y1: number ): Float32Array; + ( d1: number, d2: number, x1: number, y1: number ): Float32Array; - /** + /** * Constructs the parameters for a modified Givens plane rotation. * * @param d1 - scaling factor for the first vector component @@ -58,13 +58,13 @@ interface Routine { * * var out = new Float32Array( 5 ); * - * var y = srotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); - * // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + * var y = srotmg.assign( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); + * // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] * * var bool = (y === out); * // returns true */ - assign( d1: number, d2: number, x1: number, y1: number, out: Float32Array, stride: number, offset: number ): Float32Array; + assign( d1: number, d2: number, x1: number, y1: number, out: Float32Array, stride: number, offset: number ): Float32Array; } /** @@ -79,17 +79,17 @@ interface Routine { * @param offset - starting index * @returns - output array containing the rotation parameters * -@example -* var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); -* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] + * @example +* var out = srotmg( 5.0, 4.0, 1.0, -2.0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var out = new Float32Array( 5 ); * -* var y = srotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); -* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* var y = srotmg.assign( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] * * var bool = (y === out); * // returns true diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts old mode 100644 new mode 100755 index a4864e2a1995..892a25ff2b96 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts @@ -44,7 +44,7 @@ import srotmg = require( './index' ); srotmg( 0.0, [], 2.0, 3.0 ); // $ExpectError srotmg( 0.0, {}, 2.0, 3.0 ); // $ExpectError - srotmg( 0.0, 1.0, true, 3.0 ); // $ExpectError + srotmg( 0.0, 1.0, true, 3.0 ); // $ExpectError srotmg( 0.0, 1.0, false, 3.0 ); // $ExpectError srotmg( 0.0, 1.0, null, 3.0 ); // $ExpectError srotmg( 0.0, 1.0, undefined, 3.0 ); // $ExpectError @@ -52,7 +52,7 @@ import srotmg = require( './index' ); srotmg( 0.0, 1.0, [], 3.0 ); // $ExpectError srotmg( 0.0, 1.0, {}, 3.0 ); // $ExpectError - srotmg( 0.0, 1.0, 2.0, true ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, true ); // $ExpectError srotmg( 0.0, 1.0, 2.0, false ); // $ExpectError srotmg( 0.0, 1.0, 2.0, null ); // $ExpectError srotmg( 0.0, 1.0, 2.0, undefined ); // $ExpectError @@ -66,8 +66,8 @@ import srotmg = require( './index' ); srotmg(); // $ExpectError srotmg( 0.0 ); // $ExpectError srotmg( 0.0, 1.0 ); // $ExpectError - srotmg( 0.0, 1.0, 2.0 ); // $ExpectError - srotmg( 0.0, 1.0, 2.0, 3.0, 4.0 ); // $ExpectError + srotmg( 0.0, 1.0, 2.0 ); // $ExpectError + srotmg( 0.0, 1.0, 2.0, 3.0, 4.0 ); // $ExpectError } // Attached to the main export is an `assign` method which returns a Float32Array... @@ -97,15 +97,15 @@ import srotmg = require( './index' ); srotmg.assign( 0.0, [], 3.0, 4.0, out, 1, 0 ); // $ExpectError srotmg.assign( 0.0, {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,true, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,false, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,null, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,undefined, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,'5', 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,[], 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0 ,{}, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, true, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, false, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, null, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, undefined, 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, '5', 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, [], 4.0, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, {}, 4.0, out, 1, 0 ); // $ExpectError - srotmg.assign( 0.0, 2.0, 3.0, true, out, 1, 0 ); // $ExpectError + srotmg.assign( 0.0, 2.0, 3.0, true, out, 1, 0 ); // $ExpectError srotmg.assign( 0.0, 2.0, 3.0, false, out, 1, 0 ); // $ExpectError srotmg.assign( 0.0, 2.0, 3.0, null, out, 1, 0 ); // $ExpectError srotmg.assign( 0.0, 2.0, 3.0, undefined, out, 1, 0 ); // $ExpectError @@ -148,10 +148,10 @@ import srotmg = require( './index' ); srotmg.assign( 1.0, 2.0, out ); // $ExpectError srotmg.assign( 1.0, 2.0, out, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, out, 1, 0, 1 ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0 ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0, out ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError - srotmg.assign( 1.0, 2.0, 3.0, out, 1, 0, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out, 1 ); // $ExpectError + srotmg.assign( 1.0, 2.0, 3.0, out, 1, 0, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, 3.0, 4.0, out ); // $ExpectError srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1 ); // $ExpectError srotmg.assign( 1.0, 2.0, 3.0, 4.0, out, 1, 0, 1 ); // $ExpectError diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js old mode 100644 new mode 100755 index 554c8922453b..a6a4a4f5dfb9 --- a/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js @@ -23,7 +23,15 @@ var srotmg = require( './../lib' ); var out; var i; +var d1; +var d2; +var x1; +var y1; for ( i = 0; i < 100; i++ ) { - out = srotmg( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ), discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + d1 = discreteUniform( -5, 5 ); + d2 = discreteUniform( -5, 5 ); + x1 = discreteUniform( -5, 5 ); + y1 = discreteUniform( -5, 5 ); + out = srotmg( d1, d2, x1, y1 ); console.log( out ); } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js old mode 100644 new mode 100755 index 580bd027f1de..59766c55410a --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -49,8 +49,8 @@ var RGAM_SQ = 5.9604645e-8; * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var out = srotmg( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); -* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* var out = srotmg( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] */ function srotmg( d1, d2, x1, y1, param, stride, offset ) { var flag; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js old mode 100644 new mode 100755 index b76d2b0f68db..b4369707c6d8 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js @@ -19,15 +19,15 @@ 'use strict'; /** -* Constructs the parameters for a modified Givens plane rotation. +* Construct the parameters for a modified Givens plane rotation. * * @module @stdlib/blas/base/srotmg * * @example * var srotmg = require( '@stdlib/blas/base/srotmg' ); * -* var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); -* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* var out = srotmg( 5.0, 4.0, 1.0, -2.0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] * * var out = srotmg( 4.0, 6.0, 2.0, 1.0 ); * // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] @@ -38,8 +38,8 @@ * * var out = new Float32Array( 5 ); * -* var y = srotmg.assign( 3.0, 4.0, 1.5, 2.5, new Float32Array( 5 ), 1, 0 ); -* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* var y = srotmg.assign( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] * * var bool = ( y === out ); * // returns true diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js old mode 100644 new mode 100755 index 5d716dbf2c27..ac7b46c1180e --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js @@ -27,7 +27,7 @@ var fcn = require( './assign.js' ); // MAIN // /** -* Constructs the parameters for a modified Givens plane rotation. +* 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 @@ -36,12 +36,12 @@ var fcn = require( './assign.js' ); * @returns {Float32Array} output array containing the rotation parameters * * @example -* var out = srotmg( 3.0, 4.0, 1.5, 2.5 ); -* // returns [ 1.0, 0.45, 0.0, 0.0, 0.6 ] +* var out = srotmg( 5.0, 4.0, 1.0, -2.0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] */ function srotmg( d1, d2, x1, y1 ) { - var out = new Float32Array( 5 ); - return fcn( d1, d2, x1, y1, out, 1, 0 ); + var out = new Float32Array( 5 ); + return fcn( d1, d2, x1, y1, out, 1, 0 ); } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/package.json b/lib/node_modules/@stdlib/blas/base/srotmg/package.json old mode 100644 new mode 100755 index e939baedee91..b37b0a1bda68 --- a/lib/node_modules/@stdlib/blas/base/srotmg/package.json +++ b/lib/node_modules/@stdlib/blas/base/srotmg/package.json @@ -1,75 +1,75 @@ { - "name": "@stdlib/blas/base/srotmg", - "version": "0.0.0", - "description": "Constructs the parameters for a modified Givens plane rotation.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/blas/base/srotmg", + "version": "0.0.0", + "description": "Constructs the parameters for a modified 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" - }, - "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", - "srotmg", - "parameters", - "modified", - "givens", - "rotation", - "matrix", - "linear", - "algebra", - "subroutines", - "vector", - "array", - "ndarray", - "float32", - "float", - "single", - "float32array" - ] - } + } + ], + "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", + "srotmg", + "parameters", + "modified", + "givens", + "rotation", + "matrix", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "float32", + "float", + "single", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js old mode 100644 new mode 100755 index 79e39801cf39..7f972abc01a7 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -23,7 +23,9 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var absf = require( '@stdlib/math/base/special/absf' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); var srotmg = require( './../lib/assign.js' ); @@ -85,8 +87,8 @@ tape( 'the function constructs the parameters for a modified Givens plane rotati 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] ); + delta = absf( out[j] - e[j] ); + tol = 1.5 * EPS * absf( e[j] ); t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); } } @@ -192,8 +194,8 @@ tape( 'the function supports providing a positive stride', function test(t) { 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] ); + delta = absf( out[i] - expected[i] ); + tol = 1.5 * EPS * absf( expected[i] ); t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } @@ -217,8 +219,8 @@ tape( 'the function supports providing a negative stride', function test(t) { 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] ); + delta = absf( out[i] - expected[i] ); + tol = 1.5 * EPS * absf( expected[i] ); t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } @@ -242,8 +244,8 @@ tape( 'the function supports providing an offset', function test(t) { 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] ); + delta = absf( out[i] - expected[i] ); + tol = 1.5 * EPS * absf( expected[i] ); t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } @@ -267,8 +269,8 @@ tape( 'the function supports providing both a stride and offset', function test( 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] ); + delta = absf( out[i] - expected[i] ); + tol = 1.5 * EPS * absf( expected[i] ); t.ok( delta <= tol, 'within tolerance. out: '+out[i]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js old mode 100644 new mode 100755 diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js old mode 100644 new mode 100755 index 0760bd410c1a..63395a6d48f0 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js @@ -23,7 +23,9 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var absf = require( '@stdlib/math/base/special/absf' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); var srotmg = require( './../lib/main.js' ); @@ -84,8 +86,8 @@ tape( 'the function constructs the parameters for a modified Givens plane rotati 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] ); + delta = absf( out[j] - e[j] ); + tol = 1.5 * EPS * absf( e[j] ); t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); } } From 44191704dc0e17572021b9ad61e2f9ea272eee39 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 2 Mar 2025 23:19:12 +0530 Subject: [PATCH 09/12] fix: update test.main.js Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../blas/base/srotmg/test/test.main.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js index 63395a6d48f0..0097267fbb8f 100755 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.main.js @@ -81,7 +81,7 @@ tape( 'the function constructs the parameters for a modified Givens plane rotati for ( i = 0; i < values.length; i++ ) { e = new Float32Array( expected[i] ); - srotmg( float64ToFloat32( values[i][0] ), float64ToFloat32( values[i][1] ), float64ToFloat32( values[i][2] ), float64ToFloat32( values[i][3] ) ); + out = srotmg( float64ToFloat32( values[i][0] ), float64ToFloat32( values[i][1] ), float64ToFloat32( values[i][2] ), float64ToFloat32( values[i][3] ) ); for ( j = 0; j < out.length; j++ ) { if ( out[j] === e[j] ) { t.strictEqual( out[j], e[j], 'returns expected value' ); @@ -99,77 +99,77 @@ tape( 'the function returns an array of NaNs if provided a rotational eliminatio var actual; var i; - actual = srotmg( NaN, 1.0, 2.0, 3.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, 1.0, 2.0, 3.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 3.0, 4.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, NaN, 3.0, 4.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, 3.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, NaN, 3.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, 3.0, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, NaN, 3.0, 4.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, NaN, 3.0, 4.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, NaN, NaN, 4.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, 2.0, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, 2.0, NaN, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 2.0, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, 2.0, NaN, 4.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, NaN, 3.0, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 2.0, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, 2.0, 3.0, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, NaN, NaN, 4.0, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, NaN, NaN, 4.0 ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( 1.0, NaN, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( 1.0, NaN, NaN, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, NaN, 3.0, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, NaN, 3.0, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, 2.0, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, 2.0, NaN, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } - actual = srotmg( NaN, NaN, NaN, NaN, new Float32Array( 5 ), 1, 0 ); + actual = srotmg( NaN, NaN, NaN, NaN ); for ( i = 0; i < actual.length; i++ ) { t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); } From 6393de9900e8babdec00ce5e3fa8fbd62a6df4dc Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 30 Apr 2025 23:30:23 +0530 Subject: [PATCH 10/12] chore: update implementation Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt index b2ad218411dd..51750749c653 100755 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt @@ -28,7 +28,8 @@ {{alias}}.assign( d1, d2, x1, y1, out, stride, offset ) - Constructs the parameters for a modified Givens plane rotation. + Constructs the parameters for a modified Givens plane rotation and assigns + results to an output array. Parameters ---------- From 03f043f9679f013caafcad14a54c87009810d6b2 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 30 Apr 2025 23:31:21 +0530 Subject: [PATCH 11/12] chore: update implementation Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts index 5f139aa22240..22f70fa298ab 100755 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -42,7 +42,7 @@ interface Routine { ( d1: number, d2: number, x1: number, y1: number ): Float32Array; /** - * Constructs the parameters for a modified Givens plane rotation. + * Constructs the parameters for a modified Givens plane rotation and assigns results to an output array. * * @param d1 - scaling factor for the first vector component * @param d2 - scaling factor for the second vector component From 14faf2413c5636673576789e892ef6dc0c658a23 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 1 May 2025 23:07:35 +0530 Subject: [PATCH 12/12] fix: indentation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/srotmg/docs/types/index.d.ts | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts index 22f70fa298ab..2f6d00e0411b 100755 --- a/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -23,47 +23,47 @@ */ 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 = srotmg( 5.0, 4.0, 1.0, -2.0 ); - * // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] - * - * @example - * var out = srotmg( 4.0, 6.0, 2.0, 1.0 ); - * // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] - */ + * 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 = srotmg( 5.0, 4.0, 1.0, -2.0 ); + * // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] + * + * @example + * var out = srotmg( 4.0, 6.0, 2.0, 1.0 ); + * // returns [ 0.0, 0.0, -0.5, 0.75, 0.0 ] + */ ( d1: number, d2: number, x1: number, y1: number ): Float32Array; /** - * Constructs the parameters for a modified Givens plane rotation and assigns results to an output array. - * - * @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 Float32Array = require( '@stdlib/array/float32' ); - * - * var out = new Float32Array( 5 ); - * - * var y = srotmg.assign( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); - * // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] - * - * var bool = (y === out); - * // returns true - */ + * Constructs the parameters for a modified Givens plane rotation and assigns results to an output array. + * + * @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 Float32Array = require( '@stdlib/array/float32' ); + * + * var out = new Float32Array( 5 ); + * + * var y = srotmg.assign( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); + * // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] + * + * var bool = (y === out); + * // returns true + */ assign( d1: number, d2: number, x1: number, y1: number, out: Float32Array, stride: number, offset: number ): Float32Array; }