diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/README.md b/lib/node_modules/@stdlib/lapack/base/dlas2/README.md new file mode 100644 index 000000000000..93cc3250673e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/README.md @@ -0,0 +1,232 @@ + + +# dlas2 + +> Compute the singular values of a 2x2 upper triangular matrix. + +
+ +The singular values of a 2x2 upper triangular matrix $ A = \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ are returned as $\begin{bmatrix} SSMIN & SSMAX \end{bmatrix}$. + +
+ + + +
+ +## Usage + +```javascript +var dlas2 = require( '@stdlib/lapack/base/dlas2' ); +``` + +#### dlas2( F, G, H, out ) + +Computes the singular values of 2x2 upper triangular matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 2 ); +dlas2( 1.0, 2.0, 3.0, out ); +// out => [ ~0.822, ~3.65 ] +``` + +The function has the following parameters: + +- **F**: the (0,0) element of a 2x2 matrix. +- **G**: the (0,1) and (1,0) elements of a 2x2 matrix. +- **H**: the (1,1) element of a 2x2 matrix. +- **out**: output [`Float64Array`][@stdlib/array/float64] containing the smaller and larger singular values respectively. + +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 ] ); + +// Create an offset view... +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlas2( 1.0, 2.0, 3.0, out1 ); +// out0 => [ 0.0, ~0.822, ~3.65 ] +``` + +#### dlas2.ndarray( F, G, H, out, strideOut, offsetOut ) + +Computes the singular values of a 2x2 upper triangular matrix using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 2 ); +dlas2.ndarray( 1.0, 2.0, 3.0, out, 1, 0 ); +// out => [ ~0.822, ~3.65 ] +``` + +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 ] ); +dlas2.ndarray( 1.0, 2.0, 3.0, out, -1, 2 ); +// out => [ 0.0, ~3.65, ~0.822 ] +``` + +
+ + + +
+ +## Notes + +- `dlas2()` corresponds to the [LAPACK][lapack] routine [`dlas2`][lapack-dlas2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlas2 = require( '@stdlib/lapack/base/dlas2' ); + +var out = new Float64Array( 2 ); +dlas2( 6.0, 8.0, 2.0, out ); +console.log( out ); + +dlas2.ndarray( 6.0, 8.0, 2.0, out, 1, 0 ); +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/dlas2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlas2/benchmark/benchmark.js new file mode 100644 index 000000000000..a476b1a1f61f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlas2 = require( './../lib/dlas2.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( format( '%s', pkg ), function benchmark( b ) { + var out; + var N; + var f; + var g; + var h; + var i; + + N = 100; + f = uniform( N, -500.0, 500.0, options ); + g = uniform( N, -500.0, 500.0, options ); + h = uniform( N, -500.0, 500.0, options ); + + out = new Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dlas2( f[ i%f.length ], g[ i%g.length ], h[ i%h.length ], out ); + 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/dlas2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlas2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..ac078eeea986 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/benchmark/benchmark.ndarray.js @@ -0,0 +1,69 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlas2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( format( '%s:ndarray', pkg ), function benchmark( b ) { + var out; + var N; + var f; + var g; + var h; + var i; + + N = 100; + f = uniform( N, -500.0, 500.0, options ); + g = uniform( N, -500.0, 500.0, options ); + h = uniform( N, -500.0, 500.0, options ); + + out = new Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dlas2( f[ i%f.length ], g[ i%g.length ], h[ i%h.length ], out, 1, 0 ); + 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/dlas2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlas2/docs/repl.txt new file mode 100644 index 000000000000..e66f4e889eeb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/docs/repl.txt @@ -0,0 +1,76 @@ + +{{alias}}( F, G, H, out ) + Computes the singular values of a 2x2 upper triangular matrix. + + Indexing is relative to the first index. To introduce an offset, + use typed array views. + + Parameters + ---------- + F: number + The (0,0) element of a 2x2 matrix. + + G: number + The (0,1) and (1,0) elements of a 2x2 matrix. + + H: number + The (1,1) element of a 2x2 matrix. + + out: Float64Array + Output array containing eigenvalues of the larger and smaller absolute + values, respectively. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}( 1.0, 2.0, 3.0, out ) + [ ~0.822, ~3.65 ] + + +{{alias}}.ndarray( F, G, H, out, strideOut, offsetOut ) + Computes the singular values of a 2x2 upper triangular matrix using + alternative indexing semantics. + + 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 (0,0) element of a 2x2 matrix. + + G: number + The (0,1) and (1,0) elements of a 2x2 matrix. + + H: number + The (1,1) element of a 2x2 matrix. + + out: Float64Array + Output array containing eigenvalues of the larger and smaller absolute + values, 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 ] ); + > {{alias}}.ndarray( 1.0, 2.0, 3.0, out, 1, 1 ) + [ 0.0, ~0.822, ~3.65 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlas2/docs/types/index.d.ts new file mode 100644 index 000000000000..48df6b6fc6e3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* Interface describing `dlas2`. +*/ +interface Routine { + /** + * Computes the singular values of a `2x2` upper triangular matrix. + * + * @param F - the (0,0) element of a `2x2` matrix + * @param G - the (0,1) element of a `2x2` matrix + * @param H - the (1,1) element of a `2x2` matrix + * @param out - output array containing the smaller and larger singular values respectively + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 2 ); + * dlas2( 1.0, 2.0, 3.0, out ); + * // out => [ ~0.822, ~3.65 ] + */ + ( F: number, G: number, H: number, out: Float64Array ): Float64Array; + + /** + * Computes the singular values of a `2x2` upper triangular matrix using alternative indexing semantics. + * + * @param F - the (0,0) element of a `2x2` matrix + * @param G - the (0,1) element of a `2x2` matrix + * @param H - the (1,1) element of a `2x2` matrix + * @param out - output array containing the smaller and larger singular values respectively + * @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( 2 ); + * dlas2.ndarray( 1.0, 2.0, 3.0, out, 1, 0 ); + * // out => [ ~0.822, ~3.65 ] + */ + ndarray( F: number, G: number, H: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; +} + +/** +* Computes the singular values of a `2x2` upper triangular matrix. +* +* @param F - the (0,0) element of a `2x2` matrix +* @param G - the (0,1) element of a `2x2` matrix +* @param H - the (1,1) element of a `2x2` matrix +* @param out - output array containing the smaller and larger singular values respectively +* @returns output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* dlas2( 1.0, 2.0, 3.0, out ); +* // out => [ ~0.822, ~3.65 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* dlas2.ndarray( 1.0, 2.0, 3.0, out, 1, 0 ); +* // out => [ ~0.822, ~3.65 ] +*/ +declare var dlas2: Routine; + + +// EXPORTS // + +export = dlas2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlas2/docs/types/test.ts new file mode 100644 index 000000000000..5deb36a46418 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/docs/types/test.ts @@ -0,0 +1,200 @@ +/* +* @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 dlas2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlas2( 2.0, 3.0, 4.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 ] ); + + dlas2( '5', 3.0, 4.0, out ); // $ExpectError + dlas2( true, 3.0, 4.0, out ); // $ExpectError + dlas2( false, 3.0, 4.0, out ); // $ExpectError + dlas2( null, 3.0, 4.0, out ); // $ExpectError + dlas2( void 0, 3.0, 4.0, out ); // $ExpectError + dlas2( [], 3.0, 4.0, out ); // $ExpectError + dlas2( {}, 3.0, 4.0, out ); // $ExpectError + dlas2( ( x: number ): number => x, 3.0, 4.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 ] ); + + dlas2( 2.0, '5', 4.0, out ); // $ExpectError + dlas2( 2.0, true, 4.0, out ); // $ExpectError + dlas2( 2.0, false, 4.0, out ); // $ExpectError + dlas2( 2.0, null, 4.0, out ); // $ExpectError + dlas2( 2.0, void 0, 4.0, out ); // $ExpectError + dlas2( 2.0, [], 4.0, out ); // $ExpectError + dlas2( 2.0, {}, 4.0, out ); // $ExpectError + dlas2( 2.0, ( x: number ): number => x, 4.0, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlas2( 2.0, 3.0, '5', out ); // $ExpectError + dlas2( 2.0, 3.0, true, out ); // $ExpectError + dlas2( 2.0, 3.0, false, out ); // $ExpectError + dlas2( 2.0, 3.0, null, out ); // $ExpectError + dlas2( 2.0, 3.0, void 0, out ); // $ExpectError + dlas2( 2.0, 3.0, [], out ); // $ExpectError + dlas2( 2.0, 3.0, {}, out ); // $ExpectError + dlas2( 2.0, 3.0, ( x: number ): number => x, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + + dlas2( 2.0, 3.0, 4.0, '5' ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, 5 ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, true ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, false ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, null ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, void 0 ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, [] ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, {} ); // $ExpectError + dlas2( 2.0, 3.0, 4.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 ] ); + + dlas2(); // $ExpectError + dlas2( 2.0 ); // $ExpectError + dlas2( 2.0, 3.0 ); // $ExpectError + dlas2( 2.0, 3.0, 4.0 ); // $ExpectError + dlas2( 2.0, 3.0, 4.0, out, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlas2.ndarray( 2.0, 3.0, 4.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 ] ); + + dlas2.ndarray( '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( true, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( false, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( null, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( void 0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( [], 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( ( x: number ): number => x, 3.0, 4.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 ] ); + + dlas2.ndarray( 2.0, '5', 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, true, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, false, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, null, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, void 0, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, [], 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, {}, 4.0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, ( x: number ): number => x, 4.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlas2.ndarray( 2.0, 3.0, '5', out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, true, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, false, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, null, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, void 0, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, [], out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, {}, out, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + + dlas2.ndarray( 2.0, 3.0, 4.0, '5', 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, 5, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, true, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, false, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, null, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, void 0, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, [], 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, {}, 1, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, ( x: number ): number => x, 1, 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 ] ); + + dlas2.ndarray( 2.0, 3.0, 4.0, out, '5', 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, true, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, false, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, null, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, void 0, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, [], 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, {}, 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, '5' ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, true ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, false ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, null ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, void 0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, [] ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, {} ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.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 ] ); + + dlas2.ndarray(); // $ExpectError + dlas2.ndarray( 2.0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1 ); // $ExpectError + dlas2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlas2/examples/index.js new file mode 100644 index 000000000000..46711054687f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/examples/index.js @@ -0,0 +1,29 @@ +/** +* @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 dlas2 = require( './../lib' ); + +var out = new Float64Array( 2 ); +dlas2( 6.0, 8.0, 2.0, out ); +console.log( out ); + +dlas2.ndarray( 6.0, 8.0, 2.0, out, 1, 0 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/base.js new file mode 100644 index 000000000000..87d9af7d3ddd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/base.js @@ -0,0 +1,106 @@ +/** +* @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 min = require( '@stdlib/math/base/special/min' ); +var abs2 = require( '@stdlib/math/base/special/abs2' ); + + +// MAIN // + +/** +* Computes the singular values of a `2x2` upper triangular matrix. +* +* @private +* @param {number} F - the (0,0) element of a `2x2` matrix +* @param {number} G - the (0,1) element of a `2x2` matrix +* @param {number} H - the (1,1) element of a `2x2` matrix +* @param {Float64Array} out - output array containing the smaller and larger singular values respectively +* @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( 2 ); +* dlas2( 1.0, 2.0, 3.0, out, 1, 0 ); +* // out => [ ~0.822, ~3.65 ] +*/ +function dlas2( F, G, H, out, strideOut, offsetOut ) { + var ssmax; + var ssmin; + var fhmn; + var fhmx; + var as; + var at; + var au; + var fa; + var ga; + var ha; + var c; + + fa = abs( F ); + ga = abs( G ); + ha = abs( H ); + fhmn = min( fa, ha ); + fhmx = max( fa, ha ); + if ( fhmn === 0.0 ) { + ssmin = 0.0; + if ( fhmx === 0.0 ) { + ssmax = ga; + } else { + ssmax = max( fhmx, ga ) * sqrt( 1.0 + abs2( min( fhmx, ga ) / max( fhmx, ga ) ) ); + } + } else if ( ga < fhmx ) { + as = 1.0 + ( fhmn / fhmx ); + at = ( fhmx - fhmn ) / fhmx; + au = abs2( ga / fhmx ); + c = 2.0 / ( sqrt( ( as * as ) + au ) + sqrt( ( at * at ) + au ) ); + ssmin = fhmn * c; + ssmax = fhmx / c; + } else { + au = fhmx / ga; + if ( au === 0.0 ) { + // Avoid possible harmful underflow if exponent range asymmetric. + ssmin = ( fhmn * fhmx ) / ga; + ssmax = ga; + } else { + as = 1.0 + ( fhmn / fhmx ); + at = ( fhmx - fhmn ) / fhmx; + c = 1.0 / ( sqrt( 1.0 + abs2( as * au ) ) + sqrt( 1.0 + abs2( at * au ) ) ); + ssmin = ( fhmn * c ) * au; + ssmin += ssmin; + ssmax = ga / ( c + c ); + } + } + out[ offsetOut ] = ssmin; + out[ offsetOut + strideOut ] = ssmax; + return out; +} + + +// EXPORTS // + +module.exports = dlas2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/lib/dlas2.js b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/dlas2.js new file mode 100644 index 000000000000..4edd42eba0d5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/dlas2.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the singular values of a `2x2` upper triangular matrix. +* +* @param {number} F - the (0,0) element of a `2x2` matrix +* @param {number} G - the (0,1) element of a `2x2` matrix +* @param {number} H - the (1,1) element of a `2x2` matrix +* @param {Float64Array} out - output array containing the smaller and larger singular values respectively +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* dlas2( 1.0, 2.0, 3.0, out ); +* // out => [ ~0.822, ~3.65 ] +*/ +function dlas2( F, G, H, out ) { + return base( F, G, H, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlas2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/index.js new file mode 100644 index 000000000000..8435eaff05a7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/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 a `2x2` upper triangular matrix. +* +* @module @stdlib/lapack/base/dlas2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlas2 = require( '@stdlib/lapack/base/dlas2' ); +* +* var out = new Float64Array( 2 ); +* dlas2( 1.0, 2.0, 3.0, out ); +* // out => [ ~0.822, ~3.65 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlas2 = require( '@stdlib/lapack/base/dlas2' ); +* +* var out = new Float64Array( 2 ); +* dlas2.ndarray( 1.0, 2.0, 3.0, out, 1, 0 ); +* // out => [ ~0.822, ~3.65 ] +*/ + +// 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 dlas2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlas2 = main; +} else { + dlas2 = tmp; +} + + +// EXPORTS // + +module.exports = dlas2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/main.js new file mode 100644 index 000000000000..4acef21c2995 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/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 dlas2 = require( './dlas2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlas2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlas2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/ndarray.js new file mode 100644 index 000000000000..fbaad6e54c43 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/lib/ndarray.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the singular values of a `2x2` upper triangular matrix using alternative indexing semantics. +* +* @name dlas2 +* @type {Function} +* @param {number} F - the (0,0) element of a `2x2` matrix +* @param {number} G - the (0,1) element of a `2x2` matrix +* @param {number} H - the (1,1) element of a `2x2` matrix +* @param {Float64Array} out - output array containing the smaller and larger singular values respectively +* @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( 2 ); +* dlas2( 1.0, 2.0, 3.0, out, 1, 0 ); +* // out => [ ~0.822, ~3.65 ] +*/ +function dlas2( F, G, H, out, strideOut, offsetOut ) { + return base( F, G, H, out, strideOut, offsetOut ); +} + + +// EXPORTS // + +module.exports = dlas2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/package.json b/lib/node_modules/@stdlib/lapack/base/dlas2/package.json new file mode 100644 index 000000000000..2a5ee39709d4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlas2", + "version": "0.0.0", + "description": "Compute the singular values of a `2x2` upper triangular matrix.", + "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", + "dlas2", + "singular", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.dlas2.js b/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.dlas2.js new file mode 100644 index 000000000000..764c984792eb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.dlas2.js @@ -0,0 +1,86 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isAlmostSameValueFloat64Array = require( '@stdlib/assert/is-almost-same-value-float64array' ); +var dlas2 = require( './../lib/dlas2.js' ); + + +// TESTS // + +// NOTE: Expected outputs in tests were generated using the reference LAPACK Fortran implementation of DLAS2. + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlas2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( dlas2.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular symmetric matrix', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 2.0, 3.0, 4.0, out ); + expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 0.0, 3.0, 4.0, out ); + expected = new Float64Array( [ 0.0, 5.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with zero diagonal and nonzero off-diagonal elements', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 0.0, 5.0, 0.0, out ); + expected = new Float64Array( [ 0.0, 5.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with `G` greater than `F` and `H`', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 3.0, 5.0, 4.0, out ); + expected = new Float64Array( [ 1.7516528767249206, 6.8506723903177065 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 1.0e-200, 1.0e200, 2.0e-200, out ); + expected = new Float64Array( [ 0.0, 1.0e200 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.js new file mode 100644 index 000000000000..b3e37f897949 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/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 dlas2 = 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 dlas2, '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 dlas2.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 dlas2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlas2, 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 dlas2; + var main; + + main = require( './../lib/dlas2.js' ); + + dlas2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlas2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.ndarray.js new file mode 100644 index 000000000000..162d2b5c5c8b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlas2/test/test.ndarray.js @@ -0,0 +1,218 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isAlmostSameValueFloat64Array = require( '@stdlib/assert/is-almost-same-value-float64array' ); +var dlas2 = require( './../lib/ndarray.js' ); + + +// TESTS // + +// NOTE: Expected outputs in tests were generated using the reference LAPACK Fortran implementation of DLAS2. + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlas2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dlas2.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular symmetric matrix', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 2.0, 3.0, 4.0, out, 1, 0 ); + expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 0.0, 3.0, 4.0, out, 1, 0 ); + expected = new Float64Array( [ 0.0, 5.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with zero diagonal and nonzero off-diagonal elements', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 0.0, 5.0, 0.0, out, 1, 0 ); + expected = new Float64Array( [ 0.0, 5.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with `G` greater than `F` and `H`', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 3.0, 5.0, 4.0, out, 1, 0 ); + expected = new Float64Array( [ 1.7516528767249206, 6.8506723903177065 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 1.0e-200, 1.0e200, 2.0e-200, out, 1, 0 ); + expected = new Float64Array( [ 0.0, 1.0e200 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular symmetric matrix (large stride)', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 0, 9999, 0, 9999 ] ); + + out = dlas2( 2.0, 3.0, 4.0, out, 2, 0 ); + expected = new Float64Array( [ 1.5513263285176897, 9999, 5.1568776039816795, 9999 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 0.0, 3.0, 4.0, out, 2, 0 ); + expected = new Float64Array( [ 0.0, 9999, 5.0, 9999 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with zero diagonal and nonzero off-diagonal elements (large stride)', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 0, 9999, 0, 9999 ] ); + + out = dlas2( 0.0, 5.0, 0.0, out, 2, 0 ); + expected = new Float64Array( [ 0.0, 9999, 5.0, 9999 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with `G` greater than `F` and `H` (large stride)', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 0, 9999, 0, 9999 ] ); + + out = dlas2( 3.0, 5.0, 4.0, out, 2, 0 ); + expected = new Float64Array( [ 1.7516528767249206, 9999, 6.8506723903177065, 9999 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 1.0e-200, 1.0e200, 2.0e-200, out, 2, 0 ); + expected = new Float64Array( [ 0.0, 9999, 1.0e200, 9999 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular symmetric matrix (negative stride)', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 2.0, 3.0, 4.0, out, -1, 1 ); + expected = new Float64Array( [ 5.1568776039816795, 1.5513263285176897 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 0.0, 3.0, 4.0, out, -1, 1 ); + expected = new Float64Array( [ 5.0, 0.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with zero diagonal and nonzero off-diagonal elements (negative stride)', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 0.0, 5.0, 0.0, out, -1, 1 ); + expected = new Float64Array( [ 5.0, 0.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with `G` greater than `F` and `H` (negative stride)', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + + out = dlas2( 3.0, 5.0, 4.0, out, -1, 1 ); + expected = new Float64Array( [ 6.8506723903177065, 1.7516528767249206 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 1.0e-200, 1.0e200, 2.0e-200, out, -1, 1 ); + expected = new Float64Array( [ 1.0e200, 0.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular symmetric matrix (offset)', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 9999, 0, 0 ] ); + + out = dlas2( 2.0, 3.0, 4.0, out, 1, 1 ); + expected = new Float64Array( [ 9999, 1.5513263285176897, 5.1568776039816795 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 0.0, 3.0, 4.0, out, 1, 1 ); + expected = new Float64Array( [ 9999, 0.0, 5.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with zero diagonal and nonzero off-diagonal elements (offset)', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 9999, 0, 0 ] ); + + out = dlas2( 0.0, 5.0, 0.0, out, 1, 1 ); + expected = new Float64Array( [ 9999, 0.0, 5.0 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the singular values of a 2x2 upper triangular matrix with `G` greater than `F` and `H` (offset)', function test( t ) { + var expected; + var out; + + out = new Float64Array( [ 9999, 0, 0 ] ); + + out = dlas2( 3.0, 5.0, 4.0, out, 1, 1 ); + expected = new Float64Array( [ 9999, 1.7516528767249206, 6.8506723903177065 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + + out = dlas2( 1.0e-200, 1.0e200, 2.0e-200, out, 1, 1 ); + expected = new Float64Array( [ 9999, 0.0, 1.0e200 ] ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); + t.end(); +});