diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/README.md b/lib/node_modules/@stdlib/lapack/base/dlartg/README.md new file mode 100644 index 000000000000..a5e7729ef44a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/README.md @@ -0,0 +1,292 @@ + + +# dlartg + +> LAPACK routine to construct a Givens rotation of a two-dimensional vector that zeros out the second component. + +
+ +`dlartg` constructs a Givens rotation for a two-dimensional vector such that the following equation is satisfied: + + + + +```math +\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix} +``` + + + +where `C` represents the cosine of the rotation `S` represents the sine of the rotation and `R` represents the length of the vector after rotation. + +
+ + + +
+ +## Usage + +```javascript +var dlartg = require( '@stdlib/lapack/base/dlartg' ); +``` + +#### dlartg( F, G, C, S, R ) + +Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. For a two-dimensional vector `( F, G )` it computes the sine `S`, cosine `C` and the resultant `R`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var F = new Float64Array( [ 3.0 ] ); +var G = new Float64Array( [ 4.0 ] ); +var C = new Float64Array( 1 ); +var S = new Float64Array( 1 ); +var R = new Float64Array( 1 ); + +dlartg( F, G, C, S, R ); +// R => [ 5.0 ] +// C => [ 0.6 ] +// S => [ 0.8 ] +``` + +The function has the following parameters: + +- **F**: single element array representing the first component of the vector to be rotated as a [`Float64Array`][mdn-float64array]. +- **G**: single element array representing the second component of the vector to be rotated as a [`Float64Array`][mdn-float64array]. +- **C**: single element array overwritten by the cosine of the rotation as a [`Float64Array`][mdn-float64array]. +- **S**: single element array overwritten by the sine of the rotation as a [`Float64Array`][mdn-float64array]. +- **R**: single element array overwritten by the length of the rotated vector as a [`Float64Array`][mdn-float64array]. + +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 arrays... +var F0 = new Float64Array( [ 0.0, 3.0 ] ); +var G0 = new Float64Array( [ 0.0, 4.0 ] ); +var C0 = new Float64Array( [ 0.0, 0.0 ] ); +var S0 = new Float64Array( [ 0.0, 0.0 ] ); +var R0 = new Float64Array( [ 0.0, 0.0 ] ); + +// Create offset views... +var F1 = new Float64Array( F0.buffer, F0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var G1 = new Float64Array( G0.buffer, G0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var C1 = new Float64Array( C0.buffer, C0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var S1 = new Float64Array( S0.buffer, S0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var R1 = new Float64Array( R0.buffer, R0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlartg( F1, G1, C1, S1, R1 ); +// R0 => [ 0.0, 5.0 ] +// C0 => [ 0.0, 0.6 ] +// S0 => [ 0.0, 0.8 ] +``` + +#### dlartg.ndarray( F, offsetF, G, offsetG, C, offsetC, S, offsetS, R, offsetR ) + +Constructs a Givens rotation of a two-dimensional vector that zeros out the second component, using alternative indexing semantics. For a two-dimensional vector `( F, G )` it computes the sine `S`, cosine `C` and the resultant `R`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var F = new Float64Array( [ 3.0 ] ); +var G = new Float64Array( [ 4.0 ] ); +var C = new Float64Array( 1 ); +var S = new Float64Array( 1 ); +var R = new Float64Array( 1 ); + +dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0 ); +// R => [ 5.0 ] +// C => [ 0.6 ] +// S => [ 0.8 ] +``` + +The function has the following parameters: + +- **F**: single element array representing the first component of the vector to be rotated as a [`Float64Array`][mdn-float64array]. +- **offsetF**: starting index for `F`. +- **G**: single element array representing the second component of the vector to be rotated as a [`Float64Array`][mdn-float64array]. +- **offsetG**: starting index for `G`. +- **C**: single element array overwritten by the cosine of the rotation as a [`Float64Array`][mdn-float64array]. +- **offsetC**: starting index for `C`. +- **S**: single element array overwritten by the sine of the rotation as a [`Float64Array`][mdn-float64array]. +- **offsetS**: starting index for `S`. +- **R**: single element array overwritten by the length of the rotated vector as a [`Float64Array`][mdn-float64array]. +- **offsetR**: starting index for `R`. + +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 F = new Float64Array( [ 0.0, 3.0 ] ); +var G = new Float64Array( [ 0.0, 4.0 ] ); +var C = new Float64Array( 2 ); +var S = new Float64Array( 2 ); +var R = new Float64Array( 2 ); + +dlartg.ndarray( F, 1, G, 1, C, 1, S, 1, R, 1 ); +// R => [ 0.0, 5.0 ] +// C => [ 0.0, 0.6 ] +// S => [ 0.0, 0.8 ] +``` + +
+ + + +
+ +## Notes + +- `dlartg()` corresponds to the [LAPACK][LAPACK] function [`dlartg`][lapack-dlartg]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var dlartg = require( '@stdlib/lapack/base/dlartg' ); + +var F = uniform( 1, -10.0, 10.0 ); +var G = uniform( 1, -10.0, 10.0 ); +var C = new Float64Array( 1 ); +var S = new Float64Array( 1 ); +var R = new Float64Array( 1 ); + +dlartg( F, G, C, S, R ); + +console.log( C ); +console.log( S ); +console.log( R ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlartg/benchmark/benchmark.js new file mode 100644 index 000000000000..91544fa03eb7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/benchmark/benchmark.js @@ -0,0 +1,67 @@ +/** +* @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/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlartg = require( './../lib/dlartg.js' ); + + +// VARIABLES // + +var opts = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var C; + var S; + var R; + var F; + var G; + var i; + + F = discreteUniform( 1, -50, 50, opts ); + G = discreteUniform( 1, -50, 50, opts ); + C = new Float64Array( 1 ); + S = new Float64Array( 1 ); + R = new Float64Array( 1 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dlartg( F, G, C, S, R ); + if ( isnan( C[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( S[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlartg/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..dbd7ec3bcada --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/benchmark/benchmark.ndarray.js @@ -0,0 +1,67 @@ +/** +* @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/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlartg = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var opts = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var C; + var S; + var R; + var F; + var G; + var i; + + F = discreteUniform( 1, -50, 50, opts ); + G = discreteUniform( 1, -50, 50, opts ); + C = new Float64Array( 1 ); + S = new Float64Array( 1 ); + R = new Float64Array( 1 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dlartg( F, 0, G, 0, C, 0, S, 0, R, 0 ); + if ( isnan( C[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( S[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlartg/docs/repl.txt new file mode 100644 index 000000000000..9f5806827422 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/docs/repl.txt @@ -0,0 +1,114 @@ + +{{alias}}( F, G, C, S, R ) + Constructs a Givens rotation of a two-dimensional vector that zeros out the + second component. + + For a two-dimensional vector `( F, G )` it computes the sine `S`, cosine `C` + and the resultant `R`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + F: Float64Array + First component of the vector to be rotated. + + G: Float64Array + Second component of the vector to be rotated. + + C: Float64Array + Overwritten by the cosine of the rotation. + + S: Float64Array + Overwritten by the sine of the rotation. + + R: Float64Array + Overwritten by the length of the rotated vector. + + Returns + ------- + undefined + Overwrites the arrays in place. + + Examples + -------- + > var F = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); + > var G = new {{alias:@stdlib/array/float64}}( [ 4.0 ] ); + > var C = new {{alias:@stdlib/array/float64}}( 1 ); + > var S = new {{alias:@stdlib/array/float64}}( 1 ); + > var R = new {{alias:@stdlib/array/float64}}( 1 ); + > {{alias}}( F, G, C, S, R ); + > R + [ 5.0 ] + > C + [ 0.6 ] + > S + [ 0.8 ] + + +{{alias}}.ndarray( F, offsetF, G, offsetG, C, offsetC, S, offsetS, R, offsetR ) + Constructs a Givens rotation of a two-dimensional vector that zeros out the + second component, using alternative indexing semantics. + + For a two-dimensional vector `( F, G )` it computes the sine `S`, cosine `C` + and the resultant `R`. + + 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: Float64Array + First component of the vector to be rotated. + + offsetF: integer + Starting index for `F`. + + G: Float64Array + Second component of the vector to be rotated. + + offsetG: integer + Starting index for `G`. + + C: Float64Array + Overwritten by the cosine of the rotation. + + offsetC: integer + Starting index for `C`. + + S: Float64Array + Overwritten by the sine of the rotation. + + offsetS: integer + Starting index for `S`. + + R: Float64Array + Overwritten by the length of the rotated vector. + + offsetR: integer + Starting index for `R`. + + Returns + ------- + undefined + Overwrites the arrays in place. + + Examples + -------- + > var F = new {{alias:@stdlib/array/float64}}( [ 0.0, 3.0 ] ); + > var G = new {{alias:@stdlib/array/float64}}( [ 0.0, 4.0 ] ); + > var C = new {{alias:@stdlib/array/float64}}( 2 ); + > var S = new {{alias:@stdlib/array/float64}}( 2 ); + > var R = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}.ndarray( F, 1, G, 1, C, 1, S, 1, R, 1 ); + > R + [ 0.0, 5.0 ] + > C + [ 0.0, 0.6 ] + > S + [ 0.0, 0.8 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/index.d.ts new file mode 100644 index 000000000000..09762a82e955 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/index.d.ts @@ -0,0 +1,144 @@ +/* +* @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 + +/** +* Interface describing `dlartg`. +*/ +interface Routine { + /** + * Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. + * + * For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: + * + * ```tex + * \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) + * ``` + * + * @param F - single element array representing the first component of the vector to be rotated + * @param G - single element array representing the second component of the vector to be rotated + * @param C - single element array overwritten by the cosine of the rotation + * @param S - single element array overwritten by the sine of the rotation + * @param R - single element array overwritten by the length of the rotated vector + * @returns {void} + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var F = new Float64Array( [ 3.0 ] ); + * var G = new Float64Array( [ 4.0 ] ); + * var C = new Float64Array( 1 ); + * var S = new Float64Array( 1 ); + * var R = new Float64Array( 1 ); + * + * dlartg( F, G, C, S, R ); + * // R => [ 5.0 ] + * // C => [ 0.6 ] + * // S => [ 0.8 ] + */ + ( F: Float64Array, G: Float64Array, C: Float64Array, S: Float64Array, R: Float64Array ): void; + + /** + * Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. + * + * For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: + * + * ```tex + * \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) + * ``` + * + * @param F - single element array representing the first component of the vector to be rotated + * @param offsetF - starting index for `F` + * @param G - single element array representing the second component of the vector to be rotated + * @param offsetG - starting index for `G` + * @param C - single element array overwritten by the cosine of the rotation + * @param offsetC - starting index for `C` + * @param S - single element array overwritten by the sine of the rotation + * @param offsetS - starting index for `S` + * @param R - single element array overwritten by the length of the rotated vector + * @param offsetR - starting index for `R` + * @returns {void} + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var F = new Float64Array( [ 3.0 ] ); + * var G = new Float64Array( [ 4.0 ] ); + * var C = new Float64Array( 1 ); + * var S = new Float64Array( 1 ); + * var R = new Float64Array( 1 ); + * + * dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0 ); + * // R => [ 5.0 ] + * // C => [ 0.6 ] + * // S => [ 0.8 ] + */ + ndarray( F: Float64Array, offsetF: number, G: Float64Array, offsetG: number, C: Float64Array, offsetC: number, S: Float64Array, offsetS: number, R: Float64Array, offsetR: number ): void; +} + +/** +* Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. +* +* For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: +* +* ```tex +* \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) +* ``` +* +* @param F - single element array representing the first component of the vector to be rotated +* @param G - single element array representing the second component of the vector to be rotated +* @param C - single element array overwritten by the cosine of the rotation +* @param S - single element array overwritten by the sine of the rotation +* @param R - single element array overwritten by the length of the rotated vector +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var F = new Float64Array( [ 3.0 ] ); +* var G = new Float64Array( [ 4.0 ] ); +* var C = new Float64Array( 1 ); +* var S = new Float64Array( 1 ); +* var R = new Float64Array( 1 ); +* +* dlartg( F, G, C, S, R ); +* // R => [ 5.0 ] +* // C => [ 0.6 ] +* // S => [ 0.8 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var F = new Float64Array( [ 3.0 ] ); +* var G = new Float64Array( [ 4.0 ] ); +* var C = new Float64Array( 1 ); +* var S = new Float64Array( 1 ); +* var R = new Float64Array( 1 ); +* +* dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0 ); +* // R => [ 5.0 ] +* // C => [ 0.6 ] +* // S => [ 0.8 ] +*/ +declare var dlartg: Routine; + + +// EXPORTS // + +export = dlartg; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/test.ts new file mode 100644 index 000000000000..99b7511aaa75 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/test.ts @@ -0,0 +1,351 @@ +/* +* @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 dlartg = require( './index' ); + + +// TESTS // + +// The function returns void... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg( F, G, C, S, R ); // $ExpectType void +} + +// The compiler throws an error if the function is provided a first argument which is not a Float64Array... +{ + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg( '5', G, C, S, R ); // $ExpectError + dlartg( 5, G, C, S, R ); // $ExpectError + dlartg( true, G, C, S, R ); // $ExpectError + dlartg( false, G, C, S, R ); // $ExpectError + dlartg( null, G, C, S, R ); // $ExpectError + dlartg( void 0, G, C, S, R ); // $ExpectError + dlartg( [], G, C, S, R ); // $ExpectError + dlartg( {}, G, C, S, R ); // $ExpectError + dlartg( ( x: number ): number => x, G, C, S, R ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg( F, '5', C, S, R ); // $ExpectError + dlartg( F, 5, C, S, R ); // $ExpectError + dlartg( F, true, C, S, R ); // $ExpectError + dlartg( F, false, C, S, R ); // $ExpectError + dlartg( F, null, C, S, R ); // $ExpectError + dlartg( F, void 0, C, S, R ); // $ExpectError + dlartg( F, [], C, S, R ); // $ExpectError + dlartg( F, {}, C, S, R ); // $ExpectError + dlartg( F, ( x: number ): number => x, C, S, R ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg( F, G, '5', S, R ); // $ExpectError + dlartg( F, G, 5, S, R ); // $ExpectError + dlartg( F, G, true, S, R ); // $ExpectError + dlartg( F, G, false, S, R ); // $ExpectError + dlartg( F, G, null, S, R ); // $ExpectError + dlartg( F, G, void 0, S, R ); // $ExpectError + dlartg( F, G, [], S, R ); // $ExpectError + dlartg( F, G, {}, S, R ); // $ExpectError + dlartg( F, G, ( x: number ): number => x, S, R ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg( F, G, C, '5', R ); // $ExpectError + dlartg( F, G, C, 5, R ); // $ExpectError + dlartg( F, G, C, true, R ); // $ExpectError + dlartg( F, G, C, false, R ); // $ExpectError + dlartg( F, G, C, null, R ); // $ExpectError + dlartg( F, G, C, void 0, R ); // $ExpectError + dlartg( F, G, C, [], R ); // $ExpectError + dlartg( F, G, C, {}, R ); // $ExpectError + dlartg( F, G, C, ( x: number ): number => x, R ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + + dlartg( F, G, C, S, '5' ); // $ExpectError + dlartg( F, G, C, S, 5 ); // $ExpectError + dlartg( F, G, C, S, true ); // $ExpectError + dlartg( F, G, C, S, false ); // $ExpectError + dlartg( F, G, C, S, null ); // $ExpectError + dlartg( F, G, C, S, void 0 ); // $ExpectError + dlartg( F, G, C, S, [] ); // $ExpectError + dlartg( F, G, C, S, {} ); // $ExpectError + dlartg( F, G, C, S, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg(); // $ExpectError + dlartg( F ); // $ExpectError + dlartg( F, G ); // $ExpectError + dlartg( F, G, C ); // $ExpectError + dlartg( F, G, C, S ); // $ExpectError + dlartg( F, G, C, S, R, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns void... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectType void +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a Float64Array... +{ + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( '5', 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( 5, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( true, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( false, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( null, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( void 0, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( [], 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( {}, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( ( x: number ): number => x, 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, '5', G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, true, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, false, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, null, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, void 0, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, [], G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, {}, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, ( x: number ): number => x, G, 0, C, 0, S, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, '5', 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, 5, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, true, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, false, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, null, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, void 0, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, [], 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, {}, 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, ( x: number ): number => x, 0, C, 0, S, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, '5', C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, true, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, false, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, null, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, void 0, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, [], C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, {}, C, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, ( x: number ): number => x, C, 0, S, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, '5', 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, 5, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, true, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, false, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, null, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, void 0, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, [], 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, {}, 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, ( x: number ): number => x, 0, S, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, C, '5', S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, true, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, false, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, null, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, void 0, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, [], S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, {}, S, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, ( x: number ): number => x, S, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, C, 0, '5', 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, 5, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, true, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, false, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, null, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, void 0, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, [], 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, {}, 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, ( x: number ): number => x, 0, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, C, 0, S, '5', R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, true, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, false, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, null, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, void 0, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, [], R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, {}, R, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, ( x: number ): number => x, R, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a Float64Array... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, '5', 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, 5, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, true, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, false, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, null, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, void 0, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, [], 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, {}, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, '5' ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, true ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, false ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, null ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, void 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, [] ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, {} ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const F = new Float64Array( 1 ); + const G = new Float64Array( 1 ); + const C = new Float64Array( 1 ); + const S = new Float64Array( 1 ); + const R = new Float64Array( 1 ); + + dlartg.ndarray(); // $ExpectError + dlartg.ndarray( F ); // $ExpectError + dlartg.ndarray( F, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G ); // $ExpectError + dlartg.ndarray( F, 0, G, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0 ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R ); // $ExpectError + dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlartg/examples/index.js new file mode 100644 index 000000000000..ccc43a7529b1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/examples/index.js @@ -0,0 +1,35 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var dlartg = require( './../lib' ); + +var F = uniform( 1, -10.0, 10.0 ); +var G = uniform( 1, -10.0, 10.0 ); +var C = new Float64Array( 1 ); +var S = new Float64Array( 1 ); +var R = new Float64Array( 1 ); + +dlartg( F, G, C, S, R ); + +console.log( C ); +console.log( S ); +console.log( R ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/base.js new file mode 100644 index 000000000000..1928af7020f0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/base.js @@ -0,0 +1,116 @@ +/** +* @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 dlamch = require( '@stdlib/lapack/base/dlamch' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/fast/abs' ); +var sign = require( '@stdlib/math/base/special/copysign' ); +var min = require( '@stdlib/math/base/special/fast/min' ); +var max = require( '@stdlib/math/base/special/maxn' ); + + +// VARIABLES // + +var safmin = dlamch( 'safe minimum' ); +var safmax = 1.0 / safmin; +var rtmin = sqrt( safmin ); +var rtmax = sqrt( safmax / 2.0 ); + + +// MAIN // + +/** +* Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. +* +* For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: +* +* ```tex +* \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) +* ``` +* +* @private +* @param {Float64Array} F - single element array representing the first component of the vector to be rotated +* @param {NonNegativeInteger} offsetF - starting index for `F` +* @param {Float64Array} G - single element array representing the second component of the vector to be rotated +* @param {NonNegativeInteger} offsetG - starting index for `G` +* @param {Float64Array} C - single element array overwritten by the cosine of the rotation +* @param {NonNegativeInteger} offsetC - starting index for `C` +* @param {Float64Array} S - single element array overwritten by the sine of the rotation +* @param {NonNegativeInteger} offsetS - starting index for `S` +* @param {Float64Array} R - single element array overwritten by the length of the rotated vector +* @param {NonNegativeInteger} offsetR - starting index for `R` +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var F = new Float64Array( [ 3.0 ] ); +* var G = new Float64Array( [ 4.0 ] ); +* var C = new Float64Array( 1 ); +* var S = new Float64Array( 1 ); +* var R = new Float64Array( 1 ); +* +* dlartg( F, 0, G, 0, C, 0, S, 0, R, 0 ); +* // R => [ 5.0 ] +* // C => [ 0.6 ] +* // S => [ 0.8 ] +*/ +function dlartg( F, offsetF, G, offsetG, C, offsetC, S, offsetS, R, offsetR ) { + var f1; + var g1; + var fs; + var gs; + var u; + var d; + + f1 = abs( F[ offsetF ] ); + g1 = abs( G[ offsetG ] ); + + if ( G[ offsetG ] === 0.0 ) { + C[ offsetC ] = 1.0; + S[ offsetS ] = 0.0; + R[ offsetR ] = F[ offsetF ]; + } else if ( F[ offsetF ] === 0.0 ) { + C[ offsetC ] = 0.0; + S[ offsetS ] = sign( 1.0, G[ offsetG ] ); + R[ offsetR ] = g1; + } else if ( f1 > rtmin && f1 < rtmax && g1 > rtmin && g1 < rtmax ) { + d = sqrt( (F[ offsetF ]*F[ offsetF ]) + (G[ offsetG ]*G[ offsetG ]) ); + C[ offsetC ] = f1 / d; + R[ offsetR ] = sign( d, F[ offsetF ] ); + S[ offsetS ] = G[ offsetG ] / R[ offsetR ]; + } else { + u = min( safmax, max( safmin, f1, g1 ) ); + fs = F[ offsetF ] / u; + gs = G[ offsetG ] / u; + d = sqrt( (fs*fs) + (gs*gs) ); + C[ offsetC ] = abs( fs ) / d; + R[ offsetR ] = sign( d, F[ offsetF ] ); + S[ offsetS ] = gs / R[ offsetR ]; + R[ offsetR ] *= u; + } +} + + +// EXPORTS // + +module.exports = dlartg; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/lib/dlartg.js b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/dlartg.js new file mode 100644 index 000000000000..bc53d5be81e0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/dlartg.js @@ -0,0 +1,65 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. +* +* For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: +* +* ```tex +* \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) +* ``` +* +* @param {Float64Array} F - single element array representing the first component of the vector to be rotated +* @param {Float64Array} G - single element array representing the second component of the vector to be rotated +* @param {Float64Array} C - single element array overwritten by the cosine of the rotation +* @param {Float64Array} S - single element array overwritten by the sine of the rotation +* @param {Float64Array} R - single element array overwritten by the length of the rotated vector +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var F = new Float64Array( [ 3.0 ] ); +* var G = new Float64Array( [ 4.0 ] ); +* var C = new Float64Array( 1 ); +* var S = new Float64Array( 1 ); +* var R = new Float64Array( 1 ); +* +* dlartg( F, G, C, S, R ); +* // R => [ 5.0 ] +* // C => [ 0.6 ] +* // S => [ 0.8 ] +*/ +function dlartg( F, G, C, S, R ) { + base( F, 0, G, 0, C, 0, S, 0, R, 0 ); +} + + +// EXPORTS // + +module.exports = dlartg; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/index.js new file mode 100644 index 000000000000..be2716ede04b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/index.js @@ -0,0 +1,69 @@ +/** +* @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'; + +/** +* LAPACK routine to construct a Givens rotation of a two-dimensional vector that zeros out the second component. +* +* For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: +* +* ```tex +* \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) +* ``` +* +* @module @stdlib/lapack/base/dlartg +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlartg = require( '@stdlib/lapack/base/dlartg' ); +* +* var F = new Float64Array( [ 3.0 ] ); +* var G = new Float64Array( [ 4.0 ] ); +* var C = new Float64Array( 1 ); +* var S = new Float64Array( 1 ); +* var R = new Float64Array( 1 ); +* +* dlartg( F, G, C, S, R ); +* // R => [ 5.0 ] +* // C => [ 0.6 ] +* // S => [ 0.8 ] +*/ + +// 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 dlartg; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlartg = main; +} else { + dlartg = tmp; +} + + +// EXPORTS // + +module.exports = dlartg; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/main.js new file mode 100644 index 000000000000..b82f04b67f15 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlartg = require( './dlartg.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlartg, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlartg; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/ndarray.js new file mode 100644 index 000000000000..fe043f61900e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/lib/ndarray.js @@ -0,0 +1,70 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Constructs a Givens rotation of a two-dimensional vector that zeros out the second component. +* +* For a two-dimensional vector ( f, g ) it computes the sine `S`, cosine `C` and the resultant `R` such that the following equation is satisfied: +* +* ```tex +* \(\begin{bmatrix} C & S \\ -S & C \end{bmatrix} \begin{bmatrix} F \\ G \end{bmatrix} = \begin{bmatrix} R \\ 0 \end{bmatrix}\) +* ``` +* +* @param {Float64Array} F - single element array representing the first component of the vector to be rotated +* @param {NonNegativeInteger} offsetF - starting index for `F` +* @param {Float64Array} G - single element array representing the second component of the vector to be rotated +* @param {NonNegativeInteger} offsetG - starting index for `G` +* @param {Float64Array} C - single element array overwritten by the cosine of the rotation +* @param {NonNegativeInteger} offsetC - starting index for `C` +* @param {Float64Array} S - single element array overwritten by the sine of the rotation +* @param {NonNegativeInteger} offsetS - starting index for `S` +* @param {Float64Array} R - single element array overwritten by the length of the rotated vector +* @param {NonNegativeInteger} offsetR - starting index for `R` +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var F = new Float64Array( [ 3.0 ] ); +* var G = new Float64Array( [ 4.0 ] ); +* var C = new Float64Array( 1 ); +* var S = new Float64Array( 1 ); +* var R = new Float64Array( 1 ); +* +* dlartg( F, 0, G, 0, C, 0, S, 0, R, 0 ); +* // R => [ 5.0 ] +* // C => [ 0.6 ] +* // S => [ 0.8 ] +*/ +function dlartg( F, offsetF, G, offsetG, C, offsetC, S, offsetS, R, offsetR) { + base( F, offsetF, G, offsetG, C, offsetC, S, offsetS, R, offsetR ); +} + + +// EXPORTS // + +module.exports = dlartg; diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/package.json b/lib/node_modules/@stdlib/lapack/base/dlartg/package.json new file mode 100644 index 000000000000..52274dbd7945 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/lapack/base/dlartg", + "version": "0.0.0", + "description": "LAPACK routine to construct a Givens rotation of a two-dimensional vector that zeros out the second component.", + "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", + "dlartg", + "rotation", + "givens", + "plane", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/f_eq_zero.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/f_eq_zero.json new file mode 100644 index 000000000000..0310364ecb67 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/f_eq_zero.json @@ -0,0 +1,16 @@ +{ + "F": [ 0.0 ], + "offsetF": 0, + "G": [ 5.0 ], + "offsetG": 0, + "S": [ 0.0 ], + "offsetS": 0, + "C": [ 0.0 ], + "offsetC": 0, + "R": [ 0.0 ], + "offsetR": 0, + + "S_out": [ 1.0 ], + "C_out": [ 0.0 ], + "R_out": [ 5.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/g_eq_zero.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/g_eq_zero.json new file mode 100644 index 000000000000..c4bd76d3c7b3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/g_eq_zero.json @@ -0,0 +1,16 @@ +{ + "F": [ 5.0 ], + "offsetF": 0, + "G": [ 0.0 ], + "offsetG": 0, + "S": [ 0.0 ], + "offsetS": 0, + "C": [ 0.0 ], + "offsetC": 0, + "R": [ 0.0 ], + "offsetR": 0, + + "S_out": [ 0.0 ], + "C_out": [ 1.0 ], + "R_out": [ 5.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/large_values.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/large_values.json new file mode 100644 index 000000000000..b4d96ce30dd8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/large_values.json @@ -0,0 +1,16 @@ +{ + "F": [ 9.9999999999999997e+199 ], + "offsetF": 0, + "G": [ 9.9999999999999997E+199 ], + "offsetG": 0, + "S": [ 0.0 ], + "offsetS": 0, + "C": [ 0.0 ], + "offsetC": 0, + "R": [ 0.0 ], + "offsetR": 0, + + "S_out": [ 0.70710678118654746 ], + "C_out": [ 0.70710678118654746 ], + "R_out": [ 1.4142135623730950e+200 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/nonzero.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/nonzero.json new file mode 100644 index 000000000000..a41f6a6fd9cd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/nonzero.json @@ -0,0 +1,16 @@ +{ + "F": [ 3.0 ], + "offsetF": 0, + "G": [ 4.0 ], + "offsetG": 0, + "S": [ 0.0 ], + "offsetS": 0, + "C": [ 0.0 ], + "offsetC": 0, + "R": [ 0.0 ], + "offsetR": 0, + + "S_out": [ 0.8 ], + "C_out": [ 0.6 ], + "R_out": [ 5.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/f_eq_zero.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/f_eq_zero.json new file mode 100644 index 000000000000..dd652ef9cd48 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/f_eq_zero.json @@ -0,0 +1,39 @@ +{ + "F": [ + 9999, + 0 + ], + "offsetF": 1, + "G": [ + 9999, + 5 + ], + "offsetG": 1, + "S": [ + 9999, + 0 + ], + "offsetS": 1, + "C": [ + 9999, + 0 + ], + "offsetC": 1, + "R": [ + 9999, + 0 + ], + "offsetR": 1, + "S_out": [ + 9999, + 1 + ], + "C_out": [ + 9999, + 0 + ], + "R_out": [ + 9999, + 5 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/g_eq_zero.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/g_eq_zero.json new file mode 100644 index 000000000000..e7bdbf856168 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/g_eq_zero.json @@ -0,0 +1,39 @@ +{ + "F": [ + 9999, + 5 + ], + "offsetF": 1, + "G": [ + 9999, + 0 + ], + "offsetG": 1, + "S": [ + 9999, + 0 + ], + "offsetS": 1, + "C": [ + 9999, + 0 + ], + "offsetC": 1, + "R": [ + 9999, + 0 + ], + "offsetR": 1, + "S_out": [ + 9999, + 0 + ], + "C_out": [ + 9999, + 1 + ], + "R_out": [ + 9999, + 5 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/large_values.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/large_values.json new file mode 100644 index 000000000000..814d21665646 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/large_values.json @@ -0,0 +1,39 @@ +{ + "F": [ + 9999, + 1e+200 + ], + "offsetF": 1, + "G": [ + 9999, + 1e+200 + ], + "offsetG": 1, + "S": [ + 9999, + 0 + ], + "offsetS": 1, + "C": [ + 9999, + 0 + ], + "offsetC": 1, + "R": [ + 9999, + 0 + ], + "offsetR": 1, + "S_out": [ + 9999, + 0.7071067811865475 + ], + "C_out": [ + 9999, + 0.7071067811865475 + ], + "R_out": [ + 9999, + 1.414213562373095e+200 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/nonzero.json b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/nonzero.json new file mode 100644 index 000000000000..7a46b9a20828 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/fixtures/offsets/nonzero.json @@ -0,0 +1,39 @@ +{ + "F": [ + 9999, + 3 + ], + "offsetF": 1, + "G": [ + 9999, + 4 + ], + "offsetG": 1, + "S": [ + 9999, + 0 + ], + "offsetS": 1, + "C": [ + 9999, + 0 + ], + "offsetC": 1, + "R": [ + 9999, + 0 + ], + "offsetR": 1, + "S_out": [ + 9999, + 0.8 + ], + "C_out": [ + 9999, + 0.6 + ], + "R_out": [ + 9999, + 5 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.dlartg.js b/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.dlartg.js new file mode 100644 index 000000000000..31486a2d7316 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.dlartg.js @@ -0,0 +1,171 @@ +/** +* @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 dlartg = require( './../lib/dlartg.js' ); + + +// FIXTURES // + +var G_EQ_ZERO = require( './fixtures/g_eq_zero.json' ); +var F_EQ_ZERO = require( './fixtures/f_eq_zero.json' ); +var NONZERO_VALUES = require( './fixtures/nonzero.json' ); +var LARGE_VALUES = require( './fixtures/large_values.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlartg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( dlartg.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for G = 0', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = G_EQ_ZERO; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, G, C, S, R ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for F = 0', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = F_EQ_ZERO; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, G, C, S, R ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for nonzero inputs', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = NONZERO_VALUES; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, G, C, S, R ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for large inputs', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = LARGE_VALUES; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, G, C, S, R ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.js new file mode 100644 index 000000000000..469d2df8c732 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/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 IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlartg = 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 dlartg, '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 dlartg.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 dlartg = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlartg, 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 dlartg; + var main; + + main = require( './../lib/dlartg.js' ); + + dlartg = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlartg, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.ndarray.js new file mode 100644 index 000000000000..b65668151113 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlartg/test/test.ndarray.js @@ -0,0 +1,302 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlartg = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var G_EQ_ZERO = require( './fixtures/g_eq_zero.json' ); +var F_EQ_ZERO = require( './fixtures/f_eq_zero.json' ); +var NONZERO_VALUES = require( './fixtures/nonzero.json' ); +var LARGE_VALUES = require( './fixtures/large_values.json' ); + +var OFFSET_G_EQ_ZERO = require( './fixtures/offsets/g_eq_zero.json' ); +var OFFSET_F_EQ_ZERO = require( './fixtures/offsets/f_eq_zero.json' ); +var OFFSET_NONZERO_VALUES = require( './fixtures/offsets/nonzero.json' ); +var OFFSET_LARGE_VALUES = require( './fixtures/offsets/large_values.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlartg, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlartg.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for G = 0', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = G_EQ_ZERO; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for F = 0', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = F_EQ_ZERO; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for nonzero inputs', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = NONZERO_VALUES; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for large inputs', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = LARGE_VALUES; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for G = 0 (offsets)', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = OFFSET_G_EQ_ZERO; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for F = 0 (offsets)', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = OFFSET_F_EQ_ZERO; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for nonzero inputs (offsets)', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = OFFSET_NONZERO_VALUES; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for large inputs (offsets)', function test( t ) { + var expectedS; + var expectedC; + var expectedR; + var data; + var F; + var G; + var S; + var C; + var R; + + data = OFFSET_LARGE_VALUES; + + F = new Float64Array( data.F ); + G = new Float64Array( data.G ); + S = new Float64Array( data.S ); + C = new Float64Array( data.C ); + R = new Float64Array( data.R ); + + expectedC = new Float64Array( data.C_out ); + expectedS = new Float64Array( data.S_out ); + expectedR = new Float64Array( data.R_out ); + + dlartg( F, data.offsetF, G, data.offsetG, C, data.offsetC, S, data.offsetS, R, data.offsetR ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( C, expectedC, 'returns expected value' ); + t.deepEqual( R, expectedR, 'returns expected value' ); + t.end(); +});