From 50a113bd07130f594cfe00c3c5d7a458d6e09a42 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Fri, 9 Jan 2026 20:48:32 +0530 Subject: [PATCH 1/5] feat: add blas/base/zrotg --- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: missing_dependencies - 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/zrotg/README.md | 278 ++++++++++ .../base/zrotg/benchmark/benchmark.assign.js | 56 ++ .../benchmark/benchmark.assign.native.js | 65 +++ .../blas/base/zrotg/benchmark/benchmark.js | 55 ++ .../base/zrotg/benchmark/benchmark.native.js | 64 +++ .../blas/base/zrotg/benchmark/c/Makefile | 146 +++++ .../base/zrotg/benchmark/c/benchmark.length.c | 218 ++++++++ .../base/zrotg/benchmark/fortran/Makefile | 141 +++++ .../benchmark/fortran/benchmark.length.f | 216 ++++++++ .../@stdlib/blas/base/zrotg/binding.gyp | 265 +++++++++ .../@stdlib/blas/base/zrotg/docs/repl.txt | 28 + .../blas/base/zrotg/docs/types/index.d.ts | 53 ++ .../blas/base/zrotg/docs/types/test.ts | 63 +++ .../blas/base/zrotg/examples/c/Makefile | 146 +++++ .../blas/base/zrotg/examples/c/example.c | 49 ++ .../@stdlib/blas/base/zrotg/examples/index.js | 61 +++ .../@stdlib/blas/base/zrotg/include.gypi | 70 +++ .../zrotg/include/stdlib/blas/base/zrotg.h | 49 ++ .../include/stdlib/blas/base/zrotg_cblas.h | 44 ++ .../include/stdlib/blas/base/zrotg_fortran.h | 41 ++ .../@stdlib/blas/base/zrotg/lib/assign.js | 152 ++++++ .../blas/base/zrotg/lib/assign.native.js | 58 ++ .../@stdlib/blas/base/zrotg/lib/index.js | 72 +++ .../@stdlib/blas/base/zrotg/lib/main.js | 35 ++ .../@stdlib/blas/base/zrotg/lib/native.js | 35 ++ .../@stdlib/blas/base/zrotg/lib/zrotg.js | 55 ++ .../blas/base/zrotg/lib/zrotg.native.js | 57 ++ .../@stdlib/blas/base/zrotg/manifest.json | 510 ++++++++++++++++++ .../@stdlib/blas/base/zrotg/package.json | 80 +++ .../@stdlib/blas/base/zrotg/src/Makefile | 70 +++ .../@stdlib/blas/base/zrotg/src/addon.c | 63 +++ .../@stdlib/blas/base/zrotg/src/zrotg.c | 36 ++ .../@stdlib/blas/base/zrotg/src/zrotg.f | 241 +++++++++ .../blas/base/zrotg/src/zrotg_assign.c | 155 ++++++ .../@stdlib/blas/base/zrotg/src/zrotg_cblas.c | 49 ++ .../@stdlib/blas/base/zrotg/src/zrotg_f.c | 90 ++++ .../blas/base/zrotg/test/test.assign.js | 222 ++++++++ .../base/zrotg/test/test.assign.native.js | 169 ++++++ .../@stdlib/blas/base/zrotg/test/test.js | 82 +++ .../blas/base/zrotg/test/test.zrotg.js | 222 ++++++++ .../blas/base/zrotg/test/test.zrotg.native.js | 169 ++++++ 41 files changed, 4730 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/include/stdlib/blas/base/zrotg.h create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/include/stdlib/blas/base/zrotg_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/include/stdlib/blas/base/zrotg_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.f create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js create mode 100644 lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/README.md b/lib/node_modules/@stdlib/blas/base/zrotg/README.md new file mode 100644 index 000000000000..51f4943c13f6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/README.md @@ -0,0 +1,278 @@ + + +# zrotg + +> Construct a Givens plane rotation. + +
+ +## Usage + +```javascript +var zrotg = require( '@stdlib/blas/base/zrotg' ); +``` + +#### zrotg( za, zb ) + +Constructs a Givens plane rotation provided two double-precision complex floating-point values `za` and `zb`. + +```javascript +var Complex128 = require( '@stdlib/complex/float64/ctor' ); + +var za = new Complex128( 4.0, 3.0 ); +var zb = new Complex128( 0.0, 0.0 ); + +var out = zrotg( za, zb ); +// returns [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +``` + +The function has the following parameters: + +- **za**: rotational elimination parameter (complex number). +- **zb**: rotational elimination parameter (complex number). + +The function returns an array with the following elements: + +- **r**: real part of the rotated vector (real number). +- **r_imag**: imaginary part of the rotated vector (real number). +- **c**: cosine of the rotation angle (real number). +- **s**: real part of the sine of the rotation angle (real number). +- **s_imag**: imaginary part of the sine of the rotation angle (real number). + +#### zrotg.assign( za, zb, out, stride, offset ) + +Constructs a Givens plane rotation provided two double-precision complex floating-point values `za` and `zb` and assigns results to an output array. + +```javascript +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var za = new Complex128( 4.0, 3.0 ); +var zb = new Complex128( 0.0, 0.0 ); + +var out = new Float64Array( 5 ); + +var y = zrotg.assign( za, zb, out, 1, 0 ); +// returns [ 4.0, 3.0, 1.0, 0.0, 0.0 ] + +var bool = ( y === out ); +// returns true +``` + +
+ + + +
+ +## Notes + +- `zrotg()` corresponds to the [BLAS][blas] level 1 function [`zrotg`][blas-zrotg]. + +
+ + + +
+ +## Examples + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zrotg = require( '@stdlib/blas/base/zrotg' ); + +var out; +var i; + +function rand() { + return new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); +} + +for ( i = 0; i < 100; i++ ) { + out = zrotg( rand(), rand() ); + console.log( out ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zrotg.h" +``` + +#### c_zrotg( a, b, \*Out, strideOut ) + +Constructs a Givens plane rotation provided two double-precision complex floating-point values `a` and `b`. + +```c +#include "stdlib/complex/float64/ctor.h" + +double Out[ 5 ]; +const stdlib_complex128_t a = stdlib_complex128( 4.0, 3.0 ); +const stdlib_complex128_t b = stdlib_complex128( 0.0, 0.0 ); + +c_zrotg( a, b, Out, 1 ); +// Out => [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +``` + +The function accepts the following arguments: + +- **a**: `[in] stdlib_complex128_t` rotational elimination parameter. +- **b**: `[in] stdlib_complex128_t` rotational elimination parameter. +- **Out**: `[out] double*` output array. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. + +```c +void c_zrotg( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut ); +``` + +#### c_zrotg_assign( a, b, \*Out, strideOut, offsetOut ) + +Constructs a Givens plane rotation provided two double-precision complex floating-point values `a` and `b` using alternative indexing semantics. + +```c +#include "stdlib/complex/float64/ctor.h" + +double Out[ 5 ]; +const stdlib_complex128_t a = stdlib_complex128( 4.0, 3.0 ); +const stdlib_complex128_t b = stdlib_complex128( 0.0, 0.0 ); + +c_zrotg_assign( a, b, Out, 1, 0 ); +// Out => [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +``` + +The function accepts the following arguments: + +- **a**: `[in] stdlib_complex128_t` rotational elimination parameter. +- **b**: `[in] stdlib_complex128_t` rotational elimination parameter. +- **Out**: `[out] double*` output array. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. + +```c +void c_zrotg_assign( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zrotg.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + // Specify rotational elimination parameters: + const stdlib_complex128_t a = stdlib_complex128( 4.0, 3.0 ); + const stdlib_complex128_t b = stdlib_complex128( 0.0, 0.0 ); + int i; + + // Create output array: + double Out[ 5 ]; + + // Specify stride length: + const int strideOut = 1; + + // Apply plane rotation: + c_zrotg( a, b, Out, strideOut ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "Out[%d] = %lf\n", i, Out[ i ] ); + } + + // Apply plane rotation using alternative indexing semantics: + c_zrotg_assign( a, b, Out, strideOut, 0 ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "Out[%d] = %lf\n", i, Out[ i ] ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..e5e11fb35be2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var zrotg = require( './../lib/assign.js' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var za; + var zb; + var z; + var i; + + za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = zrotg( za, zb, new Float64Array(5), 1, 0 ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js new file mode 100644 index 000000000000..994539701975 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zrotg = tryRequire( resolve( __dirname, './../lib/assign.native.js' ) ); +var opts = { + 'skip': ( zrotg instanceof Error ) +}; + + +// MAIN // + +bench( pkg, opts, function benchmark( b ) { + var za; + var zb; + var z; + var i; + + za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = zrotg( za, zb, new Float64Array(5), 1, 0 ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js new file mode 100644 index 000000000000..79e381a2e5d3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var pkg = require( './../package.json' ).name; +var zrotg = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var za; + var zb; + var z; + var i; + + za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = zrotg( za, zb ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js new file mode 100644 index 000000000000..7396044beb0a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zrotg = tryRequire( resolve( __dirname, './../lib/zrotg.native.js' ) ); +var opts = { + 'skip': ( zrotg instanceof Error ) +}; + + +// MAIN // + +bench( pkg, opts, function benchmark( b ) { + var za; + var zb; + var z; + var i; + + za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = zrotg( za, zb ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile new file mode 100644 index 000000000000..9f97140e7cb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/zrotg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..cbfb638e5b73 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c @@ -0,0 +1,218 @@ +/** +* @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/zrotg.h" +#include "stdlib/complex/float64/ctor.h" +#include +#include +#include +#include + +#define NAME "zrotg" +#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 double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + stdlib_complex128_t a[ len ]; + stdlib_complex128_t b[ len ]; + double elapsed; + double out[ 5 ]; + double t; + int i; + + if ( a == NULL || b == NULL ) { + printf( "Error: failed to allocate memory\n" ); + if ( a != NULL ) free( a ); + if ( b != NULL ) free( b ); + return -1.0; + } + for ( i = 0; i < len; i++ ) { + a[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); + b[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_zrotg( a[ i % len ], b[ 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( a ); + free( b ); + 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 ) { + stdlib_complex128_t a[ len ]; + stdlib_complex128_t b[ len ]; + double elapsed; + double out[ 5 ]; + double t; + int i; + + if ( a == NULL || b == NULL ) { + printf( "Error: failed to allocate memory\n" ); + if ( a != NULL ) free( a ); + if ( b != NULL ) free( b ); + return -1.0; + } + for ( i = 0; i < len; i++ ) { + a[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); + b[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_zrotg_assign( a[ i % len ], b[ 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( a ); + free( b ); + 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 ); + if ( elapsed < 0.0 ) { + printf( "not ok %d benchmark failed\n", count ); + continue; + } + 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 ); + if ( elapsed < 0.0 ) { + printf( "not ok %d benchmark failed\n", count ); + continue; + } + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile new file mode 100644 index 000000000000..354a2ac8b281 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/zrotg.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/zrotg/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..661a838656eb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/benchmark.length.f @@ -0,0 +1,216 @@ +!> +! @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(5), parameter :: name = 'zrotg' ! 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 zrotg( a, b, c, s ) + complex(kind=kind(0.0d0)) :: a, b, s + double precision :: c + end subroutine zrotg + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, len + ! .. + ! Local scalars: + double precision :: elapsed, rand_val1, rand_val2, c + real :: t1, t2 + complex(kind=kind(0.0d0)) :: a, b, s + integer :: i, idx + ! .. + ! Local arrays: + complex(kind=kind(0.0d0)), allocatable :: va(:), vb(:) + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time, mod, cmplx + ! .. + ! Allocate arrays: + allocate( va(len), vb(len) ) + ! .. + do i = 1, len + call random_number( rand_val1 ) + call random_number( rand_val2 ) + va( i ) = cmplx( ( rand_val1 * 200.0d0 ) - 100.0d0, ( rand_val2 * 200.0d0 ) - 100.0d0, kind=kind(0.0d0) ) + call random_number( rand_val1 ) + call random_number( rand_val2 ) + vb( i ) = cmplx( ( rand_val1 * 200.0d0 ) - 100.0d0, ( rand_val2 * 200.0d0 ) - 100.0d0, kind=kind(0.0d0) ) + end do + ! .. + call cpu_time( t1 ) + ! .. + do i = 1, iterations + idx = mod( i-1, len ) + 1 + a = va( idx ) + b = vb( idx ) + call zrotg( a, b, c, s ) + if ( real(a) /= real(a) ) then + print '(A)', 'should not return NaN' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( real(a) /= real(a) ) then + print '(A)', 'should not return NaN' + end if + ! .. + ! Deallocate arrays: + deallocate( va, vb ) + ! .. + 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/zrotg/binding.gyp b/lib/node_modules/@stdlib/blas/base/zrotg/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/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/zrotg/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zrotg/docs/repl.txt new file mode 100644 index 000000000000..3b7aeeba0888 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( za, zb ) + Constructs a Givens plane rotation from two double-precision complex + floating-point numbers. + + Parameters + ---------- + za: Complex128 + Rotational elimination parameter. + + zb: Complex128 + Rotational elimination parameter. + + Returns + ------- + out: Float64Array + Computed values. + + Examples + -------- + // Standard usage: + > var za = new {{alias:@stdlib/complex/float64/ctor}}( 4.0, 3.0 ); + > var zb = new {{alias:@stdlib/complex/float64/ctor}}( 0.0, 0.0 ); + > var out = {{alias}}( za, zb ) + out => [ 4.0, 3.0, 1.0, 0.0, 0.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts new file mode 100644 index 000000000000..e560be4f581c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts @@ -0,0 +1,53 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Constructs a Givens plane rotation. +* +* @param za - rotational elimination parameter +* @param zb - rotational elimination parameter +* @returns output array +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var za = new Complex128( 4.0, 3.0 ); +* var zb = new Complex128( 0.0, 0.0 ); +* +* var out = zrotg( za, zb ); +* // returns [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +* +* @example +* var za = new Complex128( 5.0, 6.0 ); +* var zb = new Complex128( 0.0, 0.0 ); +* +* var out = zrotg( za, zb ); +* // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] +*/ +declare function zrotg( za: Complex128, zb: Complex128 ): Float64Array; + + +// EXPORTS // + +export = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts new file mode 100644 index 000000000000..e2be566c77f8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts @@ -0,0 +1,63 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128 = require( '@stdlib/complex/float64/ctor' ); +import zrotg = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const za = new Complex128( 1.0, 1.0 ); + const zb = new Complex128( 2.0, 2.0 ); + + zrotg( za, zb ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided an argument which is not a number... +{ + const za = new Complex128( 1.0, 1.0 ); + const zb = new Complex128( 2.0, 2.0 ); + + zrotg( true, zb ); // $ExpectError + zrotg( false, zb ); // $ExpectError + zrotg( null, zb ); // $ExpectError + zrotg( undefined, zb ); // $ExpectError + zrotg( '5', zb ); // $ExpectError + zrotg( [], zb ); // $ExpectError + zrotg( {}, zb ); // $ExpectError + + zrotg( za, true ); // $ExpectError + zrotg( za, false ); // $ExpectError + zrotg( za, null ); // $ExpectError + zrotg( za, undefined ); // $ExpectError + zrotg( za, '5' ); // $ExpectError + zrotg( za, [] ); // $ExpectError + zrotg( za, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const za = new Complex128( 1.0, 1.0 ); + const zb = new Complex128( 2.0, 2.0 ); + + zrotg(); // $ExpectError + zrotg( za ); // $ExpectError + zrotg( za, zb, 3.0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/zrotg/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c new file mode 100644 index 000000000000..4cd47a83986e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/zrotg.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + const stdlib_complex128_t a = stdlib_complex128( 5.0, 6.0 ); + const stdlib_complex128_t b = stdlib_complex128( 0.0, 0.0 ); + int i; + + // Create strided arrays: + double Out[ 5 ]; + + // Specify stride lengths: + const int strideOut = 1; + + // Apply plane rotation: + c_zrotg( a, b, Out, strideOut ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "Out[%d] = %lf\n", i, Out[ i ] ); + } + + // Apply plane rotation using alternative indexing semantics: + c_zrotg_assign( a, b, Out, strideOut, 0 ); + + // Print the result: + for ( i = 0; i < 5; i++ ) { + printf( "Out[%d] = %lf\n", i, Out[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js b/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js new file mode 100644 index 000000000000..ccb429eac137 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zrotg = require( './../lib' ); + +function example( za, zb ) { + var out = zrotg( za, zb ); + + console.log( 'za =', za.toString() ); + console.log( 'zb =', zb.toString() ); + console.log('ans =', out.toString()); + console.log( '-----------------------------' ); +} + +/* 1 */ +example(new Complex128( 5, 6 ), new Complex128( 0, 0 )); + +/* 2 */ +example(new Complex128( 4, 3 ), new Complex128( 0, 0 )); + +/* 3 */ +example(new Complex128( 1, 3 ), new Complex128( 2, 4 )); + +/* 4 */ +example(new Complex128( 2, 1 ), new Complex128( 0, 0 )); + +/* 5 */ +example(new Complex128( -3, 4 ), new Complex128( 0, 0 )); + +/* 6 */ +example(new Complex128( 0, 0 ), new Complex128( 5, 12 )); + +/* 7 */ +example(new Complex128( 3, 4 ), new Complex128( 1, 0 )); + +/* 8 */ +example(new Complex128( 6, -2 ), new Complex128( 3, 1 )); + +/* 9 */ +example(new Complex128( -2, 5 ), new Complex128( 4, -3 )); + +/* 10 */ +example(new Complex128( 1, -1 ), new Complex128( 1, 1 )); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/include.gypi b/lib/node_modules/@stdlib/blas/base/zrotg/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/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 nesting 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)', + ' +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); +* // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] +*/ +function zrotg( za, zb, out, stride, offset ) { + var scalar; + var scale; + var temp; + var za2; + var zb2; + var c2; + var c; + var s; + var r; + var d; + + // Handle NaN inputs - if either input is NaN (not a Complex128), return array of NaNs + if ( typeof za === 'number' && isnan( za ) ) { + out[ 0 ] = NaN; + out[ 1 ] = NaN; + out[ 2 ] = NaN; + out[ 3 ] = NaN; + out[ 4 ] = NaN; + return out; + } + if ( typeof zb === 'number' && isnan( zb ) ) { + out[ 0 ] = NaN; + out[ 1 ] = NaN; + out[ 2 ] = NaN; + out[ 3 ] = NaN; + out[ 4 ] = NaN; + return out; + } + + s = new Complex128( 0.0, 0.0 ); + r = new Complex128( 0.0, 0.0 ); + if ( real( zb ) === 0.0 && imag( zb ) === 0.0 ) { + c = 1.0; + r = za; + } else if ( real( za ) === 0.0 && imag( za ) === 0.0 ) { + c = 0; + if ( real( zb ) === 0 ) { + d = abs( imag( zb ) ); + r = new Complex128( d, 0.0 ); + s = cdiv( conj( zb ), new Complex128( d, 0.0 ) ); + } else if ( imag( zb ) === 0 ) { + d = abs( real( zb ) ); + r = new Complex128( d, 0.0 ); + s = cdiv( conj( zb ), new Complex128( d, 0.0 ) ); + } else { + zb2 = cabs2( zb ); + d = sqrt( zb2 ); + r = new Complex128( d, 0.0 ); + s = cdiv( conj( zb ), new Complex128( d, 0.0 ) ); + } + } else { + za2 = cabs2( za ); + zb2 = cabs2( zb ); + c2 = za2 + zb2; + + if ( za2 >= c2 * EPS ) { + c = sqrt( za2 / c2); + r = new Complex128( real( za ) / c, imag( za ) / c ); + scale = 1 / sqrt( c2 ); + temp = new Complex128( real( za ) / sqrt( za2 ), imag( za ) / sqrt( za2 ) ); + temp = new Complex128( real( temp ) * scale, imag( temp ) * scale ); + s = cmul( conj( zb ), temp ); + } else { + d = sqrt( za2 * c2 ); + c = za2 / d; + while ( c < EPS ) { + d *= 2; + c = za2 / d; + } + while ( c === 0.0 ) { + c = 1; + } + r = new Complex128( real( za ) / c, imag( za ) / c ); + scalar = new Complex128( 1 / d, 0.0 ); + s = cmul( conj( zb ), cmul( za, scalar ) ); + } + } + + za = r; + + out[ offset ] = real( za ); + out[ offset + stride ] = imag( za ); + out[ offset + ( 2 * stride ) ] = c; + out[ offset + ( 3 * stride ) ] = real( s ); + out[ offset + ( 4 * stride ) ] = imag( s ); + return out; +} + + +// EXPORTS // + +module.exports = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.native.js new file mode 100644 index 000000000000..0f3b2b1108b3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.native.js @@ -0,0 +1,58 @@ +/** +* @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 // + +/** +* Constructs a Givens plane rotation. +* +* @param {Complex128} za - rotational elimination parameter +* @param {Complex128} zb - rotational elimination parameter +* @param {Float64Array} out - output array +* @param {integer} stride - index increment +* @param {NonNegativeInteger} offset - starting index +* @returns {Float64Array} output array +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var za = new Complex128( 5.0, 6.0 ); +* // returns +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); +* // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] +*/ +function zrotg( za, zb, out, stride, offset ) { + addon.assign( za, zb, out, stride, offset ); + return out; +} + + +// EXPORTS // + +module.exports = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/index.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/index.js new file mode 100644 index 000000000000..1ecd29b6a2a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/index.js @@ -0,0 +1,72 @@ +/** +* @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'; + +/** +* Construct a Givens plane rotation. +* +* @module @stdlib/blas/base/zrotg +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var zrotg = require( '@stdlib/blas/base/zrotg' ); +* +* var za = new Complex128( 5.0, 6.0 ); +* // returns +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb ); +* // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] +* +* za = new Complex128( 3.0, 4.0 ); +* // returns +* +* zb = new Complex128( 5.0, 12.0 ); +* // returns +* +* out = zrotg( za, zb ); +* // out => [ 8.357032966310472,11.142710621747296,0.358979079308869,0.9046272798583499,-0.22974661075767622 ] +*/ + +// 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 zrotg; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zrotg = main; +} else { + zrotg = tmp; +} + + +// EXPORTS // + +module.exports = zrotg; + +// exports: { "assign": "zrotg.assign" } diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/main.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/main.js new file mode 100644 index 000000000000..99005080c7d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/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 zrotg = require( './zrotg.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly( zrotg, 'assign', assign ); + + +// EXPORTS // + +module.exports = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/native.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/native.js new file mode 100644 index 000000000000..3569e3ea1bbc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/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 zrotg = require( './zrotg.native.js' ); +var assign = require( './assign.native.js' ); + + +// MAIN // + +setReadOnly( zrotg, 'assign', assign ); + + +// EXPORTS // + +module.exports = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.js new file mode 100644 index 000000000000..746777214a3c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.js @@ -0,0 +1,55 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var assign = require( './assign.js' ); + + +// MAIN // + +/** +* Constructs a Givens plane rotation. +* +* @param {Complex128} za - rotational elimination parameter +* @param {Complex128} zb - rotational elimination parameter +* @returns {Float64Array} output array +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var za = new Complex128( 5.0, 6.0 ); +* // returns +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb ); +* // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] +*/ +function zrotg( za, zb ) { + return assign( za, zb, new Float64Array( 5 ), 1, 0 ); +} + + +// EXPORTS // + +module.exports = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.native.js new file mode 100644 index 000000000000..a426c0038d60 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/zrotg.native.js @@ -0,0 +1,57 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Constructs a Givens plane rotation. +* +* @param {Complex128} za - rotational elimination parameter +* @param {Complex128} zb - rotational elimination parameter +* @returns {Float64Array} output array +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var za = new Complex128( 5.0, 6.0 ); +* // returns +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb ); +* // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] +*/ +function zrotg( za, zb ) { + var out = new Float64Array( 5 ); + addon( za, zb, out, 1 ); + return out; +} + + +// EXPORTS // + +module.exports = zrotg; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/manifest.json b/lib/node_modules/@stdlib/blas/base/zrotg/manifest.json new file mode 100644 index 000000000000..3d0e9fe3b4ef --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/manifest.json @@ -0,0 +1,510 @@ +{ + "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/zrotg.f", + "./src/zrotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-complex128", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zrotg_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-complex128", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zrotg_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/zrotg_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/zrotg.f", + "./src/zrotg_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-complex128", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zrotg_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-complex128", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zrotg_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/zrotg_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/zrotg_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-complex128", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zrotg_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/zrotg_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/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-complex128", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/zrotg.c", + "./src/zrotg_assign.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag", + "@stdlib/complex/float64/conj", + "@stdlib/complex/float64/base/mul", + "@stdlib/complex/float64/base/div", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/sqrt", + "@stdlib/strided/base/stride2offset" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/package.json b/lib/node_modules/@stdlib/blas/base/zrotg/package.json new file mode 100644 index 000000000000..4bc6ab473d9f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/package.json @@ -0,0 +1,80 @@ +{ + "name": "@stdlib/blas/base/zrotg", + "version": "0.0.0", + "description": "Apply a plane rotation.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "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", + "linear", + "algebra", + "subroutines", + "zrotg", + "rotation", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex128", + "double", + "float64", + "float64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/src/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/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/zrotg/src/addon.c b/lib/node_modules/@stdlib/blas/base/zrotg/src/addon.c new file mode 100644 index 000000000000..43a888a8da67 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/addon.c @@ -0,0 +1,63 @@ +/** +* @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/zrotg.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_complex128.h" +#include "stdlib/napi/argv_strided_float64array.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, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 3 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, a, argv, 0 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, b, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 5, strideOut, argv, 2 ); + API_SUFFIX( c_zrotg )( a, b, 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, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 4 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, a, argv, 0 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, b, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 5, strideOut, argv, 2 ); + API_SUFFIX( c_zrotg_assign )( a, b, 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/zrotg/src/zrotg.c b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.c new file mode 100644 index 000000000000..aeb0d4da3c2e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.c @@ -0,0 +1,36 @@ +/** +* @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/zrotg.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a first input value +* @param b second input value +* @param Out output array +* @param strideOut output stride length +*/ +void API_SUFFIX( c_zrotg )( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut ) { + CBLAS_INT offsetOut = stdlib_strided_stride2offset( 5, strideOut ); + API_SUFFIX( c_zrotg_assign )( a, b, Out, strideOut, offsetOut ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.f b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.f new file mode 100644 index 000000000000..e0ccf3aa2483 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg.f @@ -0,0 +1,241 @@ +!> +! @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 Givens plane rotation for double-precision complex floating-point numbers. +! +! ## 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. +! +! ## References +! +! * Anderson E. (2017) Algorithm 978: Safe Scaling in the Level 1 BLAS. ACM Trans Math Softw 44:1--28. doi:[10.1145/3061665](https://doi.org/10.1145/3061665) +! +! ## 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 {complex128} a - rotational elimination parameter +! @param {complex128} b - rotational elimination parameter +! @param {double} c - cosine of the angle of rotation +! @param {complex128} s - sine of the angle of rotation +!< +subroutine zrotg( a, b, c, s ) + integer, parameter :: wp = kind(1.d0) +! +! -- Reference BLAS level1 routine -- +! -- Reference BLAS is a software package provided by Univ. of Tennessee, -- +! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- +! +! .. Constants .. + real(wp), parameter :: zero = 0.0_wp + real(wp), parameter :: one = 1.0_wp + complex(wp), parameter :: czero = 0.0_wp +! .. +! .. Scalar Arguments .. + real(wp) :: c + complex(wp) :: a, b, s +! .. +! .. Local Scalars .. + real(wp) :: d, f1, f2, g1, g2, h2, u, v, w, rtmax, safmin, safmax, rtmin + complex(wp) :: f, fs, g, gs, r, t +! .. +! .. Intrinsic Functions .. + intrinsic :: abs, aimag, conjg, max, min, real, sqrt, radix, minexponent, maxexponent +! .. +! .. Statement Functions .. + real(wp) :: ABSSQ +! .. +! .. Statement Function definitions .. + abssq( t ) = real( t )**2 + aimag( t )**2 +! .. +! .. Executable Statements .. +! +! Compute safe scaling constants + safmin = real(radix(0._wp),wp)**max( & + minexponent(0._wp)-1, & + 1-maxexponent(0._wp) & + ) + safmax = real(radix(0._wp),wp)**max( & + 1-minexponent(0._wp), & + maxexponent(0._wp)-1 & + ) + rtmin = sqrt( safmin ) +! + f = a + g = b + if( g == czero ) then + c = one + s = czero + r = f + else if( f == czero ) then + c = zero + if( real(g) == zero ) then + r = abs(aimag(g)) + s = conjg( g ) / r + elseif( aimag(g) == zero ) then + r = abs(real(g)) + s = conjg( g ) / r + else + g1 = max( abs(real(g)), abs(aimag(g)) ) + rtmax = sqrt( safmax/2 ) + if( g1 > rtmin .and. g1 < rtmax ) then +! +! Use unscaled algorithm +! +! The following two lines can be replaced by `d = abs( g )`. +! This algorithm do not use the intrinsic complex abs. + g2 = abssq( g ) + d = sqrt( g2 ) + s = conjg( g ) / d + r = d + else +! +! Use scaled algorithm +! + u = min( safmax, max( safmin, g1 ) ) + gs = g / u +! The following two lines can be replaced by `d = abs( gs )`. +! This algorithm do not use the intrinsic complex abs. + g2 = abssq( gs ) + d = sqrt( g2 ) + s = conjg( gs ) / d + r = d*u + end if + end if + else + f1 = max( abs(real(f)), abs(aimag(f)) ) + g1 = max( abs(real(g)), abs(aimag(g)) ) + rtmax = sqrt( safmax/4 ) + if( f1 > rtmin .and. f1 < rtmax .and. & + g1 > rtmin .and. g1 < rtmax ) then +! +! Use unscaled algorithm +! + f2 = abssq( f ) + g2 = abssq( g ) + h2 = f2 + g2 + ! safmin <= f2 <= h2 <= safmax + if( f2 >= h2 * safmin ) then + ! safmin <= f2/h2 <= 1, and h2/f2 is finite + c = sqrt( f2 / h2 ) + r = f / c + rtmax = rtmax * 2 + if( f2 > rtmin .and. h2 < rtmax ) then + ! safmin <= sqrt( f2*h2 ) <= safmax + s = conjg( g ) * ( f / sqrt( f2*h2 ) ) + else + s = conjg( g ) * ( r / h2 ) + end if + else + ! f2/h2 <= safmin may be subnormal, and h2/f2 may overflow. + ! Moreover, + ! safmin <= f2*f2 * safmax < f2 * h2 < h2*h2 * safmin <= safmax, + ! sqrt(safmin) <= sqrt(f2 * h2) <= sqrt(safmax). + ! Also, + ! g2 >> f2, which means that h2 = g2. + d = sqrt( f2 * h2 ) + c = f2 / d + if( c >= safmin ) then + r = f / c + else + ! f2 / sqrt(f2 * h2) < safmin, then + ! sqrt(safmin) <= f2 * sqrt(safmax) <= h2 / sqrt(f2 * h2) <= h2 * (safmin / f2) <= h2 <= safmax + r = f * ( h2 / d ) + end if + s = conjg( g ) * ( f / d ) + end if + else +! +! Use scaled algorithm +! + u = min( safmax, max( safmin, f1, g1 ) ) + gs = g / u + g2 = abssq( gs ) + if( f1 / u < rtmin ) then +! +! f is not well-scaled when scaled by g1. +! Use a different scaling for f. +! + v = min( safmax, max( safmin, f1 ) ) + w = v / u + fs = f / v + f2 = abssq( fs ) + h2 = f2*w**2 + g2 + else +! +! Otherwise use the same scaling for f and g. +! + w = one + fs = f / u + f2 = abssq( fs ) + h2 = f2 + g2 + end if + ! safmin <= f2 <= h2 <= safmax + if( f2 >= h2 * safmin ) then + ! safmin <= f2/h2 <= 1, and h2/f2 is finite + c = sqrt( f2 / h2 ) + r = fs / c + rtmax = rtmax * 2 + if( f2 > rtmin .and. h2 < rtmax ) then + ! safmin <= sqrt( f2*h2 ) <= safmax + s = conjg( gs ) * ( fs / sqrt( f2*h2 ) ) + else + s = conjg( gs ) * ( r / h2 ) + end if + else + ! f2/h2 <= safmin may be subnormal, and h2/f2 may overflow. + ! Moreover, + ! safmin <= f2*f2 * safmax < f2 * h2 < h2*h2 * safmin <= safmax, + ! sqrt(safmin) <= sqrt(f2 * h2) <= sqrt(safmax). + ! Also, + ! g2 >> f2, which means that h2 = g2. + d = sqrt( f2 * h2 ) + c = f2 / d + if( c >= safmin ) then + r = fs / c + else + ! f2 / sqrt(f2 * h2) < safmin, then + ! sqrt(safmin) <= f2 * sqrt(safmax) <= h2 / sqrt(f2 * h2) <= h2 * (safmin / f2) <= h2 <= safmax + r = fs * ( h2 / d ) + end if + s = conjg( gs ) * ( fs / d ) + end if + ! Rescale c and r + c = c * w + r = r * u + end if + end if + a = r + return +end subroutine zrotg diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c new file mode 100644 index 000000000000..39dac62e355d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c @@ -0,0 +1,155 @@ +/** +* @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/zrotg.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/real.h" +#include "stdlib/complex/float64/imag.h" +#include "stdlib/complex/float64/conj.h" +#include "stdlib/complex/float64/base/mul.h" +#include "stdlib/complex/float64/base/div.h" +#include "stdlib/math/base/special/abs.h" +#include "stdlib/math/base/special/sqrt.h" +#include +#include + +/** +* Computes the squared absolute value of a complex number. +* +* @param z complex number +* @return squared absolute value +*/ +static double cabs2( const stdlib_complex128_t z ) { + double re = stdlib_complex128_real( z ); + double im = stdlib_complex128_imag( z ); + return ( re * re ) + ( im * im ); +} + +/** +* Constructs a Givens plane rotation using alternative indexing semantics. +* +* @param a first rotational elimination parameter +* @param b second rotational elimination parameter +* @param Out output array +* @param strideOut output stride length +* @param offsetOut starting index for `Out` +*/ +void API_SUFFIX( c_zrotg_assign )( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + double a_re, a_im, b_re, b_im; + double za2, zb2, c2, c, d, scale; + stdlib_complex128_t r, s, temp, scalar, conj_b; + double safmin, safmax, rtmin, rtmax; + const double EPS = DBL_EPSILON; + + // Extract real and imaginary parts + a_re = stdlib_complex128_real( a ); + a_im = stdlib_complex128_imag( a ); + b_re = stdlib_complex128_real( b ); + b_im = stdlib_complex128_imag( b ); + + // Compute safe scaling constants + safmin = DBL_MIN / DBL_EPSILON; + safmax = 1.0 / safmin; + rtmin = sqrt( safmin ); + + // Initialize s and r + s = stdlib_complex128( 0.0, 0.0 ); + r = stdlib_complex128( 0.0, 0.0 ); + + // Case 1: b is zero + if ( b_re == 0.0 && b_im == 0.0 ) { + c = 1.0; + r = a; + } + // Case 2: a is zero + else if ( a_re == 0.0 && a_im == 0.0 ) { + c = 0.0; + if ( b_re == 0.0 ) { + d = stdlib_base_abs( b_im ); + r = stdlib_complex128( d, 0.0 ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_div( conj_b, r ); + } else if ( b_im == 0.0 ) { + d = stdlib_base_abs( b_re ); + r = stdlib_complex128( d, 0.0 ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_div( conj_b, r ); + } else { + zb2 = cabs2( b ); + d = stdlib_base_sqrt( zb2 ); + r = stdlib_complex128( d, 0.0 ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_div( conj_b, r ); + } + } + // Case 3: Both a and b are non-zero + else { + za2 = cabs2( a ); + zb2 = cabs2( b ); + c2 = za2 + zb2; + + if ( za2 >= c2 * EPS ) { + c = stdlib_base_sqrt( za2 / c2 ); + r = stdlib_complex128( a_re / c, a_im / c ); + + // Compute s = conj(b) * a / sqrt(za2 * c2) in a numerically stable way + rtmax = sqrt( safmax / 2.0 ); + if ( za2 > rtmin && c2 < rtmax * rtmax ) { + // safmin <= sqrt( za2*c2 ) <= safmax + scale = 1.0 / stdlib_base_sqrt( c2 ); + temp = stdlib_complex128( a_re / stdlib_base_sqrt( za2 ), a_im / stdlib_base_sqrt( za2 ) ); + temp = stdlib_complex128( stdlib_complex128_real( temp ) * scale, stdlib_complex128_imag( temp ) * scale ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_mul( conj_b, temp ); + } else { + scale = 1.0 / stdlib_base_sqrt( c2 ); + temp = stdlib_complex128( a_re / stdlib_base_sqrt( za2 ), a_im / stdlib_base_sqrt( za2 ) ); + temp = stdlib_complex128( stdlib_complex128_real( temp ) * scale, stdlib_complex128_imag( temp ) * scale ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_mul( conj_b, temp ); + } + } else { + // za2 / c2 <= EPS, so za2 is very small compared to zb2 + d = stdlib_base_sqrt( za2 * c2 ); + c = za2 / d; + + // Ensure c is not too small + while ( c < EPS && c != 0.0 ) { + d *= 2.0; + c = za2 / d; + } + if ( c == 0.0 ) { + c = 1.0; + } + + r = stdlib_complex128( a_re / c, a_im / c ); + scalar = stdlib_complex128( 1.0 / d, 0.0 ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_mul( conj_b, stdlib_base_complex128_mul( a, scalar ) ); + } + } + + // Store results in output array + Out[ offsetOut ] = stdlib_complex128_real( r ); + Out[ offsetOut + strideOut ] = stdlib_complex128_imag( r ); + Out[ offsetOut + ( 2 * strideOut ) ] = c; + Out[ offsetOut + ( 3 * strideOut ) ] = stdlib_complex128_real( s ); + Out[ offsetOut + ( 4 * strideOut ) ] = stdlib_complex128_imag( s ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_cblas.c b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_cblas.c new file mode 100644 index 000000000000..8a9fe417ad25 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_cblas.c @@ -0,0 +1,49 @@ +/** +* @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/zrotg_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/zrotg.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Constructs a Givens plane rotation. +* +* @param a first input value +* @param b second input value +* @param Out output array +* @param strideOut output stride length +*/ +void API_SUFFIX( c_zrotg )( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut ) { + API_SUFFIX( cblas_zrotg )( a, b, Out, strideOut ); +} + +/** +* Constructs a Givens plane rotation using alternative indexing semantics. +* +* @param a first input value +* @param b second input value +* @param Out output array +* @param strideOut output stride length +* @param offsetOut starting index for `Out` +*/ +void API_SUFFIX( c_zrotg_assign )( const stdlib_complex128_t a, const stdlib_complex128_t b, double *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_zrotg )( a, b, Out, strideOut ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_f.c b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_f.c new file mode 100644 index 000000000000..a830d577bd94 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_f.c @@ -0,0 +1,90 @@ +/** +* @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/zrotg.h" +#include "stdlib/blas/base/zrotg_fortran.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/real.h" +#include "stdlib/complex/float64/imag.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include "stdlib/strided/base/stride2offset.h" + + +/** +* Constructs a Givens plane rotation. +* +* @param a first input value +* @param b second input value +* @param Out output array +* @param strideOut output stride length +*/ +void API_SUFFIX( c_zrotg )( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut ) { + CBLAS_INT relOffset; + stdlib_complex128_t ta; + stdlib_complex128_t tb; + stdlib_complex128_t ts; + double c; + + relOffset = stdlib_strided_stride2offset( 5, strideOut ); + + ta = a; + tb = b; + + zrotg( &ta, &tb, &c, &ts ); + + Out[ relOffset ] = stdlib_complex128_real( ta ); // real(r) + Out[ relOffset + strideOut ] = stdlib_complex128_imag( ta ); // imag(r) + Out[ relOffset + ( 2 * strideOut ) ] = c; + Out[ relOffset + ( 3 * strideOut ) ] = stdlib_complex128_real( ts ); // real(s) + Out[ relOffset + ( 4 * strideOut ) ] = stdlib_complex128_imag( ts ); // imag(s) +} + +/** +* Constructs a Givens plane rotation using alternative indexing semantics. +* +* @param a first input value +* @param b second input value +* @param Out output array +* @param strideOut output stride length +* @param offsetOut starting index for `Out` +*/ +void API_SUFFIX( c_zrotg_assign )( const stdlib_complex128_t a, const stdlib_complex128_t b, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + CBLAS_INT minIndex; + CBLAS_INT relOffset; + stdlib_complex128_t ta; + stdlib_complex128_t tb; + stdlib_complex128_t ts; + double c; + + minIndex = stdlib_strided_min_view_buffer_index( 5, strideOut, offsetOut ); + Out += minIndex; + + relOffset = offsetOut - minIndex; + + ta = a; + tb = b; + + zrotg( &ta, &tb, &c, &ts ); + + Out[ relOffset ] = stdlib_complex128_real( ta ); // real(r) + Out[ relOffset + strideOut ] = stdlib_complex128_imag( ta ); // imag(r) + Out[ relOffset + ( 2 * strideOut ) ] = c; + Out[ relOffset + ( 3 * strideOut ) ] = stdlib_complex128_real( ts ); // real(s) + Out[ relOffset + ( 4 * strideOut ) ] = stdlib_complex128_imag( ts ); // imag(s) +} diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js new file mode 100644 index 000000000000..e2a1df3480ff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js @@ -0,0 +1,222 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var max = require( '@stdlib/math/base/special/max' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var zrotg = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 2', function test( t ) { + t.strictEqual( zrotg.length, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes a Givens plane rotation for complex numbers', function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var za; + var zb; + var i; + var j; + var e; + + expected = [ + [ 5.0, 6.0, 1.0, 0.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], + [ 13.0, 0.0, 0.0, 1.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.0, -1.0 ], + [ 0.0, 0.0, 1.0, 0.0, 0.0 ], + [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], + [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], + [ 5.0, 0.0, 0.6, 0.8, 0.0 ], + [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + ]; + values = [ + [ 5.0, 6.0, 0.0, 0.0 ], + [ 0.0, 0.0, 5.0, 12.0 ], + [ 0.0, 0.0, 13.0, 0.0 ], + [ 0.0, 0.0, 0.0, 13.0 ], + [ 0.0, 0.0, 0.0, 0.0 ], + [ 3.0, 4.0, 5.0, 12.0 ], + [ -3.0, -4.0, 5.0, 12.0 ], + [ 3.0, 0.0, 4.0, 0.0 ], + [ 0.0, 3.0, 0.0, 4.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + za = new Complex128( values[i][0], values[i][1] ); + zb = new Complex128( values[i][2], values[i][3] ); + e = new Float64Array( expected[i] ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = abs( out[j] - e[j] ); + tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); + t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function handles edge case where za is much larger than zb', function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e10, 1.0e10 ); + zb = new Complex128( 1.0, 1.0 ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 1 when za >> zb + t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + + t.end(); +}); + +tape( 'the function handles edge case where zb is much larger than za', function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( 1.0e10, 1.0e10 ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 0 when zb >> za + t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + + t.end(); +}); + +tape( 'the function handles very small complex numbers', function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e-100, 1.0e-100 ); + zb = new Complex128( 2.0e-100, 2.0e-100 ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + 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 = zrotg( NaN, 1.0, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when za is NaN' ); + } + + actual = zrotg( 1.0, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when zb is NaN' ); + } + + actual = zrotg( NaN, NaN, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when both are NaN' ); + } + t.end(); +}); + +tape( 'the function handles Complex128 objects with NaN components', function test( t ) { + var actual; + var za; + var zb; + var i; + + // za has NaN real part + za = new Complex128( NaN, 1.0 ); + zb = new Complex128( 1.0, 1.0 ); + actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.real is NaN' ); + } + + // za has NaN imaginary part + za = new Complex128( 1.0, NaN ); + zb = new Complex128( 1.0, 1.0 ); + actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.imag is NaN' ); + } + + // zb has NaN real part + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( NaN, 1.0 ); + actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.real is NaN' ); + } + + // zb has NaN imaginary part + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( 1.0, NaN ); + actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.imag is NaN' ); + } + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js new file mode 100644 index 000000000000..9f43efd32663 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js @@ -0,0 +1,169 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zrotg = tryRequire( resolve( __dirname, './../lib/assign.native.js' ) ); +var opts = { + 'skip': ( zrotg instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', opts, function test( t ) { + t.strictEqual( zrotg.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes a Givens plane rotation for complex numbers', opts, function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var za; + var zb; + var i; + var j; + var e; + + expected = [ + [ 5.0, 6.0, 1.0, 0.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], + [ 13.0, 0.0, 0.0, 1.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.0, -1.0 ], + [ 0.0, 0.0, 1.0, 0.0, 0.0 ], + [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], + [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], + [ 5.0, 0.0, 0.6, 0.8, 0.0 ], + [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + ]; + values = [ + [ 5.0, 6.0, 0.0, 0.0 ], + [ 0.0, 0.0, 5.0, 12.0 ], + [ 0.0, 0.0, 13.0, 0.0 ], + [ 0.0, 0.0, 0.0, 13.0 ], + [ 0.0, 0.0, 0.0, 0.0 ], + [ 3.0, 4.0, 5.0, 12.0 ], + [ -3.0, -4.0, 5.0, 12.0 ], + [ 3.0, 0.0, 4.0, 0.0 ], + [ 0.0, 3.0, 0.0, 4.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + za = new Complex128( values[i][0], values[i][1] ); + zb = new Complex128( values[i][2], values[i][3] ); + e = new Float64Array( expected[i] ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = abs( out[j] - e[j] ); + tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); + t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function handles edge case where za is much larger than zb', opts, function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e10, 1.0e10 ); + zb = new Complex128( 1.0, 1.0 ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 1 when za >> zb + t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + + t.end(); +}); + +tape( 'the function handles edge case where zb is much larger than za', opts, function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( 1.0e10, 1.0e10 ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 0 when zb >> za + t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + + t.end(); +}); + +tape( 'the function handles very small complex numbers', opts, function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e-100, 1.0e-100 ); + zb = new Complex128( 2.0e-100, 2.0e-100 ); + out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js new file mode 100644 index 000000000000..b4637514638c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var zrotg = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof zrotg.assign, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var zrotg = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zrotg, mock, 'returns native implementation' ); + 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 zrotg; + var main; + + main = require( './../lib/zrotg.js' ); + + zrotg = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zrotg, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js new file mode 100644 index 000000000000..945750e4932c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js @@ -0,0 +1,222 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var zrotg = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 2', function test( t ) { + t.strictEqual( zrotg.length, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes a Givens plane rotation for complex numbers', function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var za; + var zb; + var i; + var j; + var e; + + expected = [ + [ 5.0, 6.0, 1.0, 0.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], + [ 13.0, 0.0, 0.0, 1.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.0, -1.0 ], + [ 0.0, 0.0, 1.0, 0.0, 0.0 ], + [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], + [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], + [ 5.0, 0.0, 0.6, 0.8, 0.0 ], + [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + ]; + values = [ + [ 5.0, 6.0, 0.0, 0.0 ], + [ 0.0, 0.0, 5.0, 12.0 ], + [ 0.0, 0.0, 13.0, 0.0 ], + [ 0.0, 0.0, 0.0, 13.0 ], + [ 0.0, 0.0, 0.0, 0.0 ], + [ 3.0, 4.0, 5.0, 12.0 ], + [ -3.0, -4.0, 5.0, 12.0 ], + [ 3.0, 0.0, 4.0, 0.0 ], + [ 0.0, 3.0, 0.0, 4.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + za = new Complex128( values[i][0], values[i][1] ); + zb = new Complex128( values[i][2], values[i][3] ); + e = new Float64Array( expected[i] ); + out = zrotg( za, zb ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = abs( out[j] - e[j] ); + tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); + t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function handles edge case where za is much larger than zb', function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e10, 1.0e10 ); + zb = new Complex128( 1.0, 1.0 ); + out = zrotg( za, zb ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 1 when za >> zb + t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + + t.end(); +}); + +tape( 'the function handles edge case where zb is much larger than za', function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( 1.0e10, 1.0e10 ); + out = zrotg( za, zb ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 0 when zb >> za + t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + + t.end(); +}); + +tape( 'the function handles very small complex numbers', function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e-100, 1.0e-100 ); + zb = new Complex128( 2.0e-100, 2.0e-100 ); + out = zrotg( za, zb ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + 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 = zrotg( NaN, 1.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when za is NaN' ); + } + + actual = zrotg( 1.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when zb is NaN' ); + } + + actual = zrotg( NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when both are NaN' ); + } + t.end(); +}); + +tape( 'the function handles Complex128 objects with NaN components', function test( t ) { + var actual; + var za; + var zb; + var i; + + // za has NaN real part + za = new Complex128( NaN, 1.0 ); + zb = new Complex128( 1.0, 1.0 ); + actual = zrotg( za, zb ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.real is NaN' ); + } + + // za has NaN imaginary part + za = new Complex128( 1.0, NaN ); + zb = new Complex128( 1.0, 1.0 ); + actual = zrotg( za, zb ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.imag is NaN' ); + } + + // zb has NaN real part + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( NaN, 1.0 ); + actual = zrotg( za, zb ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.real is NaN' ); + } + + // zb has NaN imaginary part + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( 1.0, NaN ); + actual = zrotg( za, zb ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.imag is NaN' ); + } + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js new file mode 100644 index 000000000000..2def716c9477 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js @@ -0,0 +1,169 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zrotg = tryRequire( resolve( __dirname, './../lib/zrotg.native.js' ) ); +var opts = { + 'skip': ( zrotg instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 2', opts, function test( t ) { + t.strictEqual( zrotg.length, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes a Givens plane rotation for complex numbers', opts, function test( t ) { + var expected; + var values; + var delta; + var tol; + var out; + var za; + var zb; + var i; + var j; + var e; + + expected = [ + [ 5.0, 6.0, 1.0, 0.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], + [ 13.0, 0.0, 0.0, 1.0, 0.0 ], + [ 13.0, 0.0, 0.0, 0.0, -1.0 ], + [ 0.0, 0.0, 1.0, 0.0, 0.0 ], + [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], + [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], + [ 5.0, 0.0, 0.6, 0.8, 0.0 ], + [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + ]; + values = [ + [ 5.0, 6.0, 0.0, 0.0 ], + [ 0.0, 0.0, 5.0, 12.0 ], + [ 0.0, 0.0, 13.0, 0.0 ], + [ 0.0, 0.0, 0.0, 13.0 ], + [ 0.0, 0.0, 0.0, 0.0 ], + [ 3.0, 4.0, 5.0, 12.0 ], + [ -3.0, -4.0, 5.0, 12.0 ], + [ 3.0, 0.0, 4.0, 0.0 ], + [ 0.0, 3.0, 0.0, 4.0 ] + ]; + + for ( i = 0; i < values.length; i++ ) { + za = new Complex128( values[i][0], values[i][1] ); + zb = new Complex128( values[i][2], values[i][3] ); + e = new Float64Array( expected[i] ); + out = zrotg( za, zb ); + for ( j = 0; j < out.length; j++ ) { + if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { + t.strictEqual( out[j], e[j], 'returns expected value' ); + } else { + delta = abs( out[j] - e[j] ); + tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); + t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); + +tape( 'the function handles edge case where za is much larger than zb', opts, function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e10, 1.0e10 ); + zb = new Complex128( 1.0, 1.0 ); + out = zrotg( za, zb ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 1 when za >> zb + t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + + t.end(); +}); + +tape( 'the function handles edge case where zb is much larger than za', opts, function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0, 1.0 ); + zb = new Complex128( 1.0e10, 1.0e10 ); + out = zrotg( za, zb ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + // c should be close to 0 when zb >> za + t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + + t.end(); +}); + +tape( 'the function handles very small complex numbers', opts, function test( t ) { + var out; + var za; + var zb; + + za = new Complex128( 1.0e-100, 1.0e-100 ); + zb = new Complex128( 2.0e-100, 2.0e-100 ); + out = zrotg( za, zb ); + + t.strictEqual( out.length, 5, 'returns array of length 5' ); + t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); + t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); + t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); + t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); + t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + + t.end(); +}); From 0454a95d07ca112caa3dd92f885815dddb4b9258 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Sat, 10 Jan 2026 18:02:38 +0530 Subject: [PATCH 2/5] fix: linting and updated copyright years --- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: missing_dependencies - 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 --- --- .../base/zrotg/benchmark/benchmark.assign.js | 73 +++++-- .../benchmark/benchmark.assign.native.js | 71 ++++-- .../blas/base/zrotg/benchmark/benchmark.js | 74 +++++-- .../base/zrotg/benchmark/benchmark.native.js | 74 +++++-- .../blas/base/zrotg/benchmark/c/Makefile | 2 +- .../base/zrotg/benchmark/c/benchmark.length.c | 50 ++--- .../base/zrotg/benchmark/fortran/Makefile | 4 +- .../blas/base/zrotg/docs/types/index.d.ts | 2 +- .../blas/base/zrotg/docs/types/test.ts | 2 +- .../blas/base/zrotg/examples/c/Makefile | 2 +- .../blas/base/zrotg/examples/c/example.c | 2 +- .../@stdlib/blas/base/zrotg/examples/index.js | 32 +-- .../@stdlib/blas/base/zrotg/lib/assign.js | 99 ++++----- .../blas/base/zrotg/src/zrotg_assign.c | 29 +-- .../blas/base/zrotg/test/test.assign.js | 202 +++++++++-------- .../base/zrotg/test/test.assign.native.js | 140 ++++++------ .../@stdlib/blas/base/zrotg/test/test.js | 26 +-- .../blas/base/zrotg/test/test.zrotg.js | 204 +++++++++--------- .../blas/base/zrotg/test/test.zrotg.native.js | 142 ++++++------ 19 files changed, 680 insertions(+), 550 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js index e5e11fb35be2..488496d541c2 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -23,34 +23,81 @@ var bench = require( '@stdlib/bench' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var zrotg = require( './../lib/assign.js' ); -// MAIN // +// FUNCTIONS // -bench( pkg, function benchmark( b ) { +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { // eslint-disable-line no-unused-vars var za; var zb; var z; - var i; za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + z = new Float64Array( 5 ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = zrotg( za, zb, new Float64Array(5), 1, 0 ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zrotg( za, zb, z, 1, 0 ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); if ( isnan( z[ i%4 ] ) ) { b.fail( 'should not return NaN' ); } + b.pass( 'benchmark finished' ); + b.end(); } - b.toc(); - if ( isnan( z[ i%4 ] ) ) { - b.fail( 'should not return NaN' ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); } - b.pass( 'benchmark finished' ); - b.end(); -}); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js index 994539701975..a1ff3b8e0b2d 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.assign.native.js @@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -38,28 +39,74 @@ var opts = { }; -// MAIN // +// FUNCTIONS // -bench( pkg, opts, function benchmark( b ) { +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { // eslint-disable-line no-unused-vars var za; var zb; var z; - var i; za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); + z = new Float64Array( 5 ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = zrotg( za, zb, new Float64Array(5), 1, 0 ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zrotg( za, zb, z, 1, 0 ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); if ( isnan( z[ i%4 ] ) ) { b.fail( 'should not return NaN' ); } + b.pass( 'benchmark finished' ); + b.end(); } - b.toc(); - if ( isnan( z[ i%4 ] ) ) { - b.fail( 'should not return NaN' ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, opts, f ); } - b.pass( 'benchmark finished' ); - b.end(); -}); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js index 79e381a2e5d3..f0593431c093 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -23,33 +23,79 @@ var bench = require( '@stdlib/bench' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var pkg = require( './../package.json' ).name; var zrotg = require( './../lib' ); -// MAIN // +// FUNCTIONS // -bench( pkg, function benchmark( b ) { +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { // eslint-disable-line no-unused-vars var za; var zb; - var z; - var i; za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = zrotg( za, zb ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = zrotg( za, zb ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); if ( isnan( z[ i%4 ] ) ) { b.fail( 'should not return NaN' ); } + b.pass( 'benchmark finished' ); + b.end(); } - b.toc(); - if ( isnan( z[ i%4 ] ) ) { - b.fail( 'should not return NaN' ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); } - b.pass( 'benchmark finished' ); - b.end(); -}); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js index 7396044beb0a..7f3619c9112a 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -37,28 +38,73 @@ var opts = { }; -// MAIN // +// FUNCTIONS // -bench( pkg, opts, function benchmark( b ) { +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { // eslint-disable-line no-unused-vars var za; var zb; - var z; - var i; za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = zrotg( za, zb ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = zrotg( za, zb ); + if ( isnan( z[ i%4 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); if ( isnan( z[ i%4 ] ) ) { b.fail( 'should not return NaN' ); } + b.pass( 'benchmark finished' ); + b.end(); } - b.toc(); - if ( isnan( z[ i%4 ] ) ) { - b.fail( 'should not return NaN' ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, opts, f ); } - b.pass( 'benchmark finished' ); - b.end(); -}); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile index 9f97140e7cb0..0756dc7da20a 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c index cbfb638e5b73..d23be252da13 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c @@ -16,13 +16,13 @@ * limitations under the License. */ -#include #include "stdlib/blas/base/zrotg.h" #include "stdlib/complex/float64/ctor.h" -#include -#include #include +#include +#include #include +#include #define NAME "zrotg" #define ITERATIONS 10000000 @@ -75,7 +75,7 @@ static void print_results( int iterations, double elapsed ) { static double tic( void ) { struct timeval now; gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } /** @@ -98,24 +98,18 @@ static double rand_double( void ) { static double benchmark1( int iterations, int len ) { stdlib_complex128_t a[ len ]; stdlib_complex128_t b[ len ]; - double elapsed; double out[ 5 ]; + double elapsed; double t; int i; - if ( a == NULL || b == NULL ) { - printf( "Error: failed to allocate memory\n" ); - if ( a != NULL ) free( a ); - if ( b != NULL ) free( b ); - return -1.0; - } for ( i = 0; i < len; i++ ) { - a[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); - b[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); + a[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); + b[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_zrotg( a[ i % len ], b[ i % len ], out, 1 ); + c_zrotg( a[i], b[i], out, 1 ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -125,8 +119,6 @@ static double benchmark1( int iterations, int len ) { if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); } - free( a ); - free( b ); return elapsed; } @@ -140,24 +132,18 @@ static double benchmark1( int iterations, int len ) { static double benchmark2( int iterations, int len ) { stdlib_complex128_t a[ len ]; stdlib_complex128_t b[ len ]; - double elapsed; double out[ 5 ]; + double elapsed; double t; int i; - if ( a == NULL || b == NULL ) { - printf( "Error: failed to allocate memory\n" ); - if ( a != NULL ) free( a ); - if ( b != NULL ) free( b ); - return -1.0; - } for ( i = 0; i < len; i++ ) { - a[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); - b[ i ] = stdlib_complex128( ( rand_double() * 200.0 ) - 100.0, ( rand_double() * 200.0 ) - 100.0 ); + a[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); + b[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_zrotg_assign( a[ i % len ], b[ i % len ], out, 1, 0 ); + c_zrotg_assign( a[i], b[i], out, 1, 0 ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -167,8 +153,6 @@ static double benchmark2( int iterations, int len ) { if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); } - free( a ); - free( b ); return elapsed; } @@ -190,15 +174,11 @@ int main( void ) { count = 0; for ( i = MIN; i <= MAX; i++ ) { len = pow( 10, i ); - iter = ITERATIONS / pow( 10, i - 1 ); + 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 ); - if ( elapsed < 0.0 ) { - printf( "not ok %d benchmark failed\n", count ); - continue; - } print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } @@ -206,10 +186,6 @@ int main( void ) { count += 1; printf( "# c::%s:assign:len=%d\n", NAME, len ); elapsed = benchmark2( iter, len ); - if ( elapsed < 0.0 ) { - printf( "not ok %d benchmark failed\n", count ); - continue; - } print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile index 354a2ac8b281..876392fd8ae1 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. @@ -78,7 +78,7 @@ endif INCLUDE ?= # List of Fortran source files: -SOURCE_FILES ?= ../../src/zrotg.f +SOURCE_FILES ?= ../../src/zdrot.f # List of Fortran targets: f_targets := benchmark.length.out diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts index e560be4f581c..8e1e7e7ee9cd 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts index e2be566c77f8..a23e40dbe88a 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile index 6aed70daf167..c8f8e9a1517b 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c index 4cd47a83986e..1a0652f5212b 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js b/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js index ccb429eac137..a2df1f843937 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -21,41 +21,41 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' ); var zrotg = require( './../lib' ); -function example( za, zb ) { - var out = zrotg( za, zb ); +function example(za, zb) { + var out = zrotg(za, zb); - console.log( 'za =', za.toString() ); - console.log( 'zb =', zb.toString() ); + console.log('za =', za.toString()); + console.log('zb =', zb.toString()); console.log('ans =', out.toString()); - console.log( '-----------------------------' ); + console.log('-----------------------------'); } /* 1 */ -example(new Complex128( 5, 6 ), new Complex128( 0, 0 )); +example(new Complex128(5, 6), new Complex128(0, 0)); /* 2 */ -example(new Complex128( 4, 3 ), new Complex128( 0, 0 )); +example(new Complex128(4, 3), new Complex128(0, 0)); /* 3 */ -example(new Complex128( 1, 3 ), new Complex128( 2, 4 )); +example(new Complex128(1, 3), new Complex128(2, 4)); /* 4 */ -example(new Complex128( 2, 1 ), new Complex128( 0, 0 )); +example(new Complex128(2, 1), new Complex128(0, 0)); /* 5 */ -example(new Complex128( -3, 4 ), new Complex128( 0, 0 )); +example(new Complex128(-3, 4), new Complex128(0, 0)); /* 6 */ -example(new Complex128( 0, 0 ), new Complex128( 5, 12 )); +example(new Complex128(0, 0), new Complex128(5, 12)); /* 7 */ -example(new Complex128( 3, 4 ), new Complex128( 1, 0 )); +example(new Complex128(3, 4), new Complex128(1, 0)); /* 8 */ -example(new Complex128( 6, -2 ), new Complex128( 3, 1 )); +example(new Complex128(6, -2), new Complex128(3, 1)); /* 9 */ -example(new Complex128( -2, 5 ), new Complex128( 4, -3 )); +example(new Complex128(-2, 5), new Complex128(4, -3)); /* 10 */ -example(new Complex128( 1, -1 ), new Complex128( 1, 1 )); +example(new Complex128(1, -1), new Complex128(1, 1)); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.js b/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.js index 3a329e419e7a..2f668d5b7c8d 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/assign.js @@ -57,7 +57,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * var out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); * // returns [ 5.0, 6.0, 1.0, 0.0, 0.0 ] */ -function zrotg( za, zb, out, stride, offset ) { +function zrotg(za, zb, out, stride, offset) { var scalar; var scale; var temp; @@ -70,79 +70,80 @@ function zrotg( za, zb, out, stride, offset ) { var d; // Handle NaN inputs - if either input is NaN (not a Complex128), return array of NaNs - if ( typeof za === 'number' && isnan( za ) ) { - out[ 0 ] = NaN; - out[ 1 ] = NaN; - out[ 2 ] = NaN; - out[ 3 ] = NaN; - out[ 4 ] = NaN; + if (typeof za === 'number' && isnan(za)) { + out[0] = NaN; + out[1] = NaN; + out[2] = NaN; + out[3] = NaN; + out[4] = NaN; return out; } - if ( typeof zb === 'number' && isnan( zb ) ) { - out[ 0 ] = NaN; - out[ 1 ] = NaN; - out[ 2 ] = NaN; - out[ 3 ] = NaN; - out[ 4 ] = NaN; + if (typeof zb === 'number' && isnan(zb)) { + out[0] = NaN; + out[1] = NaN; + out[2] = NaN; + out[3] = NaN; + out[4] = NaN; return out; } - s = new Complex128( 0.0, 0.0 ); - r = new Complex128( 0.0, 0.0 ); - if ( real( zb ) === 0.0 && imag( zb ) === 0.0 ) { + s = new Complex128(0.0, 0.0); + r = new Complex128(0.0, 0.0); + if (real(zb) === 0.0 && imag(zb) === 0.0) { c = 1.0; r = za; - } else if ( real( za ) === 0.0 && imag( za ) === 0.0 ) { + } else if (real(za) === 0.0 && imag(za) === 0.0) { c = 0; - if ( real( zb ) === 0 ) { - d = abs( imag( zb ) ); - r = new Complex128( d, 0.0 ); - s = cdiv( conj( zb ), new Complex128( d, 0.0 ) ); - } else if ( imag( zb ) === 0 ) { - d = abs( real( zb ) ); - r = new Complex128( d, 0.0 ); - s = cdiv( conj( zb ), new Complex128( d, 0.0 ) ); + if (real(zb) === 0) { + d = abs(imag(zb)); + r = new Complex128(d, 0.0); + s = cdiv(conj(zb), new Complex128(d, 0.0)); + } else if (imag(zb) === 0) { + d = abs(real(zb)); + r = new Complex128(d, 0.0); + s = cdiv(conj(zb), new Complex128(d, 0.0)); } else { - zb2 = cabs2( zb ); - d = sqrt( zb2 ); - r = new Complex128( d, 0.0 ); - s = cdiv( conj( zb ), new Complex128( d, 0.0 ) ); + zb2 = cabs2(zb); + d = sqrt(zb2); + r = new Complex128(d, 0.0); + s = cdiv(conj(zb), new Complex128(d, 0.0)); } } else { - za2 = cabs2( za ); - zb2 = cabs2( zb ); + za2 = cabs2(za); + zb2 = cabs2(zb); c2 = za2 + zb2; - if ( za2 >= c2 * EPS ) { - c = sqrt( za2 / c2); - r = new Complex128( real( za ) / c, imag( za ) / c ); - scale = 1 / sqrt( c2 ); - temp = new Complex128( real( za ) / sqrt( za2 ), imag( za ) / sqrt( za2 ) ); - temp = new Complex128( real( temp ) * scale, imag( temp ) * scale ); - s = cmul( conj( zb ), temp ); + if (za2 >= c2 * EPS) { + c = sqrt(za2 / c2); + r = new Complex128(real(za) / c, imag(za) / c); + scale = 1 / sqrt(c2); + + temp = new Complex128(real(za) / sqrt(za2), imag(za) / sqrt(za2)); + temp = new Complex128(real(temp) * scale, imag(temp) * scale); + s = cmul(conj(zb), temp); } else { - d = sqrt( za2 * c2 ); + d = sqrt(za2 * c2); c = za2 / d; - while ( c < EPS ) { + while (c < EPS) { d *= 2; c = za2 / d; } - while ( c === 0.0 ) { + while (c === 0.0) { c = 1; } - r = new Complex128( real( za ) / c, imag( za ) / c ); - scalar = new Complex128( 1 / d, 0.0 ); - s = cmul( conj( zb ), cmul( za, scalar ) ); + r = new Complex128(real(za) / c, imag(za) / c); + scalar = new Complex128(1 / d, 0.0); + s = cmul(conj(zb), cmul(za, scalar)); } } za = r; - out[ offset ] = real( za ); - out[ offset + stride ] = imag( za ); - out[ offset + ( 2 * stride ) ] = c; - out[ offset + ( 3 * stride ) ] = real( s ); - out[ offset + ( 4 * stride ) ] = imag( s ); + out[offset] = real(za); + out[offset + stride] = imag(za); + out[offset + (2 * stride)] = c; + out[offset + (3 * stride)] = real(s); + out[offset + (4 * stride)] = imag(s); return out; } diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c index 39dac62e355d..259f7f475104 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c +++ b/lib/node_modules/@stdlib/blas/base/zrotg/src/zrotg_assign.c @@ -54,7 +54,6 @@ void API_SUFFIX( c_zrotg_assign )( const stdlib_complex128_t a, const stdlib_com double a_re, a_im, b_re, b_im; double za2, zb2, c2, c, d, scale; stdlib_complex128_t r, s, temp, scalar, conj_b; - double safmin, safmax, rtmin, rtmax; const double EPS = DBL_EPSILON; // Extract real and imaginary parts @@ -63,14 +62,8 @@ void API_SUFFIX( c_zrotg_assign )( const stdlib_complex128_t a, const stdlib_com b_re = stdlib_complex128_real( b ); b_im = stdlib_complex128_imag( b ); - // Compute safe scaling constants - safmin = DBL_MIN / DBL_EPSILON; - safmax = 1.0 / safmin; - rtmin = sqrt( safmin ); - - // Initialize s and r + // Initialize s (r is always assigned before use) s = stdlib_complex128( 0.0, 0.0 ); - r = stdlib_complex128( 0.0, 0.0 ); // Case 1: b is zero if ( b_re == 0.0 && b_im == 0.0 ) { @@ -109,21 +102,11 @@ void API_SUFFIX( c_zrotg_assign )( const stdlib_complex128_t a, const stdlib_com r = stdlib_complex128( a_re / c, a_im / c ); // Compute s = conj(b) * a / sqrt(za2 * c2) in a numerically stable way - rtmax = sqrt( safmax / 2.0 ); - if ( za2 > rtmin && c2 < rtmax * rtmax ) { - // safmin <= sqrt( za2*c2 ) <= safmax - scale = 1.0 / stdlib_base_sqrt( c2 ); - temp = stdlib_complex128( a_re / stdlib_base_sqrt( za2 ), a_im / stdlib_base_sqrt( za2 ) ); - temp = stdlib_complex128( stdlib_complex128_real( temp ) * scale, stdlib_complex128_imag( temp ) * scale ); - conj_b = stdlib_complex128_conj( b ); - s = stdlib_base_complex128_mul( conj_b, temp ); - } else { - scale = 1.0 / stdlib_base_sqrt( c2 ); - temp = stdlib_complex128( a_re / stdlib_base_sqrt( za2 ), a_im / stdlib_base_sqrt( za2 ) ); - temp = stdlib_complex128( stdlib_complex128_real( temp ) * scale, stdlib_complex128_imag( temp ) * scale ); - conj_b = stdlib_complex128_conj( b ); - s = stdlib_base_complex128_mul( conj_b, temp ); - } + scale = 1.0 / stdlib_base_sqrt( c2 ); + temp = stdlib_complex128( a_re / stdlib_base_sqrt( za2 ), a_im / stdlib_base_sqrt( za2 ) ); + temp = stdlib_complex128( stdlib_complex128_real( temp ) * scale, stdlib_complex128_imag( temp ) * scale ); + conj_b = stdlib_complex128_conj( b ); + s = stdlib_base_complex128_mul( conj_b, temp ); } else { // za2 / c2 <= EPS, so za2 is very small compared to zb2 d = stdlib_base_sqrt( za2 * c2 ); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js index e2a1df3480ff..64c6327fd06e 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.js @@ -32,18 +32,18 @@ var zrotg = require( './../lib/main.js' ); // TESTS // -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof zrotg, 'function', 'main export is a function'); t.end(); }); -tape( 'the function has an arity of 2', function test( t ) { - t.strictEqual( zrotg.length, 2, 'returns expected value' ); +tape('the function has an arity of 2', function test(t) { + t.strictEqual(zrotg.length, 2, 'returns expected value'); t.end(); }); -tape( 'the function computes a Givens plane rotation for complex numbers', function test( t ) { +tape('the function computes a Givens plane rotation for complex numbers', function test(t) { var expected; var values; var delta; @@ -56,166 +56,160 @@ tape( 'the function computes a Givens plane rotation for complex numbers', funct var e; expected = [ - [ 5.0, 6.0, 1.0, 0.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], - [ 13.0, 0.0, 0.0, 1.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.0, -1.0 ], - [ 0.0, 0.0, 1.0, 0.0, 0.0 ], - [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], - [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], - [ 5.0, 0.0, 0.6, 0.8, 0.0 ], - [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + [5.0, 6.0, 1.0, 0.0, 0.0], + [13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231], + [13.0, 0.0, 0.0, 1.0, 0.0], + [13.0, 0.0, 0.0, 0.0, -1.0], + [0.0, 0.0, 1.0, 0.0, 0.0], + [8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761], + [-8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761], + [5.0, 0.0, 0.6, 0.8, 0.0], + [0.0, 5.0, 0.6, 0.8, 0.0] ]; values = [ - [ 5.0, 6.0, 0.0, 0.0 ], - [ 0.0, 0.0, 5.0, 12.0 ], - [ 0.0, 0.0, 13.0, 0.0 ], - [ 0.0, 0.0, 0.0, 13.0 ], - [ 0.0, 0.0, 0.0, 0.0 ], - [ 3.0, 4.0, 5.0, 12.0 ], - [ -3.0, -4.0, 5.0, 12.0 ], - [ 3.0, 0.0, 4.0, 0.0 ], - [ 0.0, 3.0, 0.0, 4.0 ] + [5.0, 6.0, 0.0, 0.0], + [0.0, 0.0, 5.0, 12.0], + [0.0, 0.0, 13.0, 0.0], + [0.0, 0.0, 0.0, 13.0], + [0.0, 0.0, 0.0, 0.0], + [3.0, 4.0, 5.0, 12.0], + [-3.0, -4.0, 5.0, 12.0], + [3.0, 0.0, 4.0, 0.0], + [0.0, 3.0, 0.0, 4.0] ]; - for ( i = 0; i < values.length; i++ ) { - za = new Complex128( values[i][0], values[i][1] ); - zb = new Complex128( values[i][2], values[i][3] ); - e = new Float64Array( expected[i] ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); - for ( j = 0; j < out.length; j++ ) { - if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { - t.strictEqual( out[j], e[j], 'returns expected value' ); + for (i = 0; i < values.length; i++) { + za = new Complex128(values[i][0], values[i][1]); + zb = new Complex128(values[i][2], values[i][3]); + e = new Float64Array(expected[i]); + out = zrotg(za, zb, new Float64Array(5), 1, 0); + for (j = 0; j < out.length; j++) { + if (out[j] === e[j] || (abs(e[j]) < EPS && abs(out[j]) < EPS)) { + t.strictEqual(out[j], e[j], 'returns expected value'); } else { - delta = abs( out[j] - e[j] ); - tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); - t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + delta = abs(out[j] - e[j]); + tol = 10.0 * EPS * max(1.0, abs(e[j])); + t.ok(delta <= tol, 'within tolerance. out: ' + out[j] + '. expected: ' + e[j] + '. delta: ' + delta + '. tol: ' + tol + '.'); } } } t.end(); }); -tape( 'the function handles edge case where za is much larger than zb', function test( t ) { +tape('the function handles edge case where za is much larger than zb', function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e10, 1.0e10 ); - zb = new Complex128( 1.0, 1.0 ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + za = new Complex128(1.0e10, 1.0e10); + zb = new Complex128(1.0, 1.0); + out = zrotg(za, zb, new Float64Array(5), 1, 0); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 1 when za >> zb - t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + t.ok(abs(out[2] - 1.0) < 1.0e-6, 'c is close to 1 when za >> zb'); t.end(); }); -tape( 'the function handles edge case where zb is much larger than za', function test( t ) { +tape('the function handles edge case where zb is much larger than za', function test(t) { var out; var za; var zb; - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( 1.0e10, 1.0e10 ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(1.0e10, 1.0e10); + out = zrotg(za, zb, new Float64Array(5), 1, 0); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 0 when zb >> za - t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + t.ok(abs(out[2]) < 1.0e-6, 'c is close to 0 when zb >> za'); t.end(); }); -tape( 'the function handles very small complex numbers', function test( t ) { +tape('the function handles very small complex numbers', function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e-100, 1.0e-100 ); - zb = new Complex128( 2.0e-100, 2.0e-100 ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + za = new Complex128(1.0e-100, 1.0e-100); + zb = new Complex128(2.0e-100, 2.0e-100); + out = zrotg(za, zb, new Float64Array(5), 1, 0); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); t.end(); }); -tape( 'the function returns an array of NaNs if provided a rotation elimination parameter equal to NaN', function test( t ) { +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 = zrotg( NaN, 1.0, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when za is NaN' ); + actual = zrotg(NaN, 1.0, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN for element ' + i + ' when za is NaN'); } - actual = zrotg( 1.0, NaN, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when zb is NaN' ); + actual = zrotg(1.0, NaN, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN for element ' + i + ' when zb is NaN'); } - actual = zrotg( NaN, NaN, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when both are NaN' ); + actual = zrotg(NaN, NaN, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN for element ' + i + ' when both are NaN'); } t.end(); }); -tape( 'the function handles Complex128 objects with NaN components', function test( t ) { +tape('the function handles Complex128 objects with NaN components', function test(t) { var actual; var za; var zb; var i; - // za has NaN real part - za = new Complex128( NaN, 1.0 ); - zb = new Complex128( 1.0, 1.0 ); - actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.real is NaN' ); + za = new Complex128(NaN, 1.0); + zb = new Complex128(1.0, 1.0); + actual = zrotg(za, zb, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when za.real is NaN'); } - // za has NaN imaginary part - za = new Complex128( 1.0, NaN ); - zb = new Complex128( 1.0, 1.0 ); - actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.imag is NaN' ); + za = new Complex128(1.0, NaN); + zb = new Complex128(1.0, 1.0); + actual = zrotg(za, zb, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when za.imag is NaN'); } - // zb has NaN real part - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( NaN, 1.0 ); - actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.real is NaN' ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(NaN, 1.0); + actual = zrotg(za, zb, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when zb.real is NaN'); } - // zb has NaN imaginary part - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( 1.0, NaN ); - actual = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.imag is NaN' ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(1.0, NaN); + actual = zrotg(za, zb, new Float64Array(5), 1, 0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when zb.imag is NaN'); } t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js index 9f43efd32663..b3976bee1fa2 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.assign.native.js @@ -33,26 +33,26 @@ var tryRequire = require( '@stdlib/utils/try-require' ); // VARIABLES // -var zrotg = tryRequire( resolve( __dirname, './../lib/assign.native.js' ) ); +var zrotg = tryRequire(resolve(__dirname, './../lib/assign.native.js')); var opts = { - 'skip': ( zrotg instanceof Error ) + 'skip': (zrotg instanceof Error) }; // TESTS // -tape( 'main export is a function', opts, function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); +tape('main export is a function', opts, function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof zrotg, 'function', 'main export is a function'); t.end(); }); -tape( 'the function has an arity of 5', opts, function test( t ) { - t.strictEqual( zrotg.length, 5, 'returns expected value' ); +tape('the function has an arity of 5', opts, function test(t) { + t.strictEqual(zrotg.length, 5, 'returns expected value'); t.end(); }); -tape( 'the function computes a Givens plane rotation for complex numbers', opts, function test( t ) { +tape('the function computes a Givens plane rotation for complex numbers', opts, function test(t) { var expected; var values; var delta; @@ -65,105 +65,103 @@ tape( 'the function computes a Givens plane rotation for complex numbers', opts, var e; expected = [ - [ 5.0, 6.0, 1.0, 0.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], - [ 13.0, 0.0, 0.0, 1.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.0, -1.0 ], - [ 0.0, 0.0, 1.0, 0.0, 0.0 ], - [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], - [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], - [ 5.0, 0.0, 0.6, 0.8, 0.0 ], - [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + [5.0, 6.0, 1.0, 0.0, 0.0], + [13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231], + [13.0, 0.0, 0.0, 1.0, 0.0], + [13.0, 0.0, 0.0, 0.0, -1.0], + [0.0, 0.0, 1.0, 0.0, 0.0], + [8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761], + [-8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761], + [5.0, 0.0, 0.6, 0.8, 0.0], + [0.0, 5.0, 0.6, 0.8, 0.0] ]; values = [ - [ 5.0, 6.0, 0.0, 0.0 ], - [ 0.0, 0.0, 5.0, 12.0 ], - [ 0.0, 0.0, 13.0, 0.0 ], - [ 0.0, 0.0, 0.0, 13.0 ], - [ 0.0, 0.0, 0.0, 0.0 ], - [ 3.0, 4.0, 5.0, 12.0 ], - [ -3.0, -4.0, 5.0, 12.0 ], - [ 3.0, 0.0, 4.0, 0.0 ], - [ 0.0, 3.0, 0.0, 4.0 ] + [5.0, 6.0, 0.0, 0.0], + [0.0, 0.0, 5.0, 12.0], + [0.0, 0.0, 13.0, 0.0], + [0.0, 0.0, 0.0, 13.0], + [0.0, 0.0, 0.0, 0.0], + [3.0, 4.0, 5.0, 12.0], + [-3.0, -4.0, 5.0, 12.0], + [3.0, 0.0, 4.0, 0.0], + [0.0, 3.0, 0.0, 4.0] ]; - for ( i = 0; i < values.length; i++ ) { - za = new Complex128( values[i][0], values[i][1] ); - zb = new Complex128( values[i][2], values[i][3] ); - e = new Float64Array( expected[i] ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); - for ( j = 0; j < out.length; j++ ) { - if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { - t.strictEqual( out[j], e[j], 'returns expected value' ); + for (i = 0; i < values.length; i++) { + za = new Complex128(values[i][0], values[i][1]); + zb = new Complex128(values[i][2], values[i][3]); + e = new Float64Array(expected[i]); + out = zrotg(za, zb, new Float64Array(5), 1, 0); + for (j = 0; j < out.length; j++) { + if (out[j] === e[j] || (abs(e[j]) < EPS && abs(out[j]) < EPS)) { + t.strictEqual(out[j], e[j], 'returns expected value'); } else { - delta = abs( out[j] - e[j] ); - tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); - t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + delta = abs(out[j] - e[j]); + tol = 10.0 * EPS * max(1.0, abs(e[j])); + t.ok(delta <= tol, 'within tolerance. out: ' + out[j] + '. expected: ' + e[j] + '. delta: ' + delta + '. tol: ' + tol + '.'); } } } t.end(); }); -tape( 'the function handles edge case where za is much larger than zb', opts, function test( t ) { +tape('the function handles edge case where za is much larger than zb', opts, function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e10, 1.0e10 ); - zb = new Complex128( 1.0, 1.0 ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + za = new Complex128(1.0e10, 1.0e10); + zb = new Complex128(1.0, 1.0); + out = zrotg(za, zb, new Float64Array(5), 1, 0); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 1 when za >> zb - t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + t.ok(abs(out[2] - 1.0) < 1.0e-6, 'c is close to 1 when za >> zb'); t.end(); }); -tape( 'the function handles edge case where zb is much larger than za', opts, function test( t ) { +tape('the function handles edge case where zb is much larger than za', opts, function test(t) { var out; var za; var zb; - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( 1.0e10, 1.0e10 ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(1.0e10, 1.0e10); + out = zrotg(za, zb, new Float64Array(5), 1, 0); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 0 when zb >> za - t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + t.ok(abs(out[2]) < 1.0e-6, 'c is close to 0 when zb >> za'); t.end(); }); -tape( 'the function handles very small complex numbers', opts, function test( t ) { +tape('the function handles very small complex numbers', opts, function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e-100, 1.0e-100 ); - zb = new Complex128( 2.0e-100, 2.0e-100 ); - out = zrotg( za, zb, new Float64Array( 5 ), 1, 0 ); + za = new Complex128(1.0e-100, 1.0e-100); + zb = new Complex128(2.0e-100, 2.0e-100); + out = zrotg(za, zb, new Float64Array(5), 1, 0); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js index b4637514638c..318a50759da5 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -35,23 +35,23 @@ var opts = { // TESTS // -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof zrotg, 'function', 'main export is a function'); t.end(); }); -tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { - t.strictEqual( typeof zrotg.assign, 'function', 'method is a function' ); +tape('attached to the main export is a method providing an ndarray interface', function test(t) { + t.strictEqual(typeof zrotg.assign, 'function', 'method is a function'); t.end(); }); -tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { - var zrotg = proxyquire( './../lib', { +tape('if a native implementation is available, the main export is the native implementation', opts, function test(t) { + var zrotg = proxyquire('./../lib', { '@stdlib/utils/try-require': tryRequire }); - t.strictEqual( zrotg, mock, 'returns native implementation' ); + t.strictEqual(zrotg, mock, 'returns native implementation'); t.end(); function tryRequire() { @@ -63,20 +63,20 @@ tape( 'if a native implementation is available, the main export is the native im } }); -tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { +tape('if a native implementation is not available, the main export is a JavaScript implementation', opts, function test(t) { var zrotg; var main; main = require( './../lib/zrotg.js' ); - zrotg = proxyquire( './../lib', { + zrotg = proxyquire('./../lib', { '@stdlib/utils/try-require': tryRequire }); - t.strictEqual( zrotg, main, 'returns JavaScript implementation' ); + t.strictEqual(zrotg, main, 'returns JavaScript implementation'); t.end(); function tryRequire() { - return new Error( 'Cannot find module' ); + return new Error('Cannot find module'); } }); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js index 945750e4932c..bd35e9307e43 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -32,18 +32,18 @@ var zrotg = require( './../lib/main.js' ); // TESTS // -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof zrotg, 'function', 'main export is a function'); t.end(); }); -tape( 'the function has an arity of 2', function test( t ) { - t.strictEqual( zrotg.length, 2, 'returns expected value' ); +tape('the function has an arity of 2', function test(t) { + t.strictEqual(zrotg.length, 2, 'returns expected value'); t.end(); }); -tape( 'the function computes a Givens plane rotation for complex numbers', function test( t ) { +tape('the function computes a Givens plane rotation for complex numbers', function test(t) { var expected; var values; var delta; @@ -56,166 +56,160 @@ tape( 'the function computes a Givens plane rotation for complex numbers', funct var e; expected = [ - [ 5.0, 6.0, 1.0, 0.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], - [ 13.0, 0.0, 0.0, 1.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.0, -1.0 ], - [ 0.0, 0.0, 1.0, 0.0, 0.0 ], - [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], - [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], - [ 5.0, 0.0, 0.6, 0.8, 0.0 ], - [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + [5.0, 6.0, 1.0, 0.0, 0.0], + [13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231], + [13.0, 0.0, 0.0, 1.0, 0.0], + [13.0, 0.0, 0.0, 0.0, -1.0], + [0.0, 0.0, 1.0, 0.0, 0.0], + [8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761], + [-8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761], + [5.0, 0.0, 0.6, 0.8, 0.0], + [0.0, 5.0, 0.6, 0.8, 0.0] ]; values = [ - [ 5.0, 6.0, 0.0, 0.0 ], - [ 0.0, 0.0, 5.0, 12.0 ], - [ 0.0, 0.0, 13.0, 0.0 ], - [ 0.0, 0.0, 0.0, 13.0 ], - [ 0.0, 0.0, 0.0, 0.0 ], - [ 3.0, 4.0, 5.0, 12.0 ], - [ -3.0, -4.0, 5.0, 12.0 ], - [ 3.0, 0.0, 4.0, 0.0 ], - [ 0.0, 3.0, 0.0, 4.0 ] + [5.0, 6.0, 0.0, 0.0], + [0.0, 0.0, 5.0, 12.0], + [0.0, 0.0, 13.0, 0.0], + [0.0, 0.0, 0.0, 13.0], + [0.0, 0.0, 0.0, 0.0], + [3.0, 4.0, 5.0, 12.0], + [-3.0, -4.0, 5.0, 12.0], + [3.0, 0.0, 4.0, 0.0], + [0.0, 3.0, 0.0, 4.0] ]; - for ( i = 0; i < values.length; i++ ) { - za = new Complex128( values[i][0], values[i][1] ); - zb = new Complex128( values[i][2], values[i][3] ); - e = new Float64Array( expected[i] ); - out = zrotg( za, zb ); - for ( j = 0; j < out.length; j++ ) { - if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { - t.strictEqual( out[j], e[j], 'returns expected value' ); + for (i = 0; i < values.length; i++) { + za = new Complex128(values[i][0], values[i][1]); + zb = new Complex128(values[i][2], values[i][3]); + e = new Float64Array(expected[i]); + out = zrotg(za, zb); + for (j = 0; j < out.length; j++) { + if (out[j] === e[j] || (abs(e[j]) < EPS && abs(out[j]) < EPS)) { + t.strictEqual(out[j], e[j], 'returns expected value'); } else { - delta = abs( out[j] - e[j] ); - tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); - t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + delta = abs(out[j] - e[j]); + tol = 10.0 * EPS * max(1.0, abs(e[j])); + t.ok(delta <= tol, 'within tolerance. out: ' + out[j] + '. expected: ' + e[j] + '. delta: ' + delta + '. tol: ' + tol + '.'); } } } t.end(); }); -tape( 'the function handles edge case where za is much larger than zb', function test( t ) { +tape('the function handles edge case where za is much larger than zb', function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e10, 1.0e10 ); - zb = new Complex128( 1.0, 1.0 ); - out = zrotg( za, zb ); + za = new Complex128(1.0e10, 1.0e10); + zb = new Complex128(1.0, 1.0); + out = zrotg(za, zb); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 1 when za >> zb - t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + t.ok(abs(out[2] - 1.0) < 1.0e-6, 'c is close to 1 when za >> zb'); t.end(); }); -tape( 'the function handles edge case where zb is much larger than za', function test( t ) { +tape('the function handles edge case where zb is much larger than za', function test(t) { var out; var za; var zb; - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( 1.0e10, 1.0e10 ); - out = zrotg( za, zb ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(1.0e10, 1.0e10); + out = zrotg(za, zb); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 0 when zb >> za - t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + t.ok(abs(out[2]) < 1.0e-6, 'c is close to 0 when zb >> za'); t.end(); }); -tape( 'the function handles very small complex numbers', function test( t ) { +tape('the function handles very small complex numbers', function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e-100, 1.0e-100 ); - zb = new Complex128( 2.0e-100, 2.0e-100 ); - out = zrotg( za, zb ); + za = new Complex128(1.0e-100, 1.0e-100); + zb = new Complex128(2.0e-100, 2.0e-100); + out = zrotg(za, zb); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); t.end(); }); -tape( 'the function returns an array of NaNs if provided a rotation elimination parameter equal to NaN', function test( t ) { +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 = zrotg( NaN, 1.0 ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when za is NaN' ); + actual = zrotg(NaN, 1.0); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN for element ' + i + ' when za is NaN'); } - actual = zrotg( 1.0, NaN ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when zb is NaN' ); + actual = zrotg(1.0, NaN); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN for element ' + i + ' when zb is NaN'); } - actual = zrotg( NaN, NaN ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN for element ' + i + ' when both are NaN' ); + actual = zrotg(NaN, NaN); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN for element ' + i + ' when both are NaN'); } t.end(); }); -tape( 'the function handles Complex128 objects with NaN components', function test( t ) { +tape('the function handles Complex128 objects with NaN components', function test(t) { var actual; var za; var zb; var i; - // za has NaN real part - za = new Complex128( NaN, 1.0 ); - zb = new Complex128( 1.0, 1.0 ); - actual = zrotg( za, zb ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.real is NaN' ); + za = new Complex128(NaN, 1.0); + zb = new Complex128(1.0, 1.0); + actual = zrotg(za, zb); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when za.real is NaN'); } - // za has NaN imaginary part - za = new Complex128( 1.0, NaN ); - zb = new Complex128( 1.0, 1.0 ); - actual = zrotg( za, zb ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when za.imag is NaN' ); + za = new Complex128(1.0, NaN); + zb = new Complex128(1.0, 1.0); + actual = zrotg(za, zb); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when za.imag is NaN'); } - // zb has NaN real part - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( NaN, 1.0 ); - actual = zrotg( za, zb ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.real is NaN' ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(NaN, 1.0); + actual = zrotg(za, zb); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when zb.real is NaN'); } - // zb has NaN imaginary part - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( 1.0, NaN ); - actual = zrotg( za, zb ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isnan( actual[i] ), true, 'returns NaN when zb.imag is NaN' ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(1.0, NaN); + actual = zrotg(za, zb); + for (i = 0; i < actual.length; i++) { + t.strictEqual(isnan(actual[i]), true, 'returns NaN when zb.imag is NaN'); } t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js index 2def716c9477..eeb656a30527 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.zrotg.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. @@ -33,26 +33,26 @@ var tryRequire = require( '@stdlib/utils/try-require' ); // VARIABLES // -var zrotg = tryRequire( resolve( __dirname, './../lib/zrotg.native.js' ) ); +var zrotg = tryRequire(resolve(__dirname, './../lib/zrotg.native.js')); var opts = { - 'skip': ( zrotg instanceof Error ) + 'skip': (zrotg instanceof Error) }; // TESTS // -tape( 'main export is a function', opts, function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zrotg, 'function', 'main export is a function' ); +tape('main export is a function', opts, function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof zrotg, 'function', 'main export is a function'); t.end(); }); -tape( 'the function has an arity of 2', opts, function test( t ) { - t.strictEqual( zrotg.length, 2, 'returns expected value' ); +tape('the function has an arity of 2', opts, function test(t) { + t.strictEqual(zrotg.length, 2, 'returns expected value'); t.end(); }); -tape( 'the function computes a Givens plane rotation for complex numbers', opts, function test( t ) { +tape('the function computes a Givens plane rotation for complex numbers', opts, function test(t) { var expected; var values; var delta; @@ -65,105 +65,103 @@ tape( 'the function computes a Givens plane rotation for complex numbers', opts, var e; expected = [ - [ 5.0, 6.0, 1.0, 0.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231 ], - [ 13.0, 0.0, 0.0, 1.0, 0.0 ], - [ 13.0, 0.0, 0.0, 0.0, -1.0 ], - [ 0.0, 0.0, 1.0, 0.0, 0.0 ], - [ 8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761 ], - [ -8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761 ], - [ 5.0, 0.0, 0.6, 0.8, 0.0 ], - [ 0.0, 5.0, 0.6, 0.8, 0.0 ] + [5.0, 6.0, 1.0, 0.0, 0.0], + [13.0, 0.0, 0.0, 0.38461538461538464, -0.9230769230769231], + [13.0, 0.0, 0.0, 1.0, 0.0], + [13.0, 0.0, 0.0, 0.0, -1.0], + [0.0, 0.0, 1.0, 0.0, 0.0], + [8.357032966310472, 11.142710621747296, 0.358979079308869, 0.9046272798583498, -0.2297466107576761], + [-8.357032966310472, -11.142710621747296, 0.358979079308869, -0.9046272798583498, 0.2297466107576761], + [5.0, 0.0, 0.6, 0.8, 0.0], + [0.0, 5.0, 0.6, 0.8, 0.0] ]; values = [ - [ 5.0, 6.0, 0.0, 0.0 ], - [ 0.0, 0.0, 5.0, 12.0 ], - [ 0.0, 0.0, 13.0, 0.0 ], - [ 0.0, 0.0, 0.0, 13.0 ], - [ 0.0, 0.0, 0.0, 0.0 ], - [ 3.0, 4.0, 5.0, 12.0 ], - [ -3.0, -4.0, 5.0, 12.0 ], - [ 3.0, 0.0, 4.0, 0.0 ], - [ 0.0, 3.0, 0.0, 4.0 ] + [5.0, 6.0, 0.0, 0.0], + [0.0, 0.0, 5.0, 12.0], + [0.0, 0.0, 13.0, 0.0], + [0.0, 0.0, 0.0, 13.0], + [0.0, 0.0, 0.0, 0.0], + [3.0, 4.0, 5.0, 12.0], + [-3.0, -4.0, 5.0, 12.0], + [3.0, 0.0, 4.0, 0.0], + [0.0, 3.0, 0.0, 4.0] ]; - for ( i = 0; i < values.length; i++ ) { - za = new Complex128( values[i][0], values[i][1] ); - zb = new Complex128( values[i][2], values[i][3] ); - e = new Float64Array( expected[i] ); - out = zrotg( za, zb ); - for ( j = 0; j < out.length; j++ ) { - if ( out[j] === e[j] || ( abs( e[j] ) < EPS && abs( out[j] ) < EPS ) ) { - t.strictEqual( out[j], e[j], 'returns expected value' ); + for (i = 0; i < values.length; i++) { + za = new Complex128(values[i][0], values[i][1]); + zb = new Complex128(values[i][2], values[i][3]); + e = new Float64Array(expected[i]); + out = zrotg(za, zb); + for (j = 0; j < out.length; j++) { + if (out[j] === e[j] || (abs(e[j]) < EPS && abs(out[j]) < EPS)) { + t.strictEqual(out[j], e[j], 'returns expected value'); } else { - delta = abs( out[j] - e[j] ); - tol = 10.0 * EPS * max( 1.0, abs( e[j] ) ); - t.ok( delta <= tol, 'within tolerance. out: '+out[j]+'. expected: '+e[j]+'. delta: '+delta+'. tol: '+tol+'.' ); + delta = abs(out[j] - e[j]); + tol = 10.0 * EPS * max(1.0, abs(e[j])); + t.ok(delta <= tol, 'within tolerance. out: ' + out[j] + '. expected: ' + e[j] + '. delta: ' + delta + '. tol: ' + tol + '.'); } } } t.end(); }); -tape( 'the function handles edge case where za is much larger than zb', opts, function test( t ) { +tape('the function handles edge case where za is much larger than zb', opts, function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e10, 1.0e10 ); - zb = new Complex128( 1.0, 1.0 ); - out = zrotg( za, zb ); + za = new Complex128(1.0e10, 1.0e10); + zb = new Complex128(1.0, 1.0); + out = zrotg(za, zb); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 1 when za >> zb - t.ok( abs( out[2] - 1.0 ) < 1.0e-6, 'c is close to 1 when za >> zb' ); + t.ok(abs(out[2] - 1.0) < 1.0e-6, 'c is close to 1 when za >> zb'); t.end(); }); -tape( 'the function handles edge case where zb is much larger than za', opts, function test( t ) { +tape('the function handles edge case where zb is much larger than za', opts, function test(t) { var out; var za; var zb; - za = new Complex128( 1.0, 1.0 ); - zb = new Complex128( 1.0e10, 1.0e10 ); - out = zrotg( za, zb ); + za = new Complex128(1.0, 1.0); + zb = new Complex128(1.0e10, 1.0e10); + out = zrotg(za, zb); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); - // c should be close to 0 when zb >> za - t.ok( abs( out[2] ) < 1.0e-6, 'c is close to 0 when zb >> za' ); + t.ok(abs(out[2]) < 1.0e-6, 'c is close to 0 when zb >> za'); t.end(); }); -tape( 'the function handles very small complex numbers', opts, function test( t ) { +tape('the function handles very small complex numbers', opts, function test(t) { var out; var za; var zb; - za = new Complex128( 1.0e-100, 1.0e-100 ); - zb = new Complex128( 2.0e-100, 2.0e-100 ); - out = zrotg( za, zb ); + za = new Complex128(1.0e-100, 1.0e-100); + zb = new Complex128(2.0e-100, 2.0e-100); + out = zrotg(za, zb); - t.strictEqual( out.length, 5, 'returns array of length 5' ); - t.strictEqual( isnan( out[0] ), false, 'r real part is not NaN' ); - t.strictEqual( isnan( out[1] ), false, 'r imag part is not NaN' ); - t.strictEqual( isnan( out[2] ), false, 'c is not NaN' ); - t.strictEqual( isnan( out[3] ), false, 's real part is not NaN' ); - t.strictEqual( isnan( out[4] ), false, 's imag part is not NaN' ); + t.strictEqual(out.length, 5, 'returns array of length 5'); + t.strictEqual(isnan(out[0]), false, 'r real part is not NaN'); + t.strictEqual(isnan(out[1]), false, 'r imag part is not NaN'); + t.strictEqual(isnan(out[2]), false, 'c is not NaN'); + t.strictEqual(isnan(out[3]), false, 's real part is not NaN'); + t.strictEqual(isnan(out[4]), false, 's imag part is not NaN'); t.end(); }); From 5d7c219874120cd054cfc497258320bb1b4f967e Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Sat, 10 Jan 2026 18:20:23 +0530 Subject: [PATCH 3/5] fix: c benchmark file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: 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: na - task: lint_license_headers status: passed --- --- .../base/zrotg/benchmark/c/benchmark.length.c | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c index d23be252da13..f8e9df4c98c7 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c @@ -92,7 +92,7 @@ static double rand_double( void ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len array length +* @param len array length (unused for zrotg) * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { @@ -103,20 +103,16 @@ static double benchmark1( int iterations, int len ) { double t; int i; - for ( i = 0; i < len; i++ ) { - a[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); - b[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); - } t = tic(); for ( i = 0; i < iterations; i++ ) { c_zrotg( a[i], b[i], out, 1 ); - if ( out[ 0 ] != out[ 0 ] ) { + if ( isnan( out[ 0 ] ) ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( out[ 0 ] != out[ 0 ] ) { + if ( isnan( out[ 0 ] ) ) { printf( "should not return NaN\n" ); } return elapsed; @@ -126,7 +122,7 @@ static double benchmark1( int iterations, int len ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len array length +* @param len array length (unused for zrotg) * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { @@ -137,20 +133,16 @@ static double benchmark2( int iterations, int len ) { double t; int i; - for ( i = 0; i < len; i++ ) { - a[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); - b[ i ] = stdlib_complex128( ( rand_double()*2.0 ) - 1.0, ( rand_double()*2.0 ) - 1.0 ); - } t = tic(); for ( i = 0; i < iterations; i++ ) { c_zrotg_assign( a[i], b[i], out, 1, 0 ); - if ( out[ 0 ] != out[ 0 ] ) { + if ( isnan( out[ 0 ] ) ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( out[ 0 ] != out[ 0 ] ) { + if ( isnan( out[ 0 ] ) ) { printf( "should not return NaN\n" ); } return elapsed; From 409361481baf6aa3bfb62082af1207855a5fd649 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Sat, 10 Jan 2026 18:38:06 +0530 Subject: [PATCH 4/5] fix: c benchmark file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: 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: na - task: lint_license_headers status: passed --- --- .../base/zrotg/benchmark/c/benchmark.length.c | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c index f8e9df4c98c7..3ea8461e9d56 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c @@ -103,16 +103,21 @@ static double benchmark1( int iterations, int len ) { double t; int i; + for ( i = 0; i < len; i++ ) { + a[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); + b[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); + } + t = tic(); for ( i = 0; i < iterations; i++ ) { - c_zrotg( a[i], b[i], out, 1 ); - if ( isnan( out[ 0 ] ) ) { + c_zrotg( a[ i%len ], b[ i%len ], out, 1 ); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) || isnan( out[ 2 ] ) || isnan( out[ 3 ] ) || isnan( out[ 4 ] ) ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( isnan( out[ 0 ] ) ) { + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) || isnan( out[ 2 ] ) || isnan( out[ 3 ] ) || isnan( out[ 4 ] ) ) { printf( "should not return NaN\n" ); } return elapsed; @@ -133,16 +138,21 @@ static double benchmark2( int iterations, int len ) { double t; int i; + for ( i = 0; i < len; i++ ) { + a[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); + b[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); + } + t = tic(); for ( i = 0; i < iterations; i++ ) { - c_zrotg_assign( a[i], b[i], out, 1, 0 ); - if ( isnan( out[ 0 ] ) ) { + c_zrotg_assign( a[ i%len ], b[ i%len ], out, 1, 0 ); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) || isnan( out[ 2 ] ) || isnan( out[ 3 ] ) || isnan( out[ 4 ] ) ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( isnan( out[ 0 ] ) ) { + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) || isnan( out[ 2 ] ) || isnan( out[ 3 ] ) || isnan( out[ 4 ] ) ) { printf( "should not return NaN\n" ); } return elapsed; From 255d91d10ba9284f2b1b07fa7114cc0091aa0f12 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Sat, 10 Jan 2026 19:34:44 +0530 Subject: [PATCH 5/5] fix: c benchmark file and fortran makefile --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: 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: na - task: lint_license_headers status: passed --- --- .../base/zrotg/benchmark/c/benchmark.length.c | 24 ++++++++----------- .../base/zrotg/benchmark/fortran/Makefile | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c index 3ea8461e9d56..c408f8b9047c 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/c/benchmark.length.c @@ -96,21 +96,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - stdlib_complex128_t a[ len ]; - stdlib_complex128_t b[ len ]; + stdlib_complex128_t a; + stdlib_complex128_t b; double out[ 5 ]; double elapsed; double t; int i; - for ( i = 0; i < len; i++ ) { - a[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); - b[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); - } + a = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); + b = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_zrotg( a[ i%len ], b[ i%len ], out, 1 ); + c_zrotg( a, b, out, 1 ); if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) || isnan( out[ 2 ] ) || isnan( out[ 3 ] ) || isnan( out[ 4 ] ) ) { printf( "should not return NaN\n" ); break; @@ -131,21 +129,19 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - stdlib_complex128_t a[ len ]; - stdlib_complex128_t b[ len ]; + stdlib_complex128_t a; + stdlib_complex128_t b; double out[ 5 ]; double elapsed; double t; int i; - for ( i = 0; i < len; i++ ) { - a[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); - b[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); - } + a = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); + b = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_zrotg_assign( a[ i%len ], b[ i%len ], out, 1, 0 ); + c_zrotg_assign( a, b, out, 1, 0 ); if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) || isnan( out[ 2 ] ) || isnan( out[ 3 ] ) || isnan( out[ 4 ] ) ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile index 876392fd8ae1..ac3a1adcc283 100644 --- a/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile +++ b/lib/node_modules/@stdlib/blas/base/zrotg/benchmark/fortran/Makefile @@ -78,7 +78,7 @@ endif INCLUDE ?= # List of Fortran source files: -SOURCE_FILES ?= ../../src/zdrot.f +SOURCE_FILES ?= ../../src/zrotg.f # List of Fortran targets: f_targets := benchmark.length.out