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..eaceb1c7904b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/README.md @@ -0,0 +1,191 @@ + + +# zrotg + +> Constructs a Givens plane rotation. + +
+ +## Usage + +```javascript +var zrotg = require( '@stdlib/blas/base/zrotg' ); +``` + +#### zrotg( za, zb ) + +Constructs a Givens plane rotation provided two single-precision floating-point values `a` and `b`. + +```javascript +var Complex128 = require( '@stdlib/complex/float64/ctor' ); + +var za = new Complex128( 4.0, 3.0 ); +// returns + +var zb = new Complex128( 0.0, 0.0 ); +// returns + +var out = zrotg( za, zb ); +// out => [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +``` + +The function has the following parameters: + +- **za**: rotational elimination parameter. +- **za**: rotational elimination parameter. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +
+ + + +
+ +## Notes + +- `zrotg()` corresponds to the [BLAS][blas] level 1 function [`zrotg`][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 +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + 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/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..92de75d62bef --- /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( 1.0, 2.0 ); +* var zb = new Complex128( 3.0, 4.0 ); +* +* var out = zrotg( za, zb ); +* // returns [ ~1.732, ~5.1961, ~0.5773, ~0.8082, ~0.1154 ] +*/ +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/index.js b/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js new file mode 100644 index 000000000000..59cd56a58fff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zrotg = require( './../lib' ); + +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 ); +} + +console.log(zrotg(new Complex128( 1, 3 ), new Complex128( 2, 4 ))); 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..7fbd86312497 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/index.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'; + +/** +* 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( 4.0, 3.0 ); +* // returns +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb ); +* // returns [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +* +* za = new Complex128( 1.0, 3.0 ); +* // returns +* +* zb = new Complex128( 2.0, 4.0 ); +* // returns +* +* out = zrotg( za, zb ); +* // out => [ ~1.732, ~5.1961, ~0.5773, ~0.8082, ~0.1154 ] +*/ + +// MODULES // + +var zrotg = require( './main.js' ); + + +// EXPORTS // + +module.exports = zrotg; 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..4b948ca10701 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/lib/main.js @@ -0,0 +1,130 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Float64Array = require( '@stdlib/array/float64' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var cabs2 = require( '@stdlib/math/base/special/cabs2' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var cmul = require( '@stdlib/complex/float64/base/mul' ); +var conj = require( '@stdlib/complex/float64/conj' ); + + +// 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( 4.0, 3.0 ); +* // returns +* +* var zb = new Complex128( 0.0, 0.0 ); +* // returns +* +* var out = zrotg( za, zb ); +* // out => [ 4.0, 3.0, 1.0, 0.0, 0.0 ] +*/ +function zrotg( za, zb ) { + var scalar; + var scale; + var temp; + var za2; + var zb2; + var out; + var c2; + var c; + var s; + var r; + var d; + + out = new Float64Array( 5 ); + + 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 ) { + r = abs( imag( zb ) ); + s = conj( zb ) / r; + } else if ( imag( zb ) === 0 ) { + r = abs( real( zb ) ); + s = conj( zb ) / r; + } else { + zb2 = cabs2( zb ); + d = sqrt( zb2 ); + s = conj( zb ) / d; + r = d; + } + } 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(za2 * c2); + temp = new Complex128(real(za) * scale, imag(za) * 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[ 0 ] = real( za ); + out[ 1 ] = imag( za ); + out[ 2 ] = c; + out[ 3 ] = real( s ); + out[ 4 ] = imag( s ); + return out; +} + + +// EXPORTS // + +module.exports = zrotg; 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..2231535b40cc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/base/zrotg", + "version": "0.0.0", + "description": "Construct a Givens plane rotation.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "zrotg", + "givens", + "rotation", + "matrix", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "complex128", + "complex", + "complex128array" + ] +} 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..b40f777e2a7a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zrotg/test/test.js @@ -0,0 +1,84 @@ +/** +* @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 zrotg = require( './../lib' ); + + +// 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', function test( t ) { + var expected; + var za; + var zb; + var y; + + za = new Complex128( 5.0, 6.0 ); + zb = new Complex128( 0.0, 0.0 ); + + expected = new Float64Array([ + 5.0, // 0 + 6.0, // 1 + 1.0, // 2 + 0.0, // 3 + 0.0 // 4 + ]); + + y = zrotg( za, zb ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an array of NaNs if provided a rotation elimination parameter equal to NaN', function test( t ) { + var actual; + var i; + + actual = zrotg( NaN, 1.0 ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = zrotg( 1.0, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + + actual = zrotg( NaN, NaN ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( isnan( actual[i] ), true, 'returns expected value' ); + } + t.end(); +});