diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/README.md b/lib/node_modules/@stdlib/lapack/base/dlartgp/README.md new file mode 100644 index 000000000000..9d4d193fd8a4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/README.md @@ -0,0 +1,220 @@ + + +# dlartgp + +> Generates a plane rotation so that the diagonal is nonnegative. + +
+ +## Usage + +```javascript +var dlartgp = require( '@stdlib/lapack/base/dlartgp' ); +``` + +#### dlartgp( F, G, out ) + +Generates a plane rotation so that the diagonal is nonnegative. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 3 ); +dlartgp( 1.0, 2.0, out ); +// out => [ ~0.447, ~0.894, ~2.236 ] +``` + +The function has the following parameters: + +- **F**: the first component of vector to be rotated. +- **G**: the second component of vector to be rotated. +- **out**: output [`Float64Array`][mdn-float64array] output array containing the cosine and sine of the rotation and the non zero component of the rotated vector. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array: +var out0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + +// Create an offset view... +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlartgp( 1.0, 2.0, out1 ); +// out0 => [ 0.0, ~0.447, ~0.894, ~2.236 ] +``` + +#### dlartgp.ndarray( F, G, out, strideOut, offsetOut ) + +Generates a plane rotation so that the diagonal is nonnegative using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 3 ); +dlartgp.ndarray( 1.0, 2.0, out, 1, 0 ); +// out => [ ~0.447, ~0.894, ~2.236 ] +``` + +The function has the following additional parameters: + +- **strideOut**: stride length for `out`. +- **offsetOut**: starting index of `out` + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +dlartgp.ndarray( 1.0, 2.0, out, -1, 3 ); +// out => [ 0.0, ~2.236, ~0.894, ~0.447 ] +``` + +
+ + + +
+ +## Notes + +- `dlartgp()` corresponds to the [LAPACK][lapack] routine [`dlartgp`][lapack-dlartgp]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlartgp = require( '@stdlib/lapack/base/dlartgp' ); + +var out = new Float64Array( 3 ); +dlartgp( 1.0, 2.0, out ); +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/lapack/base/dlartgp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/benchmark/benchmark.js new file mode 100644 index 000000000000..85297ac850eb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/benchmark/benchmark.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 bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlartgp = require( './../lib/dlartgp.js' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var A; + var B; + var i; + + b.tic(); + A = ( randu() * 100.0 ) - 50.0; + B = ( randu() * 100.0 ) - 50.0; + out = new Float64Array( 3 ); + for ( i = 0; i < b.iterations; i++ ) { + out = dlartgp( A, B, out ); + A = out[ i%out.length ]; + B = out[ i%out.length ]; + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..6a3e334d5f8e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/benchmark/benchmark.ndarray.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 bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlartgp = require( './../lib/ndarray.js' ); + + +// MAIN // + +bench( pkg+':ndarray', function benchmark( b ) { + var out; + var A; + var B; + var i; + + A = ( randu() * 100.0 ) - 50.0; + B = ( randu() * 100.0 ) - 50.0; + out = new Float64Array( 3 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dlartgp( A, B, out, 1, 0 ); + A = out[ i%out.length ]; + B = out[ i%out.length ]; + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/repl.txt new file mode 100644 index 000000000000..464877f69ecc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/repl.txt @@ -0,0 +1,69 @@ + +{{alias}}( F, G, out ) + Generates a plane rotation so that the diagonal is nonnegative. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + F: number + The first component of vector to be rotated. + + G: number + The second component of vector to be rotated. + + out: Float64Array + Output array containing the cosine and sine of the rotation and the + non zero component of the rotated vector, respectively. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}( 1.0, 2.0, out ) + [ ~0.447, ~0.894, ~2.236 ] + + +{{alias}}.ndarray( F, G, out, strideOut, offsetOut ) + Generates a plane rotation so that the diagonal is nonnegative. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + F: number + The first component of vector to be rotated. + + G: number + The second component of vector to be rotated. + + out: Float64Array + Output array containing the cosine and sine of the rotation and the + non zero component of the rotated vector, respectively. + + strideOut: integer + Stride length for `out`. + + offsetOut: integer + Starting index of `out`. + + Returns + ------- + out: Float64Array + Output matrix. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 1.0, 2.0, out, 1, 1 ) + [ 0.0, ~0.447, ~0.894, ~2.236 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/types/index.d.ts new file mode 100644 index 000000000000..8a6c1e60b9bb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* Interface describing `dlartgp`. +*/ +interface Routine { + /** + * Generates a plane rotation so that the diagonal is nonnegative. + * + * @param F - the first component of vector to be rotated + * @param G - the second component of vector to be rotated + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 3 ); + * dlartgp( 1.0, 2.0, out ); + * // out => [ ~0.447, ~0.894, ~2.236 ] + */ + ( F: number, G: number, out: Float64Array ): Float64Array; + + /** + * Generates a plane rotation so that the diagonal is nonnegative using alternative indexing semantics. + * + * @param F - the first component of vector to be rotated + * @param G - the second component of vector to be rotated + * @param out - output array containing the cosine and sine of the rotation and the non zero component of the rotated vector + * @param strideOut - stride length for `out` + * @param offsetOut - starting index of `out` + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 3 ); + * dlartgp.ndarray( 1.0, 2.0, out, 1, 0 ); + * // out => [ ~0.447, ~0.894, ~2.236 ] + */ + ndarray( F: number, G: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; +} + +/** +* Generates a plane rotation so that the diagonal is nonnegative. +* +* @param F - the first component of vector to be rotated +* @param G - the second component of vector to be rotated +* @param out - output array containing the cosine and sine of the rotation and the non zero component of the rotated vector +* @returns output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 3 ); +* dlartgp( 1.0, 2.0, out ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 3 ); +* dlartgp.ndarray( 1.0, 2.0, out, 1, 0 ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +*/ +declare var dlartgp: Routine; + + +// EXPORTS // + +export = dlartgp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/types/test.ts new file mode 100644 index 000000000000..f625cbfbf2ee --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/docs/types/test.ts @@ -0,0 +1,170 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dlartgp = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp( 2.0, 3.0, out ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp( '5', 3.0, out ); // $ExpectError + dlartgp( true, 3.0, out ); // $ExpectError + dlartgp( false, 3.0, out ); // $ExpectError + dlartgp( null, 3.0, out ); // $ExpectError + dlartgp( void 0, 3.0, out ); // $ExpectError + dlartgp( [], 3.0, out ); // $ExpectError + dlartgp( {}, 3.0, out ); // $ExpectError + dlartgp( ( x: number ): number => x, 3.0, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp( 2.0, '5', out ); // $ExpectError + dlartgp( 2.0, true, out ); // $ExpectError + dlartgp( 2.0, false, out ); // $ExpectError + dlartgp( 2.0, null, out ); // $ExpectError + dlartgp( 2.0, void 0, out ); // $ExpectError + dlartgp( 2.0, [], out ); // $ExpectError + dlartgp( 2.0, {}, out ); // $ExpectError + dlartgp( 2.0, ( x: number ): number => x, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + + dlartgp( 2.0, 3.0, '5' ); // $ExpectError + dlartgp( 2.0, 3.0, 5 ); // $ExpectError + dlartgp( 2.0, 3.0, true ); // $ExpectError + dlartgp( 2.0, 3.0, false ); // $ExpectError + dlartgp( 2.0, 3.0, null ); // $ExpectError + dlartgp( 2.0, 3.0, void 0 ); // $ExpectError + dlartgp( 2.0, 3.0, [] ); // $ExpectError + dlartgp( 2.0, 3.0, {} ); // $ExpectError + dlartgp( 2.0, 3.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp(); // $ExpectError + dlartgp( 2.0 ); // $ExpectError + dlartgp( 2.0, 3.0 ); // $ExpectError + dlartgp( 2.0, 3.0, out, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp.ndarray( 2.0, 3.0, out, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp.ndarray( '5', 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( true, 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( false, 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( null, 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( void 0, 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( [], 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( {}, 3.0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( ( x: number ): number => x, 3.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp.ndarray( 2.0, '5', out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, true, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, false, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, null, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, void 0, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, [], out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, {}, out, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + + dlartgp.ndarray( 2.0, 3.0, '5', 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, 5, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, true, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, false, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, null, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, void 0, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, [], 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, {}, 1, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp.ndarray( 2.0, 3.0, out, '5', 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, true, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, false, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, null, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, void 0, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, [], 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, {}, 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp.ndarray( 2.0, 3.0, out, 1, '5' ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, true ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, false ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, null ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, void 0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, [] ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, {} ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dlartgp.ndarray(); // $ExpectError + dlartgp.ndarray( 2.0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1 ); // $ExpectError + dlartgp.ndarray( 2.0, 3.0, out, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/examples/index.js new file mode 100644 index 000000000000..6c5c5dd721e5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/examples/index.js @@ -0,0 +1,26 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dlartgp = require( './../lib' ); + +var out = new Float64Array( 3 ); +dlartgp( 1.0, 2.0, out ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/base.js new file mode 100644 index 000000000000..42662ffeedc6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/base.js @@ -0,0 +1,137 @@ +/** +* @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 sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +var trunc = require( '@stdlib/math/base/special/trunc' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ln = require( '@stdlib/math/base/special/ln' ); + + +// MAIN // + +/** +* Generates a plane rotation so that the diagonal is nonnegative. +* @private +* @param {number} F - the first component of vector to be rotated. +* @param {number} G - the second component of vector to be rotated. +* @param {Float64Array} out - output array containing the cosine and sine of the rotation and the non zero component of the rotated vector. +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 3 ); +* dlartgp( 1.0, 2.0, out, 1, 0 ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +*/ +function dlartgp( F, G, out, strideOut, offsetOut ) { + var safmin; + var safmn2; + var safmx2; + var count; + var scale; + var base; + var eps; + var cs; + var f1; + var g1; + var sn; + var f; + var g; + var r; + + f=F; + g=G; + safmin = dlamch( 'S' ); + eps = dlamch( 'E' ); + base = dlamch( 'B' ); + safmn2 = pow( base, trunc( ln( safmin / eps ) / ln( base ) / 2.0 )); + safmx2 = 1.0 / safmn2; + + if ( g === 0.0 ) { + cs = ( f >= 0.0 ) ? 1.0 : -1.0; + sn = 0.0; + r = abs( f ); + } else if ( f === 0.0 ) { + cs = 0.0; + sn = ( g >= 0.0 ) ? 1.0 : -1.0; + r = abs( g ); + } else { + f1 = f; + g1 = g; + scale = max( abs( f1 ), abs( g1 ) ); + if ( scale >= safmx2 ) { + count = 0; + while ( scale >= safmx2 && count < 20 ) { + count += 1; + f1 *= safmn2; + g1 *= safmn2; + scale = max( abs( f1 ), abs( g1 ) ); + } + r = sqrt( ( f1*f1 ) + ( g1*g1 ) ); + cs = f1 / r; + sn = g1 / r; + while ( count > 0 ) { + r *= safmx2; + count -= 1; + } + } else if ( scale <= safmn2 ) { + count = 0; + while ( scale <= safmn2 ) { + count += 1; + f1 *= safmx2; + g1 *= safmx2; + scale = max( abs( f1 ), abs( g1 ) ); + } + r = sqrt( ( f1*f1 ) + ( g1*g1 ) ); + cs = f1 / r; + sn = g1 / r; + while ( count > 0 ) { + r *= safmn2; + count -= 1; + } + } else { + r = sqrt( ( f1*f1 ) + ( g1*g1 ) ); + cs = f1 / r; + sn = g1 / r; + } + } + if ( r < 0.0 ) { + cs *= -1; + sn *= -1; + r *= -1; + } + out[ offsetOut ] = cs; + out[ offsetOut + strideOut ] = sn; + out[ offsetOut + ( strideOut*2 ) ] = r; + return out; +} + + +// EXPORTS // + +module.exports = dlartgp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/dlartgp.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/dlartgp.js new file mode 100644 index 000000000000..13c22224b396 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/dlartgp.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Generates a plane rotation so that the diagonal is nonnegative. +* +* @param {number} F - the first component of vector to be rotated. +* @param {number} G - the second component of vector to be rotated. +* @param {Float64Array} out - output array containing the cosine and sine of the rotation and the non zero component of the rotated vector. +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 3 ); +* dlartgp( 1.0, 2.0, out, 1, 0 ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +*/ +function dlartgp( F, G, out ) { + return base( F, G, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlartgp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/index.js new file mode 100644 index 000000000000..37b257cb763b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/index.js @@ -0,0 +1,64 @@ +/** +* @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'; + +/** +* LAPACK routine to compute the singular values of `2x2` matrix. +* +* @module @stdlib/lapack/base/dlartgp +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlartgp = require( '@stdlib/lapack/base/dlartgp' ); +* +* var out = new Float64Array( 3 ); +* dlartgp( 1.0, 2.0, out ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlartgp = require( '@stdlib/lapack/base/dlartgp' ); +* +* var out = new Float64Array( 3 ); +* dlartgp.ndarray( 1.0, 2.0, out, 1, 0 ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +*/ + +// 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 dlartgp; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlartgp = main; +} else { + dlartgp = tmp; +} + + +// EXPORTS // + +module.exports = dlartgp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/main.js new file mode 100644 index 000000000000..1a654734cf1d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/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 dlartgp = require( './dlartgp.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlartgp, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlartgp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/ndarray.js new file mode 100644 index 000000000000..bf7527c4c348 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/lib/ndarray.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the singular values of `2x2` matrix using alternative indexing semantics. +* +* @name dlartgp +* @type {Function} +* @param {number} F - the first component of vector to be rotated. +* @param {number} G - the second component of vector to be rotated. +* @param {Float64Array} out - output array containing the cosine and sine of the rotation and the non zero component of the rotated vector. +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 3 ); +* dlartgp( 1.0, 2.0, out, 1, 0 ); +* // out => [ ~0.447, ~0.894, ~2.236 ] +*/ +var dlartgp = base; + + +// EXPORTS // + +module.exports = dlartgp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/package.json b/lib/node_modules/@stdlib/lapack/base/dlartgp/package.json new file mode 100644 index 000000000000..2f70c6cca95e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlartgp", + "version": "0.0.0", + "description": "Generates a plane rotation so that the diagonal is nonnegative.", + "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", + "lapack", + "dlartgp", + "singular", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.dlartgp.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.dlartgp.js new file mode 100644 index 000000000000..8ecd475cee7f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.dlartgp.js @@ -0,0 +1,137 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlartgp = require( './../lib/dlartgp.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlartgp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( dlartgp.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a plane rotation of vector with non-zero component(s)', function test( t ) { + var expected; + var out; + + out = new Float64Array( 3 ); + out = dlartgp( 2.0, 3.0, out ); + expected = new Float64Array( [ 0.55470019622522915, 0.83205029433784372, 3.6055512754639891 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( -1.0, 3.0, out ); + expected = new Float64Array( [ -0.31622776601683794, 0.94868329805051377, 3.1622776601683795 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( 1.0, -3.0, out ); + expected = new Float64Array( [ 0.31622776601683794, -0.94868329805051377, 3.1622776601683795 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( -99.9, -67.124, out ); + expected = new Float64Array( [ -0.83003541678744774, -0.55771068384825462, 120.35631007969629 ] ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function generates a plane rotation of vector with zero component(s)', function test( t ) { + var expected; + var out; + + out = new Float64Array( 3 ); + out = dlartgp( 2.0, 0.0, out ); + expected = new Float64Array( [ 1, 0, 2 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( 0.0, -9.4, out ); + expected = new Float64Array( [ 0, -1, 9.4 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( 0.0, 0.0, out ); + expected = new Float64Array( [ 1.0, 0.0, 0.0 ] ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function generates a plane rotation of vector with very large/small component(s)', function test( t ) { + var expected; + var out; + + out = new Float64Array( 3 ); + out = dlartgp( 1.0e147, 1.0e146, out ); + expected = new Float64Array( [ 0.99503719020998915, 0.099503719020998915, 1.004987562112089e+147 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( 5.0e-147, 1.0e-148, out ); + expected = new Float64Array( [ 0.99980005998000698, 0.19996001199600138E-1, 0.50009999000199952E-146 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( 5.0e-324, 5.0e-324, out ); + expected = new Float64Array( [ 0.70710678118654746, 0.70710678118654746, 5.0e-324 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlartgp( 1.0e300, 1.0e-320, out ); + expected = new Float64Array( [ 1.0, 0.0, 0.1E+301 ] ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.js new file mode 100644 index 000000000000..0626a6c8e5e6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlartgp = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlartgp, '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 dlartgp.ndarray, '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 dlartgp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlartgp, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var dlartgp; + var main; + + main = require( './../lib/dlartgp.js' ); + + dlartgp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlartgp, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.ndarray.js new file mode 100644 index 000000000000..13877e0615b2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartgp/test/test.ndarray.js @@ -0,0 +1,94 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlartgp = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlartgp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( dlartgp.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access pattern to store computed values', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 999.9, 999.9, 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ); + expected = new Float64Array( [ 999.9, 999.9, 0.55470019622522915, 999.9, 999.9, 0.83205029433784372, 999.9, 999.9, 3.6055512754639891 ] ); + out = dlartgp( 2.0, 3.0, out, 3, 2 ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 999.9, 999.9, 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ); + expected = new Float64Array( [ 999.9, 999.9, 3.6055512754639891, 999.9, 999.9, 0.83205029433784372, 999.9, 999.9, 0.55470019622522915 ] ); + out = dlartgp( 2.0, 3.0, out, -3, out.length-1 ); + isApprox( t, out, expected, 1.0 ); + t.end(); +});