From fb98a6e1d6980d10bef40ce19efb26e564adff12 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Mon, 12 Jan 2026 22:02:33 +0530 Subject: [PATCH 1/6] feat: add blas/base/srotmg --- 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: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: skipped - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: skipped - task: lint_javascript_benchmarks status: skipped - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: skipped - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/srotmg/README.md | 262 ++++++++++ .../base/srotmg/benchmark/benchmark.assign.js | 68 +++ .../benchmark/benchmark.assign.native.js | 73 +++ .../blas/base/srotmg/benchmark/benchmark.js | 65 +++ .../base/srotmg/benchmark/benchmark.native.js | 70 +++ .../blas/base/srotmg/benchmark/c/Makefile | 146 ++++++ .../srotmg/benchmark/c/benchmark.length.c | 219 ++++++++ .../base/srotmg/benchmark/fortran/Makefile | 141 +++++ .../benchmark/fortran/benchmark.length.f | 228 ++++++++ .../@stdlib/blas/base/srotmg/binding.gyp | 265 ++++++++++ .../@stdlib/blas/base/srotmg/docs/repl.txt | 71 +++ .../blas/base/srotmg/docs/types/index.d.ts | 97 ++++ .../blas/base/srotmg/docs/types/test.ts | 158 ++++++ .../blas/base/srotmg/examples/c/Makefile | 146 ++++++ .../blas/base/srotmg/examples/c/example.c | 51 ++ .../blas/base/srotmg/examples/index.js | 37 ++ .../@stdlib/blas/base/srotmg/include.gypi | 70 +++ .../srotmg/include/stdlib/blas/base/srotmg.h | 48 ++ .../include/stdlib/blas/base/srotmg_cblas.h | 43 ++ .../include/stdlib/blas/base/srotmg_fortran.h | 41 ++ .../@stdlib/blas/base/srotmg/lib/assign.js | 202 ++++++++ .../blas/base/srotmg/lib/assign.native.js | 54 ++ .../@stdlib/blas/base/srotmg/lib/index.js | 71 +++ .../@stdlib/blas/base/srotmg/lib/main.js | 35 ++ .../@stdlib/blas/base/srotmg/lib/native.js | 35 ++ .../@stdlib/blas/base/srotmg/lib/srotmg.js | 50 ++ .../blas/base/srotmg/lib/srotmg.native.js | 51 ++ .../@stdlib/blas/base/srotmg/manifest.json | 485 ++++++++++++++++++ .../@stdlib/blas/base/srotmg/package.json | 77 +++ .../@stdlib/blas/base/srotmg/src/Makefile | 70 +++ .../@stdlib/blas/base/srotmg/src/addon.c | 67 +++ .../@stdlib/blas/base/srotmg/src/srotmg.c | 37 ++ .../@stdlib/blas/base/srotmg/src/srotmg.f | 217 ++++++++ .../blas/base/srotmg/src/srotmg_assign.c | 181 +++++++ .../blas/base/srotmg/src/srotmg_cblas.c | 52 ++ .../@stdlib/blas/base/srotmg/src/srotmg_f.c | 84 +++ .../blas/base/srotmg/test/test.assign.js | 277 ++++++++++ .../base/srotmg/test/test.assign.native.js | 205 ++++++++ .../@stdlib/blas/base/srotmg/test/test.js | 84 +++ .../blas/base/srotmg/test/test.srotmg.js | 176 +++++++ .../base/srotmg/test/test.srotmg.native.js | 103 ++++ 41 files changed, 4912 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.assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/binding.gyp 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/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg.h create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.native.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/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.f create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_f.c 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.assign.native.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.srotmg.js create mode 100644 lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.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..29ea27eca926 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/README.md @@ -0,0 +1,262 @@ + + +# srotmg + +> Construct a Givens plane rotation. + +
+ +## Usage + +```javascript +var srotmg = require( '@stdlib/blas/base/srotmg' ); +``` + +#### srotmg( d1, d2, x1, y1 ) + +Constructs a Givens plane rotation provided four single-precision floating-point values `d1`, `d2`, `x1` and `y1`. + +```javascript +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: + +- **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, 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( 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 +``` + +
+ + + +
+ +## Notes + +- `srotmg()` corresponds to the [BLAS][blas] level 1 function [`srotmg`][srotmg]. + +
+ + + +## Examples + +
+ +```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 ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/srotmg.h" +``` + +#### c_srotmg( d1, d2, x1, y1, \*Out, strideOut ) + +Constructs a Givens plane rotation provided four single-precision floating-point values `d1`, `d2`, `x1` & `y1`and assigns results to an output array. + + +```c +float Out[5]; + +c_srotmg( 5.0, 4.0, 1.0, -2.0, Out, 1 ); +// Out => [ 1.0, -0.625, 0.0, 0.0, -0.5] +``` + +The function accepts the following arguments: + +- **d1**: `[in] float` scaling factor for the first vector component. +- **d2**: `[in] float` scaling factor for the second vector component. +- **x1**: `[in] float` first component of the first vector. +- **y1**: `[in] float` first component of the second vector. +- **Out**: `[inout] float*` output array. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. + + +```c +void c_srotmg( float d1, float d2, float x1, float y1, float* Out, const CBLAS_INT strideOut ); +``` + +#### c_srotmg_assign( d1, d2, x1, y1, \*Out, strideOut, offsetOut ) + +Constructs a Givens plane rotation provided four single-precision floating-point values `d1`, `d2`, `x1` & `y1`and assigns results to an output array using alternative indexing semantics.. + +```c +float Out[5]; + +c_srotmg( 5.0, 4.0, 1.0, -2.0, Out, 1, 0 ); +// Out => [ 1.0, -0.625, 0.0, 0.0, -0.5] +``` + +The function accepts the following arguments: + +- **d1**: `[in] float` scaling factor for the first vector component. +- **d2**: `[in] float` scaling factor for the second vector component. +- **x1**: `[in] float` first component of the first vector. +- **y1**: `[in] float` first component of the second vector. +- **Out**: `[inout] float*` output array. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. + +Givens transformation. + +```c +void c_srotmg_assign( float d1, float d2, float x1, float y1, float* Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/srotg.h" +#include + +int main( void ) { + const float d1 = 5.0; + const float d2 = 4.0; + const float x1 = 1.0; + const float y1 = -2.0; + int i; + + // Create strided arrays: + float out[ 5 ]; + + // Specify stride lengths: + const int strideOut = 1; + + // Apply plane rotation: + c_srotmg( d1, d2, x1, y1, out, stride ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "out[%d] = %f\n", i, out[ i ] ); + } + + // Apply plane rotation + c_srotmg_assign( d1, d2, x1, y1, out, stride, 0 ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "out[%d] = %f\n", i, out[ i ] ); + } +} + +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..3dc9ebddc3d6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/assign.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +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, options ); + d2 = discreteUniform( 100, -5, 5, options ); + x1 = discreteUniform( 100, -5, 5, options ); + y1 = discreteUniform( 100, -5, 5, options ); + out = new Float32Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = srotmg( 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/benchmark/benchmark.assign.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js new file mode 100644 index 000000000000..5f59551729bb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +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 tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var srotmg = tryRequire(resolve(__dirname, './../lib/assign.native.js')); +var opts = { + 'skip': (srotmg instanceof Error) +}; +var options = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg+':assign::native', opts, function benchmark( b ) { + var out; + var d1; + var d2; + var x1; + var y1; + var z; + var i; + + d1 = discreteUniform( 100, -5, 5, options ); + d2 = discreteUniform( 100, -5, 5, options ); + x1 = discreteUniform( 100, -5, 5, options ); + y1 = discreteUniform( 100, -5, 5, options ); + out = new Float32Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = srotmg( 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/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js new file mode 100644 index 000000000000..5c2c0f990a9e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 pkg = require( './../package.json' ).name; +var srotmg = require( './../lib' ); + + +// VARIABLES // + +var options = { + '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, options ); + d2 = discreteUniform( 100, -5, 5, options ); + x1 = discreteUniform( 100, -5, 5, options ); + y1 = discreteUniform( 100, -5, 5, options ); + + 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js new file mode 100644 index 000000000000..375a20cadf08 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var srotmg = tryRequire(resolve(__dirname, './../lib/native.js')); +var opts = { + 'skip': (srotmg instanceof Error) +}; +var OPTS = { + 'dtype': 'float32' +}; + + +// MAIN // + +bench( pkg+'::native', opts, 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..7a878a6cdbb9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/c/benchmark.length.c @@ -0,0 +1,219 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include +#include "stdlib/blas/base/srotmg.h" +#include +#include +#include +#include + +#define NAME "srotmg" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + double elapsed; + float out[ 5 ]; + float *d1; + float *d2; + float *x1; + float *y1; + double t; + int i; + + d1 = (float *)malloc( len * sizeof( float ) ); + d2 = (float *)malloc( len * sizeof( float ) ); + x1 = (float *)malloc( len * sizeof( float ) ); + y1 = (float *)malloc( len * sizeof( float ) ); + + for ( i = 0; i < len; i++ ) { + d1[ i ] = ( rand_float() * 200.0f ) - 100.0f; + d2[ i ] = ( rand_float() * 200.0f ) - 100.0f; + x1[ i ] = ( rand_float() * 200.0f ) - 100.0f; + y1[ i ] = ( rand_float() * 200.0f ) - 100.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_srotmg( d1[ i % (len) ], d2[ i % (len) ], x1[ i % (len) ], y1[ i % (len) ], out, 1 ); + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( d1 ); + free( d2 ); + free( x1 ); + free( y1 ); + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + float out[ 5 ]; + float *d1; + float *d2; + float *x1; + float *y1; + double t; + int i; + + d1 = (float *)malloc( len * sizeof( float ) ); + d2 = (float *)malloc( len * sizeof( float ) ); + x1 = (float *)malloc( len * sizeof( float ) ); + y1 = (float *)malloc( len * sizeof( float ) ); + + for ( i = 0; i < len; i++ ) { + d1[ i ] = ( rand_float() * 200.0f ) - 100.0f; + d2[ i ] = ( rand_float() * 200.0f ) - 100.0f; + x1[ i ] = ( rand_float() * 200.0f ) - 100.0f; + y1[ i ] = ( rand_float() * 200.0f ) - 100.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_srotmg_assign( d1[ i % (len) ], d2[ i % (len) ], x1[ i % (len) ], y1[ i % (len) ], out, 1, 0 ); + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( d1 ); + free( d2 ); + free( x1 ); + free( y1 ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i - 1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:assign:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/Makefile new file mode 100644 index 000000000000..2fd6f1413234 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling Fortran source files: +ifdef FORTRAN_COMPILER + FC := $(FORTRAN_COMPILER) +else + FC := gfortran +endif + +# Define the command-line options when compiling Fortran files: +FFLAGS ?= \ + -std=f95 \ + -ffree-form \ + -O3 \ + -Wall \ + -Wextra \ + -Wno-compare-reals \ + -Wimplicit-interface \ + -fno-underscoring \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop`): +INCLUDE ?= + +# List of Fortran source files: +SOURCE_FILES ?= ../../src/srotmg.f + +# List of Fortran targets: +f_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles Fortran source files. +# +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [FORTRAN_COMPILER] - Fortran compiler +# @param {string} [FFLAGS] - Fortran compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(f_targets) + +.PHONY: all + +#/ +# Compiles Fortran source files. +# +# @private +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} FC - Fortran compiler +# @param {string} FFLAGS - Fortran compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(f_targets): %.out: %.f + $(QUIET) $(FC) $(FFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(f_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..d6ff47e853ea --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/fortran/benchmark.length.f @@ -0,0 +1,228 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2026 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. +!< + +program bench + implicit none + ! .. + ! Local constants: + character(6), parameter :: name = 'srotmg' ! if changed, be sure to adjust length + integer, parameter :: iterations = 10000000 + integer, parameter :: repeats = 3 + integer, parameter :: min = 1 + integer, parameter :: max = 6 + ! .. + ! Run the benchmarks: + call main() + ! .. + ! Functions: +contains + ! .. + ! Prints the TAP version. + ! .. + subroutine print_version() + print '(A)', 'TAP version 13' + end subroutine print_version + ! .. + ! Prints the TAP summary. + ! + ! @param {integer} total - total number of tests + ! @param {integer} passing - total number of passing tests + ! .. + subroutine print_summary( total, passing ) + ! .. + ! Scalar arguments: + integer, intent(in) :: total, passing + ! .. + ! Local variables: + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + print '(A)', '#' + ! .. + write (str, '(I15)') total ! TAP plan + tmp = adjustl( str ) + print '(A,A)', '1..', trim( tmp ) + ! .. + print '(A,A)', '# total ', trim( tmp ) + ! .. + write (str, '(I15)') passing + tmp = adjustl( str ) + print '(A,A)', '# pass ', trim( tmp ) + ! .. + print '(A)', '#' + print '(A)', '# ok' + end subroutine print_summary + ! .. + ! Prints benchmarks results. + ! + ! @param {integer} iterations - number of iterations + ! @param {double} elapsed - elapsed time in seconds + ! .. + subroutine print_results( iterations, elapsed ) + ! .. + ! Scalar arguments: + double precision, intent(in) :: elapsed + integer, intent(in) :: iterations + ! .. + ! Local variables: + double precision :: rate + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic dble, adjustl, trim + ! .. + rate = dble( iterations ) / elapsed + ! .. + print '(A)', ' ---' + ! .. + write (str, '(I15)') iterations + tmp = adjustl( str ) + print '(A,A)', ' iterations: ', trim( tmp ) + ! .. + write (str, '(f100.9)') elapsed + tmp = adjustl( str ) + print '(A,A)', ' elapsed: ', trim( tmp ) + ! .. + write( str, '(f100.9)') rate + tmp = adjustl( str ) + print '(A,A)', ' rate: ', trim( tmp ) + ! .. + print '(A)', ' ...' + end subroutine print_results + ! .. + ! Runs a benchmark. + ! + ! @param {integer} iterations - number of iterations + ! @param {integer} len - array length + ! @return {double} elapsed time in seconds + ! .. + double precision function benchmark( iterations, len ) + ! .. + ! External functions: + interface + subroutine srotmg( sd1, sd2, sx1, sy1, sparam ) + real :: sd1, sd2, sx1, sy1 + real :: sparam(5) + end subroutine srotmg + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, len + ! .. + ! Local scalars: + double precision :: elapsed, rand_val + real :: t1, t2 + real :: d1, d2, x1, y1 + integer :: i, idx + ! .. + ! Local arrays: + real, allocatable :: vd1(:), vd2(:), vx1(:), vy1(:) + real :: param(5) + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time, mod + ! .. + ! Allocate arrays: + allocate( vd1(len), vd2(len), vx1(len), vy1(len) ) + ! .. + ! Initialize param array to avoid uninitialized warnings: + param(1) = 0.0 + param(2) = 0.0 + param(3) = 0.0 + param(4) = 0.0 + param(5) = 0.0 + ! .. + do i = 1, len + call random_number( rand_val ) + vd1( i ) = ( real(rand_val)*10.0 ) + call random_number( rand_val ) + vd2( i ) = ( real(rand_val)*10.0 ) + call random_number( rand_val ) + vx1( i ) = ( real(rand_val)*200.0 ) - 100.0 + call random_number( rand_val ) + vy1( i ) = ( real(rand_val)*200.0 ) - 100.0 + end do + ! .. + call cpu_time( t1 ) + ! .. + do i = 1, iterations + idx = mod( i-1, len ) + 1 + d1 = vd1( idx ) + d2 = vd2( idx ) + x1 = vx1( idx ) + y1 = vy1( idx ) + call srotmg( d1, d2, x1, y1, param ) + if ( param(1) /= param(1) ) then + print '(A)', 'should not return NaN' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( param(1) /= param(1) ) then + print '(A)', 'should not return NaN' + end if + ! .. + ! Deallocate arrays: + deallocate( vd1, vd2, vx1, vy1 ) + ! .. + benchmark = elapsed + return + end function benchmark + ! .. + ! Main execution sequence. + ! .. + subroutine main() + ! .. + ! Local variables: + integer :: count, iter, len, i, j + double precision :: elapsed + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + call print_version() + count = 0 + do i = min, max + len = 10**i + iter = iterations / 10**(i-1) + do j = 1, repeats + count = count + 1 + ! .. + write (str, '(I15)') len + tmp = adjustl( str ) + print '(A,A,A,A)', '# fortran::', name, ':len=', trim( tmp ) + ! .. + elapsed = benchmark( iter, len ) + ! .. + call print_results( iter, elapsed ) + ! .. + write (str, '(I15)') count + tmp = adjustl( str ) + print '(A,A,A)', 'ok ', trim( tmp ), ' benchmark finished' + end do + end do + call print_summary( count, count ) + end subroutine main +end program bench diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/binding.gyp b/lib/node_modules/@stdlib/blas/base/srotmg/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} 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..51750749c653 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/repl.txt @@ -0,0 +1,71 @@ + +{{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}}( 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 ) + Constructs the parameters for a modified Givens plane rotation and assigns + results to an output array. + + Parameters + ---------- + d1: float + Scaling factor for the first vector component. + + d2: float + Scaling factor for the second vector component. + + x1: float + First component of the first vector. + + y1: float + First component of the second vector. + + out: 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( 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 + + 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..d5a741ee0b48 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/index.d.ts @@ -0,0 +1,97 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 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 ] + * + */ + 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 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( 5.0, 4.0, 1.0, -2.0, new Float32Array( 5 ), 1, 0 ); +* // returns [ 1.0, -0.625, 0.0, 0.0, -0.5 ] +* +*/ +declare var srotmg: Routine; + +// EXPORTS // + +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 new file mode 100644 index 000000000000..3e72300b6821 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/docs/types/test.ts @@ -0,0 +1,158 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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, second, third or fourth 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, 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 sixth 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 seventh 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, 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, 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/c/Makefile b/lib/node_modules/@stdlib/blas/base/srotmg/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/srotmg/examples/c/example.c new file mode 100644 index 000000000000..9ad50e2d59c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/c/example.c @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/base/srotmg.h" +#include + +int main( void ) { + // Specify rotational elimination parameter: + const float d1 = 5.0; + const float d2 = 4.0; + const float x1 = 1.0; + const float y1 = -2.0; + int i; + + // Create strided arrays: + float out[ 5 ]; + + // Specify stride lengths: + const int stride = 1; + + // Apply plane rotation: + c_srotmg( d1, d2, x1, y1, out, stride ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "out[%d] = %f\n", i, out[ i ] ); + } + + // Apply plane rotation + c_srotmg_assign( d1, d2, x1, y1, out, stride, 0 ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "out[%d] = %f\n", i, out[ i ] ); + } +} 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..9cfac72defcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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; +var d1; +var d2; +var x1; +var y1; +for ( i = 0; i < 100; i++ ) { + d1 = discreteUniform( -5, 5 ); + d2 = discreteUniform( -5, 5 ); + x1 = discreteUniform( -5, 5 ); + y1 = discreteUniform( -5, 5 ); + out = srotmg( d1, d2, x1, y1 ); + console.log( out ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/include.gypi b/lib/node_modules/@stdlib/blas/base/srotmg/include.gypi new file mode 100644 index 000000000000..cfdf32f2eaa4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nestingz variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + '[ 1.0, -0.625, 0.0, 0.0, -0.5 ] +*/ +function srotmg( d1, d2, x1, y1, out, stride, offset ) { + var flag; + var temp; + var ad1; + var ad2; + var h11; + var h12; + var h21; + var h22; + var p1; + var p2; + var q1; + var q2; + var u; + + if ( isnanf( d1 ) || isnanf( d2 ) || isnanf( x1 ) || isnanf( y1 ) ) { + out[ offset ] = NaN; + out[ offset + stride ] = NaN; + out[ offset + ( 2 * stride ) ] = NaN; + out[ offset + ( 3 * stride ) ] = NaN; + out[ offset + ( 4 * stride ) ] = NaN; + return out; + } + + if ( d1 < 0.0 ) { + flag = -1.0; + h11 = 0.0; + h12 = 0.0; + h21 = 0.0; + h22 = 0.0; + d1 = 0.0; + d2 = 0.0; + x1 = 0.0; + } else { + p2 = d2 * y1; + if ( p2 === 0.0 ) { + flag = -2.0; + out[ offset ] = flag; + return out; + } + 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; + } else { + 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 ) { + 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 ] = flag; + + if ( flag < 0.0 ) { + out[ offset + stride ] = h11; + out[ offset + ( 2 * stride ) ] = h21; + out[ offset + ( 3 * stride ) ] = h12; + out[ offset + ( 4 * stride ) ] = h22; + } else if ( flag === 0.0 ) { + out[ offset + ( 2 * stride ) ] = h21; + out[ offset + ( 3 * stride ) ] = h12; + } else { + out[ offset + stride ] = h11; + out[ offset + ( 4 * stride ) ] = h22; + } + + out[ offset ] = flag; + + return out; +} + + +// EXPORTS // + +module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.native.js new file mode 100644 index 000000000000..fa56cc0b09d3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.native.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Construct the parameters for a modified Givens plane rotation. +* +* @param {number} d1 - scaling factor for the first vector component +* @param {number} d2 - scaling factor for the second vector component +* @param {number} x1 - first component of the first vector +* @param {number} y1 - first component of the second vector +* @param {Float32Array} out - output array +* @param {integer} stride - output stride length +* @param {NonNegativeInteger} offset - starting index +* @returns {Float32Array} output array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* 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, out, stride, offset) { + addon.assign(d1, d2, x1, y1, out, stride, offset); + 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..3c183e023eab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/index.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* BLAS level 1 routine to 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( 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 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var srotmg = require( '@stdlib/blas/base/srotmg' ); +* +* var out = new Float32Array( 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 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var srotmg; +var tmp = tryRequire(join(__dirname, './native.js')); +if (isError(tmp)) { + srotmg = main; +} else { + srotmg = tmp; +} + + +// EXPORTS // + +module.exports = srotmg; + +// 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..02b8c2f167af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var srotmg = require( './srotmg.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly(srotmg, 'assign', assign); + + +// EXPORTS // + +module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/native.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/native.js new file mode 100644 index 000000000000..919ff1618eb2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var srotmg = require( './srotmg.native.js' ); +var assign = require( './assign.native.js' ); + + +// MAIN // + +setReadOnly(srotmg, 'assign', assign); + + +// EXPORTS // + +module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.js new file mode 100644 index 000000000000..de6320d6f19d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.js @@ -0,0 +1,50 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 // + +/** +* 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 +* @returns {Float32Array} 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 ] +*/ +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/lib/srotmg.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.native.js new file mode 100644 index 000000000000..5e8b2d63e4a5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/srotmg.native.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Construct the parameters for a modified Givens plane rotation. +* +* @param {number} d1 - scaling factor for the first vector component +* @param {number} d2 - scaling factor for the second vector component +* @param {number} x1 - first component of the first vector +* @param {number} y1 - first component of the second vector +* @returns {Float32Array} 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 ] +*/ +function srotmg(d1, d2, x1, y1) { + var out = new Float32Array(5); + addon(d1, d2, x1, y1, out, 1); + return out; +} + + +// EXPORTS // + +module.exports = srotmg; diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/manifest.json b/lib/node_modules/@stdlib/blas/base/srotmg/manifest.json new file mode 100644 index 000000000000..f5ccd42fefa7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/manifest.json @@ -0,0 +1,485 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.f", + "./src/srotmg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.f", + "./src/srotmg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/srotmg_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" + ] + }, + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/srotmg.c", + "./src/srotmg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/copysignf", + "@stdlib/math/base/special/sqrtf", + "@stdlib/math/base/special/abs2f", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + } + ] +} 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..cbfa7fddbb40 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/package.json @@ -0,0 +1,77 @@ +{ + "name": "@stdlib/blas/base/srotmg", + "version": "0.0.0", + "description": "Constructs a modified Givens plane rotation using alternative indexing semantics.", + "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", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "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", + "givens", + "rotation", + "matrix", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "float32", + "float", + "single", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/Makefile b/lib/node_modules/@stdlib/blas/base/srotmg/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/addon.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/addon.c new file mode 100644 index 000000000000..612805d7160b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/addon.c @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/srotmg.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include "stdlib/napi/export.h" + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); + STDLIB_NAPI_ARGV_FLOAT( env, d1, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, d2, argv, 1 ); + STDLIB_NAPI_ARGV_FLOAT( env, x1, argv, 2 ); + STDLIB_NAPI_ARGV_FLOAT( env, y1, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Out, 5, strideOut, argv, 4 ); + API_SUFFIX( c_srotmg )( d1, d2, x1, y1, Out, strideOut ); + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 7 ); + STDLIB_NAPI_ARGV_FLOAT( env, d1, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, d2, argv, 1 ); + STDLIB_NAPI_ARGV_FLOAT( env, x1, argv, 2 ); + STDLIB_NAPI_ARGV_FLOAT( env, y1, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Out, 5, strideOut, argv, 4 ); + API_SUFFIX( c_srotmg_assign )( d1, d2, x1, y1, Out, strideOut, offsetOut ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "assign", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.c new file mode 100644 index 000000000000..eb769af47027 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.c @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/base/srotmg.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Constructs a modified Givens plane rotation using alternative indexing semantics. +* +* @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 strideOut index increment +*/ +void API_SUFFIX( c_srotmg )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut ) { + CBLAS_INT offsetOut = stdlib_strided_stride2offset( 5, strideOut ); + API_SUFFIX( c_srotmg_assign )( d1, d2, x1, y1, Out, strideOut, offsetOut ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.f b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.f new file mode 100644 index 000000000000..c9558a8e2e50 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg.f @@ -0,0 +1,217 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2026 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. +!< + +!> Constructs a modified Givens plane rotation. +! +!! ## Notes +!! +!! * Modified version of reference BLAS level1 routine (version 3.7.0). Updated to "free form" Fortran 95. +!! +!! ## Authors +!! +!! * Univ. of Tennessee +!! * Univ. of California Berkeley +!! * Univ. of Colorado Denver +!! * NAG Ltd. +!! +!! ## License +!! +!! From : +!! +!! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +!! > +!! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +!! > +!! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +!! > +!! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {real} sd1 - scaling factor for the first vector component +! @param {real} sd2 - scaling factor for the second vector component +! @param {real} sx1 - first component of the first vector +! @param {real} sy1 - first component of the second vector +! @param {real} sparam - output array (dimension 5) +!< +subroutine srotmg( sd1, sd2, sx1, sy1, sparam ) + implicit none + ! .. + ! Internal parameters: + integer, parameter :: wp = kind(1.e0) + ! .. + ! Constants: + real(wp), parameter :: zero = 0.0e0_wp + real(wp), parameter :: one = 1.0e0_wp + real(wp), parameter :: two = 2.0e0_wp + real(wp), parameter :: gam = 4096.0e0_wp + real(wp), parameter :: gamsq = 1.67772e7_wp + real(wp), parameter :: rgamsq = 5.96046e-8_wp + ! .. + ! Scalar Arguments: + real(wp) :: sd1, sd2, sx1, sy1 + ! .. + ! Array Arguments: + real(wp) :: sparam(5) + ! .. + ! Local Scalars: + real(wp) :: sflag, sh11, sh12, sh21, sh22, sp1, sp2, sq1, sq2, stemp, su + ! Initialize h variables to zero to avoid uninitialized warnings: + sh11 = zero + sh12 = zero + sh21 = zero + sh22 = zero + ! .. + if ( sd1 .lt. zero ) then + ! GO ZERO-H-D-AND-SX1.. + sflag = -one + sh11 = zero + sh12 = zero + sh21 = zero + sh22 = zero + + sd1 = zero + sd2 = zero + sx1 = zero + else + ! CASE-SD1-NONNEGATIVE + sp2 = sd2 * sy1 + if ( sp2 .eq. zero ) then + sflag = -two + sparam(1) = sflag + return + end if + ! REGULAR-CASE.. + sp1 = sd1 * sx1 + sq2 = sp2 * sy1 + sq1 = sp1 * sx1 + + if ( abs(sq1) .gt. abs(sq2) ) then + sh21 = -sy1 / sx1 + sh12 = sp2 / sp1 + + su = one - sh12 * sh21 + + if ( su .gt. zero ) then + sflag = zero + sd1 = sd1 / su + sd2 = sd2 / su + sx1 = sx1 * su + else + ! This code path if here for safety. We do not expect this + ! condition to ever hold except in edge cases with rounding + ! errors. See DOI: 10.1145/355841.355847 + sflag = -one + sh11 = zero + sh12 = zero + sh21 = zero + sh22 = zero + + sd1 = zero + sd2 = zero + sx1 = zero + end if + else + if ( sq2 .lt. zero ) then + ! GO ZERO-H-D-AND-SX1.. + sflag = -one + sh11 = zero + sh12 = zero + sh21 = zero + sh22 = zero + + sd1 = zero + sd2 = zero + sx1 = zero + else + sflag = one + sh11 = sp1 / sp2 + sh22 = sx1 / sy1 + su = one + sh11 * sh22 + stemp = sd2 / su + sd2 = sd1 / su + sd1 = stemp + sx1 = sy1 * su + end if + end if + + ! PROCEDURE..SCALE-CHECK + if ( sd1 .ne. zero ) then + do while ( (sd1 .le. rgamsq) .or. (sd1 .ge. gamsq) ) + if ( sflag .eq. zero ) then + sh11 = one + sh22 = one + sflag = -one + else + sh21 = -one + sh12 = one + sflag = -one + end if + if ( sd1 .le. rgamsq ) then + sd1 = sd1 * gam**2 + sx1 = sx1 / gam + sh11 = sh11 / gam + sh12 = sh12 / gam + else + sd1 = sd1 / gam**2 + sx1 = sx1 * gam + sh11 = sh11 * gam + sh12 = sh12 * gam + end if + end do + end if + + if ( sd2 .ne. zero ) then + do while ( (abs(sd2) .le. rgamsq) .or. (abs(sd2) .ge. gamsq) ) + if ( sflag .eq. zero ) then + sh11 = one + sh22 = one + sflag = -one + else + sh21 = -one + sh12 = one + sflag = -one + end if + if ( abs(sd2) .le. rgamsq ) then + sd2 = sd2 * gam**2 + sh21 = sh21 / gam + sh22 = sh22 / gam + else + sd2 = sd2 / gam**2 + sh21 = sh21 * gam + sh22 = sh22 * gam + end if + end do + end if + end if + + if ( sflag .lt. zero ) then + sparam(2) = sh11 + sparam(3) = sh21 + sparam(4) = sh12 + sparam(5) = sh22 + else if ( sflag .eq. zero ) then + sparam(3) = sh21 + sparam(4) = sh12 + else + sparam(2) = sh11 + sparam(5) = sh22 + end if + + sparam(1) = sflag + return +end subroutine srotmg + diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c new file mode 100644 index 000000000000..8e9c7a883b24 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/srotmg.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/assert/is_nanf.h" + +/** +* Constructs a modified Givens plane rotation using alternative indexing semantics. +* +* @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 strideOut index increment +* @param offsetOut starting index +*/ +void API_SUFFIX( c_srotmg_assign )( float d1, float d2, float x1, const float y1, float *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + const float GAM = 4096.0f; + const float GAM_SQ = 16777216.0f; + const float RGAM_SQ = 5.9604645e-8f; + + float flag = 0.0f; + float temp = 0.0f; + float ad1 = 0.0f; + float ad2 = 0.0f; + float h11 = 0.0f; + float h12 = 0.0f; + float h21 = 0.0f; + float h22 = 0.0f; + float p1 = 0.0f; + float p2 = 0.0f; + float q1 = 0.0f; + float q2 = 0.0f; + float u = 0.0f; + + // Check for NaN inputs + if ( stdlib_base_is_nanf( d1 ) || stdlib_base_is_nanf( d2 ) || stdlib_base_is_nanf( x1 ) || stdlib_base_is_nanf( y1 ) ) { + Out[ offsetOut ] = 0.0f / 0.0f; // NaN + Out[ offsetOut + strideOut ] = 0.0f / 0.0f; + Out[ offsetOut + ( 2 * strideOut ) ] = 0.0f / 0.0f; + Out[ offsetOut + ( 3 * strideOut ) ] = 0.0f / 0.0f; + Out[ offsetOut + ( 4 * strideOut ) ] = 0.0f / 0.0f; + return; + } + + if ( d1 < 0.0f ) { + flag = -1.0f; + h11 = 0.0f; + h12 = 0.0f; + h21 = 0.0f; + h22 = 0.0f; + d1 = 0.0f; + d2 = 0.0f; + x1 = 0.0f; + } else { + p2 = d2 * y1; + if ( p2 == 0.0f ) { + flag = -2.0f; + Out[ offsetOut ] = flag; + return; + } + p1 = d1 * x1; + q2 = p2 * y1; + q1 = p1 * x1; + ad1 = stdlib_base_absf( q1 ); + ad2 = stdlib_base_absf( q2 ); + + if ( ad1 > ad2 ) { + h21 = -y1 / x1; + h12 = p2 / p1; + u = 1.0f - ( h12 * h21 ); + if ( u > 0.0f ) { + flag = 0.0f; + d1 = d1 / u; + d2 = d2 / u; + x1 = x1 * u; + } + } else if ( q2 < 0.0f ) { + flag = -1.0f; + h11 = 0.0f; + h12 = 0.0f; + h21 = 0.0f; + h22 = 0.0f; + d1 = 0.0f; + d2 = 0.0f; + x1 = 0.0f; + } else { + flag = 1.0f; + h11 = p1 / p2; + h22 = x1 / y1; + u = 1.0f + ( h11 * h22 ); + temp = d2 / u; + d2 = d1 / u; + d1 = temp; + x1 = y1 * u; + } + + if ( d1 != 0.0f ) { + while ( ( d1 < RGAM_SQ ) || ( d1 > GAM_SQ ) ) { + if ( flag == 0.0f ) { + h11 = 1.0f; + h22 = 1.0f; + flag = -1.0f; + } else { + h21 = -1.0f; + h12 = 1.0f; + flag = -1.0f; + } + if ( d1 < RGAM_SQ ) { + d1 = d1 * GAM * GAM; + x1 = x1 / GAM; + h11 = h11 / GAM; + h12 = h12 / GAM; + } else { + d1 = d1 / ( GAM * GAM ); + x1 = x1 * GAM; + h11 = h11 * GAM; + h12 = h12 * GAM; + } + } + } + + if ( d2 != 0.0f ) { + while ( ( stdlib_base_absf( d2 ) < RGAM_SQ ) || ( stdlib_base_absf( d2 ) > GAM_SQ ) ) { + if ( flag == 0.0f ) { + h11 = 1.0f; + h22 = 1.0f; + flag = -1.0f; + } else { + h21 = -1.0f; + h12 = 1.0f; + flag = -1.0f; + } + if ( stdlib_base_absf( d2 ) < RGAM_SQ ) { + d2 = d2 * GAM * GAM; + h21 = h21 / GAM; + h22 = h22 / GAM; + } else { + d2 = d2 / ( GAM * GAM ); + h21 = h21 * GAM; + h22 = h22 * GAM; + } + } + } + } + + Out[ offsetOut ] = flag; + + if ( flag < 0.0f ) { + Out[ offsetOut + strideOut ] = h11; + Out[ offsetOut + ( 2 * strideOut ) ] = h21; + Out[ offsetOut + ( 3 * strideOut ) ] = h12; + Out[ offsetOut + ( 4 * strideOut ) ] = h22; + } else if ( flag == 0.0f ) { + Out[ offsetOut + ( 2 * strideOut ) ] = h21; + Out[ offsetOut + ( 3 * strideOut ) ] = h12; + } else { + Out[ offsetOut + strideOut ] = h11; + Out[ offsetOut + ( 4 * strideOut ) ] = h22; + } + + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_cblas.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_cblas.c new file mode 100644 index 000000000000..a1f61cc49cdc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_cblas.c @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/base/srotmg_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/srotmg.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Constructs 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 strideOut index increment +*/ +void API_SUFFIX( c_srotmg )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut ) { + API_SUFFIX( cblas_srotmg )( d1, d2, x1, y1, Out, strideOut ); +} + +/** +* Constructs a modified Givens plane rotation using alternative indexing semantics. +* +* @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 strideOut index increment +* @param offsetOut starting index +*/ +void API_SUFFIX( c_srotmg_assign )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + Out += stdlib_strided_min_view_buffer_index( 5, strideOut, offsetOut ); // adjust array pointer + API_SUFFIX( cblas_srotmg )( d1, d2, x1, y1, Out, strideOut ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_f.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_f.c new file mode 100644 index 000000000000..4289fdd04940 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_f.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/srotmg.h" +#include "stdlib/blas/base/srotmg_fortran.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include "stdlib/strided/base/stride2offset.h" + + +/** +* Constructs 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 strideOut index increment +*/ +void API_SUFFIX( c_srotmg )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut ) { + CBLAS_INT relOffset; + float td1 = d1; + float td2 = d2; + float tx1 = x1; + float result[ ] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; + + relOffset = stdlib_strided_stride2offset( 5, strideOut ); + + srotmg( &td1, &td2, &tx1, &y1, result ); + + Out[relOffset] = result[0]; + Out[relOffset + strideOut] = result[1]; + Out[relOffset + (2 * strideOut)] = result[2]; + Out[relOffset + (3 * strideOut)] = result[3]; + Out[relOffset + (4 * strideOut)] = result[4]; +} + +/** +* Constructs a modified Givens plane rotation using alternative indexing semantics. +* +* @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 strideOut index increment +* @param offsetOut starting index +*/ +void API_SUFFIX( c_srotmg_assign )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + CBLAS_INT minIndex; + CBLAS_INT relOffset; + float td1 = d1; + float td2 = d2; + float tx1 = x1; + float result[ ] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; + + minIndex = stdlib_strided_min_view_buffer_index( 5, strideOut, offsetOut ); + Out += minIndex; + + relOffset = offsetOut - minIndex; + + srotmg( &td1, &td2, &tx1, &y1, result ); + Out[relOffset] = result[0]; + Out[relOffset + strideOut] = result[1]; + Out[relOffset + (2 * strideOut)] = result[2]; + Out[relOffset + (3 * strideOut)] = result[3]; + Out[relOffset + (4 * strideOut)] = result[4]; +} 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..90a29ce5821d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.js @@ -0,0 +1,277 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 absf = require( '@stdlib/math/base/special/absf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +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 computes a Givens plane rotation', function test(t) { + var expected; + var values; + var delta; + var tol; + var out; + var e; + var i; + var j; + + expected = [ + [ 1.0, 0.375, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.0, 0.0, -0.5, 0.125, 0.0 ], + [ 0.0, 0.0, -0.25, 0.1, 0.0 ], + [ 1.0, 0.625, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 0.0, 0.0, 0.0, 0.0 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ] + ]; + values = [ + [ 3.0, 4.0, 1.0, 2.0 ], + [ -3.0, 2.0, 2.0, 3.0 ], + [ 4.0, 1.0, 2.0, 1.0 ], + [ 5.0, 2.0, 4.0, 1.0 ], + [ 5.0, 4.0, 1.0, 2.0 ], + [ -5.0, 4.0, 1.0, 2.0 ], + [ 5.0, 4.0, -1.0, 2.0 ], + [ 5.0, 4.0, 1.0, -2.0 ], + [ 5.0, 0.0, 1.0, 2.0 ], + [ 5.0, 3.0, 0.0, 2.0 ], + [ 5.0, 3.0, 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + e = new Float32Array( expected[i] ); + out = new Float32Array( 5 ); + srotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + } + 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( 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, 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( 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( 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( 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, 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( 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, 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, 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, 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' ); + } + 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( [ 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( 3.0, 4.0, 1.0, 2.0, out, 2, 0 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + 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( [ 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( 3.0, 4.0, 1.0, 2.0, out, -2, 8 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + 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, 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( 3.0, 4.0, 1.0, 2.0, out, 1, 1 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + 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, 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( 3.0, 4.0, 1.0, 2.0, out, 2, 2 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js new file mode 100644 index 000000000000..4e09d47287b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js @@ -0,0 +1,205 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var srotmg = tryRequire(resolve(__dirname, './../lib/assign.native.js')); +var opts = { + 'skip': (srotmg instanceof Error) +}; + + +// TESTS // + +tape('main export is a function', opts, 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', opts, function test(t) { + t.strictEqual(srotmg.length, 7, 'returns expected value'); + t.end(); +}); + +tape('the function computes a Givens plane rotation', opts, function test(t) { + var expected; + var values; + var delta; + var tol; + var out; + var e; + var i; + var j; + + expected = [ + [ 1.0, 0.375, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.0, 0.0, -0.5, 0.125, 0.0 ], + [ 0.0, 0.0, -0.25, 0.1, 0.0 ], + [ 1.0, 0.625, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 0.0, 0.0, 0.0, 0.0 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ] + ]; + values = [ + [ 3.0, 4.0, 1.0, 2.0 ], + [ -3.0, 2.0, 2.0, 3.0 ], + [ 4.0, 1.0, 2.0, 1.0 ], + [ 5.0, 2.0, 4.0, 1.0 ], + [ 5.0, 4.0, 1.0, 2.0 ], + [ -5.0, 4.0, 1.0, 2.0 ], + [ 5.0, 4.0, -1.0, 2.0 ], + [ 5.0, 4.0, 1.0, -2.0 ], + [ 5.0, 0.0, 1.0, 2.0 ], + [ 5.0, 3.0, 0.0, 2.0 ], + [ 5.0, 3.0, 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + e = new Float32Array( expected[i] ); + out = new Float32Array( 5 ); + srotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function supports providing a positive stride', opts, function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + 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( 3.0, 4.0, 1.0, 2.0, out, 2, 0 ); + console.log('actual', actual); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports providing a negative stride', opts, function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + 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( 3.0, 4.0, 1.0, 2.0, out, -2, 8 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports providing an offset', opts, function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + 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( 3.0, 4.0, 1.0, 2.0, out, 1, 1 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports providing both a stride and offset', opts, function test(t) { + var expected; + var actual; + var delta; + var tol; + var out; + var i; + + 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( 3.0, 4.0, 1.0, 2.0, out, 2, 2 ); + t.strictEqual( actual, out, 'returns expected value' ); + for ( i = 0; i < out.length; i++ ) { + if ( out[i] === expected[i] ) { + t.strictEqual( out[i], expected[i], 'returns expected value' ); + } else { + delta = 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+'.' ); + } + } + 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..7a6ffab114cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var srotmg = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// 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(); +}); + +tape('if a native implementation is available, the main export is the native implementation', opts, function test(t) { + var srotmg = proxyquire('./../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual(srotmg, mock, 'returns expected value'); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape('if a native implementation is not available, the main export is a JavaScript implementation', opts, function test(t) { + var srotmg; + var main; + + main = require( './../lib/srotmg.js' ); + + srotmg = proxyquire('./../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual(srotmg, main, 'returns expected value'); + t.end(); + + function tryRequire() { + return new Error('Cannot find module'); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.js new file mode 100644 index 000000000000..8f38d62bb118 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.js @@ -0,0 +1,176 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 absf = require( '@stdlib/math/base/special/absf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +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 delta; + var tol; + var out; + var e; + var i; + var j; + + expected = [ + [ 1.0, 0.375, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.0, 0.0, -0.5, 0.125, 0.0 ], + [ 0.0, 0.0, -0.25, 0.1, 0.0 ], + [ 1.0, 0.625, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 0.0, 0.0, 0.0, 0.0 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ] + ]; + values = [ + [ 3.0, 4.0, 1.0, 2.0 ], + [ -3.0, 2.0, 2.0, 3.0 ], + [ 4.0, 1.0, 2.0, 1.0 ], + [ 5.0, 2.0, 4.0, 1.0 ], + [ 5.0, 4.0, 1.0, 2.0 ], + [ -5.0, 4.0, 1.0, 2.0 ], + [ 5.0, 4.0, -1.0, 2.0 ], + [ 5.0, 4.0, 1.0, -2.0 ], + [ 5.0, 0.0, 1.0, 2.0 ], + [ 5.0, 3.0, 0.0, 2.0 ], + [ 5.0, 3.0, 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + e = new Float32Array( expected[i] ); + out = srotmg( values[i][0], values[i][1], values[i][2], 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 = 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+'.' ); + } + } + } + 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, 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 ); + 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, 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 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + 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 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + 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 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + 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 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + + 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 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnanf( actual[i] ), true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js new file mode 100644 index 000000000000..414d1f443c93 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var srotmg = tryRequire(resolve(__dirname, './../lib/srotmg.native.js')); +var opts = { + 'skip': (srotmg instanceof Error) +}; + + +// TESTS // + +tape( 'main export is a function', opts, 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 6', opts, function test( t ) { + t.strictEqual( srotmg.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function constructs the parameters for a modified Givens plane rotation', opts, function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var e; + var i; + var j; + + expected = [ + [ 1.0, 0.375, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.0, 0.0, -0.5, 0.125, 0.0 ], + [ 0.0, 0.0, -0.25, 0.1, 0.0 ], + [ 1.0, 0.625, 0.0, 0.0, 0.5 ], + [ -1.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ 1.0, -0.625, 0.0, 0.0, -0.5 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 0.0, 0.0, 0.0, 0.0 ], + [ -2.0, 0.0, 0.0, 0.0, 0.0 ] + ]; + values = [ + [ 3.0, 4.0, 1.0, 2.0 ], + [ -3.0, 2.0, 2.0, 3.0 ], + [ 4.0, 1.0, 2.0, 1.0 ], + [ 5.0, 2.0, 4.0, 1.0 ], + [ 5.0, 4.0, 1.0, 2.0 ], + [ -5.0, 4.0, 1.0, 2.0 ], + [ 5.0, 4.0, -1.0, 2.0 ], + [ 5.0, 4.0, 1.0, -2.0 ], + [ 5.0, 0.0, 1.0, 2.0 ], + [ 5.0, 3.0, 0.0, 2.0 ], + [ 5.0, 3.0, 1.0, 0.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + e = new Float32Array( expected[i] ); + out = srotmg( values[i][0], values[i][1], values[i][2], 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 = 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+'.' ); + } + } + } + t.end(); +}); From c3858a19d7df0f4bb46e2b15db1ae756e1c26734 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Mon, 12 Jan 2026 22:54:52 +0530 Subject: [PATCH 2/6] fix: native benchmark --- .../@stdlib/blas/base/srotmg/test/test.srotmg.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js index 414d1f443c93..8729bf2483b5 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.srotmg.native.js @@ -44,8 +44,8 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 6', opts, function test( t ) { - t.strictEqual( srotmg.length, 6, 'returns expected value' ); +tape( 'the function has an arity of 4', opts, function test( t ) { + t.strictEqual( srotmg.length, 4, 'returns expected value' ); t.end(); }); From a949f526388e9cc907cb851392b6c7ba7e7f1752 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Tue, 13 Jan 2026 13:10:44 +0530 Subject: [PATCH 3/6] fix: benchmarks ,headers and readme --- lib/node_modules/@stdlib/blas/base/srotmg/README.md | 10 +++++++--- .../@stdlib/blas/base/srotmg/examples/index.js | 8 ++++---- .../blas/base/srotmg/include/stdlib/blas/base/srotmg.h | 6 +++--- .../srotmg/include/stdlib/blas/base/srotmg_cblas.h | 4 ++-- .../srotmg/include/stdlib/blas/base/srotmg_fortran.h | 2 +- .../@stdlib/blas/base/srotmg/lib/assign.js | 8 ++++---- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/README.md b/lib/node_modules/@stdlib/blas/base/srotmg/README.md index 29ea27eca926..184cf4ab8962 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/README.md +++ b/lib/node_modules/@stdlib/blas/base/srotmg/README.md @@ -85,6 +85,10 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var srotmg = require( '@stdlib/blas/base/srotmg' ); var out; +var y1; +var x1; +var d2; +var d1; var i; for ( i = 0; i < 100; i++ ) { d1 = discreteUniform( -5, 5 ); @@ -198,7 +202,7 @@ void c_srotmg_assign( float d1, float d2, float x1, float y1, float* Out, const ### Examples ```c -#include "stdlib/blas/base/srotg.h" +#include "stdlib/blas/base/srotmg.h" #include int main( void ) { @@ -215,7 +219,7 @@ int main( void ) { const int strideOut = 1; // Apply plane rotation: - c_srotmg( d1, d2, x1, y1, out, stride ); + c_srotmg( d1, d2, x1, y1, out, strideOut ); // Print the result: for ( i = 0; i < 5; i++ ) { @@ -223,7 +227,7 @@ int main( void ) { } // Apply plane rotation - c_srotmg_assign( d1, d2, x1, y1, out, stride, 0 ); + c_srotmg_assign( d1, d2, x1, y1, out, strideOut, 0 ); // Print the result: for ( i = 0; i < 5; i++ ) { 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 9cfac72defcb..f883eac777d8 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/examples/index.js @@ -22,11 +22,11 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var srotmg = require( './../lib' ); var out; -var i; -var d1; -var d2; -var x1; var y1; +var x1; +var d2; +var d1; +var i; for ( i = 0; i < 100; i++ ) { d1 = discreteUniform( -5, 5 ); d2 = discreteUniform( -5, 5 ); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg.h b/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg.h index 55ddfacefeac..bf1e07b48255 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg.h +++ b/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg.h @@ -17,7 +17,7 @@ */ /** -* Header file containing function declarations for the C interface to the BLAS Level 1 routine `srotg`. +* Header file containing function declarations for the C interface to the BLAS Level 1 routine `srotmg`. */ #ifndef STDLIB_BLAS_BASE_SROTMG_H #define STDLIB_BLAS_BASE_SROTMG_H @@ -34,12 +34,12 @@ extern "C" { /** * Constructs a modified Givens plane rotation. */ -void API_SUFFIX( c_srotmg )( const float d1, const float d2, const float x1, const float y1, float *out, const CBLAS_INT strideOut ); +void API_SUFFIX( c_srotmg )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut ); /** * Constructs a modified Givens plane rotation using alternative indexing semantics. */ -void API_SUFFIX( c_srotmg_assign )( const float d1, const float d2, const float x1, const float y1, float *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ); +void API_SUFFIX( c_srotmg_assign )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_cblas.h b/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_cblas.h index 8be3178b5375..72c60f1c6422 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_cblas.h @@ -32,9 +32,9 @@ extern "C" { #endif /** -* Applies a plane rotation. +* Constructs a modified Givens plane rotation. */ -void API_SUFFIX( cblas_srotmg )( const float d1, const float d2, const float x1, const float y1, float *out, const CBLAS_INT stride ); +void API_SUFFIX( cblas_srotmg )( const float d1, const float d2, const float x1, const float y1, float *Out, const CBLAS_INT strideOut ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_fortran.h b/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_fortran.h index 9a2387111563..0ca533445d21 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/srotmg/include/stdlib/blas/base/srotmg_fortran.h @@ -17,7 +17,7 @@ */ /** -* Header file containing function declarations for the Fortran interface to the BLAS Level 1 routine `srotg`. +* Header file containing function declarations for the Fortran interface to the BLAS Level 1 routine `srotmg`. */ #ifndef STDLIB_BLAS_BASE_SROTMG_FORTRAN_H #define STDLIB_BLAS_BASE_SROTMG_FORTRAN_H 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 7b2166e74278..f390d32b97b2 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -139,12 +139,12 @@ function srotmg( d1, d2, x1, y1, out, stride, offset ) { flag = -1.0; } if ( d1 < RGAM_SQ ) { - d1 = float64ToFloat32( d1 * GAM * GAM ); + d1 = float64ToFloat32( d1 * ( GAM * GAM ) ); x1 = float64ToFloat32( x1 / GAM ); h11 = float64ToFloat32( h11 / GAM ); h12 = float64ToFloat32( h12 / GAM ); } else { - d1 = float64ToFloat32( d1 / GAM * GAM ); + d1 = float64ToFloat32( d1 / ( GAM * GAM ) ); x1 = float64ToFloat32( x1 * GAM ); h11 = float64ToFloat32( h11 * GAM ); h12 = float64ToFloat32( h12 * GAM ); @@ -164,11 +164,11 @@ function srotmg( d1, d2, x1, y1, out, stride, offset ) { flag = -1.0; } if ( absf( d2 ) < RGAM_SQ ) { - d2 = float64ToFloat32( d2 * GAM * GAM ); + d2 = float64ToFloat32( d2 * ( GAM * GAM ) ); h21 = float64ToFloat32( h21 / GAM ); h22 = float64ToFloat32( h22 / GAM ); } else { - d2 = float64ToFloat32( d2 / GAM * GAM ); + d2 = float64ToFloat32( d2 / ( GAM * GAM ) ); h21 = float64ToFloat32( h21 * GAM ); h22 = float64ToFloat32( h22 * GAM ); } From 82d4e500a7c448415646adcfd4c67517d6152493 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Tue, 13 Jan 2026 13:32:16 +0530 Subject: [PATCH 4/6] fix: lib and src --- .../@stdlib/blas/base/srotmg/lib/assign.js | 4 ++-- .../blas/base/srotmg/src/srotmg_assign.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) 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 f390d32b97b2..6d5928ad50f3 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/lib/assign.js @@ -139,7 +139,7 @@ function srotmg( d1, d2, x1, y1, out, stride, offset ) { flag = -1.0; } if ( d1 < RGAM_SQ ) { - d1 = float64ToFloat32( d1 * ( GAM * GAM ) ); + d1 = float64ToFloat32( d1 * GAM * GAM ); x1 = float64ToFloat32( x1 / GAM ); h11 = float64ToFloat32( h11 / GAM ); h12 = float64ToFloat32( h12 / GAM ); @@ -164,7 +164,7 @@ function srotmg( d1, d2, x1, y1, out, stride, offset ) { flag = -1.0; } if ( absf( d2 ) < RGAM_SQ ) { - d2 = float64ToFloat32( d2 * ( GAM * GAM ) ); + d2 = float64ToFloat32( d2 * GAM * GAM ); h21 = float64ToFloat32( h21 / GAM ); h22 = float64ToFloat32( h22 / GAM ); } else { diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c index 8e9c7a883b24..b8ddf1ecd8dd 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c @@ -37,19 +37,19 @@ void API_SUFFIX( c_srotmg_assign )( float d1, float d2, float x1, const float y1 const float GAM_SQ = 16777216.0f; const float RGAM_SQ = 5.9604645e-8f; - float flag = 0.0f; - float temp = 0.0f; - float ad1 = 0.0f; - float ad2 = 0.0f; + float flag; + float temp; + float ad1; + float ad2; float h11 = 0.0f; float h12 = 0.0f; float h21 = 0.0f; float h22 = 0.0f; - float p1 = 0.0f; - float p2 = 0.0f; - float q1 = 0.0f; - float q2 = 0.0f; - float u = 0.0f; + float p1; + float p2; + float q1; + float q2; + float u; // Check for NaN inputs if ( stdlib_base_is_nanf( d1 ) || stdlib_base_is_nanf( d2 ) || stdlib_base_is_nanf( x1 ) || stdlib_base_is_nanf( y1 ) ) { From 31bd6048cfd2a73d6e026b934c68b78aac1ad2a7 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Tue, 13 Jan 2026 13:43:24 +0530 Subject: [PATCH 5/6] fix: lib and src --- .../@stdlib/blas/base/srotmg/src/srotmg_assign.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c index b8ddf1ecd8dd..7c07d17a5d20 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c +++ b/lib/node_modules/@stdlib/blas/base/srotmg/src/srotmg_assign.c @@ -37,7 +37,7 @@ void API_SUFFIX( c_srotmg_assign )( float d1, float d2, float x1, const float y1 const float GAM_SQ = 16777216.0f; const float RGAM_SQ = 5.9604645e-8f; - float flag; + float flag = 0.0f; float temp; float ad1; float ad2; @@ -67,9 +67,6 @@ void API_SUFFIX( c_srotmg_assign )( float d1, float d2, float x1, const float y1 h12 = 0.0f; h21 = 0.0f; h22 = 0.0f; - d1 = 0.0f; - d2 = 0.0f; - x1 = 0.0f; } else { p2 = d2 * y1; if ( p2 == 0.0f ) { From 45a77a921ed058c27e2f2bc44fc7d6ff17256e21 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Tue, 13 Jan 2026 18:32:33 +0530 Subject: [PATCH 6/6] fix: benchmark and test --- 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: passed - task: lint_javascript_benchmarks status: passed - 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/benchmark/benchmark.assign.js | 5 +++-- .../base/srotmg/benchmark/benchmark.assign.native.js | 5 +++-- .../@stdlib/blas/base/srotmg/benchmark/benchmark.js | 2 +- .../blas/base/srotmg/benchmark/benchmark.native.js | 5 +++-- .../@stdlib/blas/base/srotmg/test/test.assign.js | 8 ++++---- .../@stdlib/blas/base/srotmg/test/test.assign.native.js | 9 ++++----- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js index 3dc9ebddc3d6..9103018b9a55 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.js @@ -24,6 +24,7 @@ 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 format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var srotmg = require( './../lib/assign.js' ); @@ -37,7 +38,7 @@ var options = { // MAIN // -bench( pkg+':assign', function benchmark( b ) { +bench( format( '%s:assign', pkg ), function benchmark( b ) { var out; var d1; var d2; @@ -54,7 +55,7 @@ bench( pkg+':assign', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], out, 1, 0 ); + z = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], out, 1, 0 ); // eslint-disable-line max-len if ( typeof z !=='object' ) { b.fail( 'should return an array' ); } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js index 5f59551729bb..257e66690c4d 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.assign.native.js @@ -26,6 +26,7 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -42,7 +43,7 @@ var options = { // MAIN // -bench( pkg+':assign::native', opts, function benchmark( b ) { +bench( format( '%s::assign::native', pkg ), opts, function benchmark( b ) { var out; var d1; var d2; @@ -59,7 +60,7 @@ bench( pkg+':assign::native', opts, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], out, 1, 0 ); + z = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], out, 1, 0 ); // eslint-disable-line max-len if ( typeof z !=='object' ) { b.fail( 'should return an array' ); } 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 5c2c0f990a9e..8dd85c8a8613 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.js @@ -51,7 +51,7 @@ bench( pkg, function benchmark( b ) { 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 ] ); + out = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ] ); // eslint-disable-line max-len if ( isnanf( out[ i%5 ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js index 375a20cadf08..63d72eedfe83 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/benchmark/benchmark.native.js @@ -25,6 +25,7 @@ var bench = require( '@stdlib/bench' ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -41,7 +42,7 @@ var OPTS = { // MAIN // -bench( pkg+'::native', opts, function benchmark( b ) { +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { var out; var d1; var d2; @@ -56,7 +57,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { 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 ] ); + out = srotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ] ); // eslint-disable-line max-len if ( isnanf( out[ i%5 ] ) ) { b.fail( 'should not return NaN' ); } 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 90a29ce5821d..d7e4cd1293a8 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 @@ -81,7 +81,7 @@ tape('the function computes a Givens plane rotation', function test(t) { for ( i = 0; i < values.length; 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 ); + srotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); // eslint-disable-line max-len for ( j = 0; j < out.length; j++ ) { if ( out[j] === e[j] ) { t.strictEqual( out[j], e[j], 'returns expected value' ); @@ -184,7 +184,7 @@ tape( 'the function supports providing a positive stride', function test(t) { var out; var i; - expected = new Float32Array( [ 1.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5 ] ); + expected = new Float32Array( [ 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 ] ); actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 0 ); @@ -209,7 +209,7 @@ tape( 'the function supports providing a negative stride', function test(t) { var out; var i; - expected = new Float32Array( [ 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 1.0 ] ); + expected = new Float32Array( [ 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 1.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 ] ); actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, -2, 8 ); @@ -260,7 +260,7 @@ tape( 'the function supports providing both a stride and offset', function test( var i; 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 ] ); + 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 ] ); // eslint-disable-line max-len actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 2 ); t.strictEqual( actual, out, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js index 4e09d47287b9..ff49d5d45d46 100644 --- a/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js +++ b/lib/node_modules/@stdlib/blas/base/srotmg/test/test.assign.native.js @@ -89,7 +89,7 @@ tape('the function computes a Givens plane rotation', opts, function test(t) { for ( i = 0; i < values.length; 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 ); + srotmg( values[i][0], values[i][1], values[i][2], values[i][3], out, 1, 0 ); // eslint-disable-line max-len for ( j = 0; j < out.length; j++ ) { if ( out[j] === e[j] ) { t.strictEqual( out[j], e[j], 'returns expected value' ); @@ -111,11 +111,10 @@ tape( 'the function supports providing a positive stride', opts, function test(t var out; var i; - expected = new Float32Array( [ 1.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5 ] ); + expected = new Float32Array( [ 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 ] ); actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 0 ); - console.log('actual', actual); t.strictEqual( actual, out, 'returns expected value' ); for ( i = 0; i < out.length; i++ ) { if ( out[i] === expected[i] ) { @@ -137,7 +136,7 @@ tape( 'the function supports providing a negative stride', opts, function test(t var out; var i; - expected = new Float32Array( [ 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 1.0 ] ); + expected = new Float32Array( [ 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 1.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 ] ); actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, -2, 8 ); @@ -188,7 +187,7 @@ tape( 'the function supports providing both a stride and offset', opts, function var i; 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 ] ); + 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 ] ); // eslint-disable-line max-len actual = srotmg( 3.0, 4.0, 1.0, 2.0, out, 2, 2 ); t.strictEqual( actual, out, 'returns expected value' );