From 847c6a168c482a5cec458697d6ef91f00a1a8b18 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 21 Aug 2024 18:20:06 +0530 Subject: [PATCH 01/16] feat: init base implementation --- .../@stdlib/lapack/base/dlasv2/lib/base.js | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js new file mode 100644 index 000000000000..4f5f48c68215 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -0,0 +1,247 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements */ + +'use strict'; + +// MODULES // + +var signum = require( '@stdlib/math/base/special/signum' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/abs' ); + + +// FUNCTIONS // + +/** +* Returns `x` multipled by `signum( y )`. +* +* @private +* @param {number} x - scalar element +* @param {number} y - scalar element +* @returns {number} computed value +* +* @example +* var out = sign( 1.0, -0.9 ); +* // out => -1.0 +*/ +function sign( x, y ) { + return x * signum( y ); +} + + +// MAIN // + +/** +* Computes singular value decomposition of a 2x2 triangular matrix. +* +* @private +* @param {number} F - the (0,0) element of matrix +* @param {number} G - the (0,1) element of matrix +* @param {number} H - the (1,1) element of matrix +* @param {Float64Array} out - output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` 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( 6 ); +* +* out = dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +*/ +function dlasv2( F, G, H, out, strideOut, offsetOut ) { + var gasmal; + var ssmin; + var ssmax; + var tsign; + var PMAX; + var swap; + var clt; + var crt; + var csl; + var csr; + var slt; + var snl; + var snr; + var srt; + var tmp; + var fa; + var ft; + var ga; + var gt; + var ha; + var ht; + var mm; + var tt; + var a; + var d; + var l; + var m; + var r; + var s; + var t; + + ft = F; + fa = abs( ft ); + ht = H; + ha = abs( ht ); + + // PMAX points to the maximum absolute element of matrix + + // PMAX = 1 if F largest in absolute values + + // PMAX = 2 if G largest in absolute values + + // PMAX = 3 if H largest in absolute values + + PMAX = 1; + swap = ha > fa; + if ( swap ) { + PMAX = 3; + tmp = ft; + ft = ht; + ht = tmp; + tmp = fa; + fa = ha; + ha = tmp; + + // Now FA >= HA + } + gt = G; + ga = abs( gt ); + if ( ga === 0.0 ) { + // Diagonal matrix + ssmin = ha; + ssmax = fa; + clt = 1.0; + crt = 1.0; + slt = 0.0; + srt = 0.0; + } else { + gasmal = true; + if ( ga > fa ) { + PMAX = 2; + + // TODO: replace 1.11022302E-16 with dlamch( 'E' ) + if ( ( fa / ga ) < 1.11022302E-16 ) { + // Case of very large GA + gasmal = false; + ssmax = ga; + if ( ha > 1.0 ) { + ssmin = fa / ( ga / ha ); + } else { + ssmin = ( fa / ga ) * ha; + } + clt = 1.0; + slt = ht / gt; + srt = 1.0; + crt = ft / gt; + } + } + if ( gasmal === true ) { + // Normal case + d = fa - ha; + if ( d === fa ) { + // Copes with infinte F or H + l = 1.0; + } else { + l = d / fa; + } + + // Note that 0 < l < 1 + m = gt / ft; + + // Note that abs( m ) < 1 / macheps + t = 2.0 - l; + + // Note that T > 1 + mm = m * m; + tt = t * t; + s = sqrt( tt + mm ); + + // Note that 1 < S < 1 + 1 / macheps + if ( l === 0.0 ) { + r = abs( m ); + } else { + r = sqrt( ( l * l ) + mm ); + } + + // Note that 0 < R < 1 + 1 / macheps + a = 0.5 * ( s + r); + + // Note that 1 < A < 1 + abs( m ) + ssmin = ha / a; + ssmax = fa * a; + if ( mm === 0.0 ) { + // Note that M is very tiny + if ( l === 0.0 ) { + t = sign( 2.0, ft ) * sign( 1.0, gt ); + } else { + t = ( ( gt / sign( d, ft ) ) + ( m / t ) ); + } + } else { + t = ( ( m / ( s + t ) ) + ( m / ( r + l ) ) ) * ( 1.0 + a ); + } + l = sqrt( ( t * t ) + 4.0 ); + crt = 2.0 / l; + srt = t / l; + clt = ( crt + ( srt * m ) ) / a; + slt = ( ht / ft ) * ( srt / a ); + } + } + if ( swap ) { + csl = srt; + snl = crt; + csr = slt; + snr = clt; + } else { + csl = clt; + snl = slt; + csr = crt; + snr = srt; + } + + // Correct signs 0f ssmax and ssmin + if ( PMAX === 1 ) { + tsign = sign( 1.0, csr ) * sign( 1.0, csl ) * sign( 1.0, F ); + } + if ( PMAX === 2 ) { + tsign = sign( 1.0, snr ) * sign( 1.0, csl ) * sign( 1.0, G ); + } + if ( PMAX === 3 ) { + tsign = sign( 1.0, snr ) * sign( 1.0, snl ) * sign( 1.0, H ); + } + ssmax = sign( ssmax, tsign ); + ssmin = sign( ssmin, tsign * sign( 1.0, F ) * sign( 1.0, H ) ); + + out[ offsetOut ] = ssmin; + out[ offsetOut + strideOut ] = ssmax; + out[ offsetOut + ( 2 * strideOut ) ] = snr; + out[ offsetOut + ( 3 * strideOut ) ] = csr; + out[ offsetOut + ( 4 * strideOut ) ] = snl; + out[ offsetOut + ( 5 * strideOut ) ] = csl; + return out; +} + + +// EXPORTS // + +module.exports = dlasv2; From 1b54010433b6b5c20a101b5dc93f44d46756f1ba Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 21 Aug 2024 18:23:13 +0530 Subject: [PATCH 02/16] feat: init public apis in lib --- .../@stdlib/lapack/base/dlasv2/lib/base.js | 2 +- .../@stdlib/lapack/base/dlasv2/lib/dlasv2.js | 51 +++++++++++++++++++ .../@stdlib/lapack/base/dlasv2/lib/main.js | 35 +++++++++++++ .../@stdlib/lapack/base/dlasv2/lib/ndarray.js | 51 +++++++++++++++++++ 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js index 4f5f48c68215..7bbce99903f4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -160,7 +160,7 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { // Normal case d = fa - ha; if ( d === fa ) { - // Copes with infinte F or H + // Copes with infinite F or H l = 1.0; } else { l = d / fa; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js new file mode 100644 index 000000000000..0350ec64d253 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes singular value decomposition of a 2x2 triangular matrix. +* +* @param {number} F - the (0,0) element of matrix +* @param {number} G - the (0,1) element of matrix +* @param {number} H - the (1,1) element of matrix +* @param {Float64Array} out - output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` respectively +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var out = new Float64Array( 6 ); +* +* out = dlasv2( 2.0, 3.0, 4.0, out ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +*/ +function dlasv2( F, G, H, out ) { + return base( F, G, H, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlasv2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js new file mode 100644 index 000000000000..ca8687ef6581 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlasv2 = require( './dlasv2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlasv2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlasv2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js new file mode 100644 index 000000000000..f0d34d7ec6aa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. +* +* @param {number} F - the (0,0) element of matrix +* @param {number} G - the (0,1) element of matrix +* @param {number} H - the (1,1) element of matrix +* @param {Float64Array} out - output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` 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( 6 ); +* +* out = dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +*/ +var dlasv2 = base; + + +// EXPORTS // + +module.exports = dlasv2; From 14c0f384204d4414d9e34fc49106b75f57ce79d6 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 21 Aug 2024 18:56:21 +0530 Subject: [PATCH 03/16] docs: add README --- .../@stdlib/lapack/base/dlasv2/README.md | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/README.md diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md new file mode 100644 index 000000000000..951666ccc00a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md @@ -0,0 +1,224 @@ + + +# dlasv2 + +> Compute singular value decomposition of a 2x2 triangular matrix. + +
+ +## Usage + +```javascript +var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); +``` + +#### dlasv2( F, G, H, out ) + +Computes singular value decomposition of a 2x2 triangular matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var out = new Float64Array( 6 ); + +out = dlasv2( 2.0, 3.0, 4.0, out ); +// out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +``` + +The function has the following parameters: + +- **F**: the (0,0) element of matrix. +- **G**: the (0,1) element of matrix. +- **H**: the (1,1) element of matrix. +- **out**: [`Float64Array`][mdn-float64array] output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` 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 arrays... +var OUT0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create offset views... +var OUT1 = new Float64Array( OUT0.buffer, OUT0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlasv2( 2.0, 3.0, 4.0, OUT1 ); +// OUT0 => [ 0.0, 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +``` + +#### dlasv2.ndarray( F, G, H, out, strideOut, offsetOut ) + +Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var out = new Float64Array( 6 ); + +out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +// out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +``` + +The function has the following additional parameters: + +- **strideOut**: stride length for `Out`. +- **offsetOut**: starting index for `Out`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ); + +out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ); +// out => [ 0.0, 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +``` + +
+ + + +
+ +## Notes + +- `dlasv2()` corresponds to the [LAPACK][LAPACK] routine [`dlasv2`][lapack-dlasv2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); + +var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +out = dlasv2( 2.0, 3.0, 4.0, out ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + From 07aa24beb3ebd4c2e15811d1e310fb18bc4d369a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 21 Aug 2024 19:03:06 +0530 Subject: [PATCH 04/16] docs: add repl --- .../@stdlib/lapack/base/dlasv2/docs/repl.txt | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt new file mode 100644 index 000000000000..522919449eda --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt @@ -0,0 +1,98 @@ + +{{alias}}( F, G, H, out ) + Computes singular value decomposition of a 2x2 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 matrix. + + G: number + The (0,1) element of matrix. + + H: number + The (1,1) element of matrix. + + out: Float64Array + Output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and + `CSL` respectively. + + Returns + ------- + out: Float64Array + Mutated array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 6 ); + > {{alias}}( 2.0, 3.0, 4.0, out ); + > out[ 0 ] + 1.5513263285176897 + > out[ 1 ] + 5.1568776039816795 + > out[ 2 ] + 0.9664996487646696 + > out[ 3 ] + 0.25666793515702424 + > out[ 4 ] + 0.7496781758158659 + > out[ 5 ] + 0.6618025632357402 + + +{{alias}}.ndarray( F, G, H, out, strideOut, offsetOut ) + Computes singular value decomposition of a 2x2 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 matrix. + + G: number + The (0,1) element of matrix. + + H: number + The (1,1) element of matrix. + + out: Float64Array + Output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and + `CSL` respectively. + + strideOut: integer + Stride length for `Out`. + + offsetOut: integer + Starting index for `Out`. + + Returns + ------- + out: Float64Array + Mutated array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 6 ); + > {{alias}}.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); + > out[ 0 ] + 1.5513263285176897 + > out[ 1 ] + 5.1568776039816795 + > out[ 2 ] + 0.9664996487646696 + > out[ 3 ] + 0.25666793515702424 + > out[ 4 ] + 0.7496781758158659 + > out[ 5 ] + 0.6618025632357402 + + See Also + -------- From 8bf7474071bedfc385043ec4fc8732037a52c122 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 22 Aug 2024 09:24:06 +0530 Subject: [PATCH 05/16] feat: add other files --- .../lapack/base/dlasv2/benchmark/benchmark.js | 92 ++++++++ .../dlasv2/benchmark/benchmark.ndarray.js | 92 ++++++++ .../lapack/base/dlasv2/docs/types/index.d.ts | 94 ++++++++ .../lapack/base/dlasv2/docs/types/test.ts | 200 ++++++++++++++++++ .../lapack/base/dlasv2/examples/index.js | 27 +++ .../@stdlib/lapack/base/dlasv2/lib/index.js | 64 ++++++ .../@stdlib/lapack/base/dlasv2/package.json | 72 +++++++ .../lapack/base/dlasv2/test/test.dlasv2.js | 135 ++++++++++++ .../@stdlib/lapack/base/dlasv2/test/test.js | 82 +++++++ .../lapack/base/dlasv2/test/test.ndarray.js | 92 ++++++++ 10 files changed, 950 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js new file mode 100644 index 000000000000..c8576c644c81 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlasv2 = require( './../lib/dlasv2.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @returns {Function} benchmark function +*/ +function createBenchmark( ) { + var out = uniform( 6, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dlasv2( out[ 0 ], out[ 2 ], out[ 1 ], out ); + if ( isnan( d[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + f = createBenchmark(); + bench( pkg, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..86c149516c21 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlasv2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @returns {Function} benchmark function +*/ +function createBenchmark( ) { + var out = uniform( 6, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dlasv2( out[ 0 ], out[ 2 ], out[ 1 ], out, 1, 0 ); + if ( isnan( d[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + f = createBenchmark(); + bench( pkg+':ndarray', f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts new file mode 100644 index 000000000000..045747286775 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* Interface describing `dlasv2`. +*/ +interface Routine { + /** + * Computes singular value decomposition of a 2x2 triangular matrix. + * + * @param F - the (0,0) element of matrix + * @param G - the (0,1) element of matrix + * @param H - the (1,1) element of matrix + * @param out - output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` respectively + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var out = new Float64Array( 6 ); + * + * out = dlasv2( 2.0, 3.0, 4.0, out ); + * // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] + */ + ( F: number, G: number, H: number, out: Float64Array ): Float64Array; + + /** + * Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. + * + * @param F - the (0,0) element of matrix + * @param G - the (0,1) element of matrix + * @param H - the (1,1) element of matrix + * @param out - output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` 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( 6 ); + * + * out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); + * // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] + */ + ndarray( F: number, G: number, H: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; +} + +/** +* Computes singular value decomposition of a 2x2 triangular matrix. +* +* @param F - the (0,0) element of matrix +* @param G - the (0,1) element of matrix +* @param H - the (1,1) element of matrix +* @param out - output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` respectively +* @returns output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var out = new Float64Array( 6 ); +* +* out = dlasv2( 2.0, 3.0, 4.0, out ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var out = new Float64Array( 6 ); +* +* out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +*/ +declare var dlasv2: Routine; + + +// EXPORTS // + +export = dlasv2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts new file mode 100644 index 000000000000..fdc8f1c98282 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts @@ -0,0 +1,200 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dlasv2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2( 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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2( '5', 3.0, 4.0, out ); // $ExpectError + dlasv2( true, 3.0, 4.0, out ); // $ExpectError + dlasv2( false, 3.0, 4.0, out ); // $ExpectError + dlasv2( null, 3.0, 4.0, out ); // $ExpectError + dlasv2( void 0, 3.0, 4.0, out ); // $ExpectError + dlasv2( [], 3.0, 4.0, out ); // $ExpectError + dlasv2( {}, 3.0, 4.0, out ); // $ExpectError + dlasv2( ( 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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2( 2.0, '5', 4.0, out ); // $ExpectError + dlasv2( 2.0, true, 4.0, out ); // $ExpectError + dlasv2( 2.0, false, 4.0, out ); // $ExpectError + dlasv2( 2.0, null, 4.0, out ); // $ExpectError + dlasv2( 2.0, void 0, 4.0, out ); // $ExpectError + dlasv2( 2.0, [], 4.0, out ); // $ExpectError + dlasv2( 2.0, {}, 4.0, out ); // $ExpectError + dlasv2( 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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2( 2.0, 3.0, '5', out ); // $ExpectError + dlasv2( 2.0, 3.0, true, out ); // $ExpectError + dlasv2( 2.0, 3.0, false, out ); // $ExpectError + dlasv2( 2.0, 3.0, null, out ); // $ExpectError + dlasv2( 2.0, 3.0, void 0, out ); // $ExpectError + dlasv2( 2.0, 3.0, [], out ); // $ExpectError + dlasv2( 2.0, 3.0, {}, out ); // $ExpectError + dlasv2( 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... +{ + + dlasv2( 2.0, 3.0, 4.0, '5' ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, 5 ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, true ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, false ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, null ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, void 0 ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, [] ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0, {} ); // $ExpectError + dlasv2( 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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2(); // $ExpectError + dlasv2( 2.0 ); // $ExpectError + dlasv2( 2.0, 3.0 ); // $ExpectError + dlasv2( 2.0, 3.0, 4.0 ); // $ExpectError + dlasv2( 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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.ndarray( '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( true, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( false, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( null, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( void 0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( [], 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.ndarray( 2.0, '5', 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, true, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, false, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, null, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, void 0, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, [], 4.0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, {}, 4.0, out, 1, 0 ); // $ExpectError + dlasv2.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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.ndarray( 2.0, 3.0, '5', out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, true, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, false, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, null, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, void 0, out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, [], out, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, {}, out, 1, 0 ); // $ExpectError + dlasv2.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... +{ + + dlasv2.ndarray( 2.0, 3.0, 4.0, '5', 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, 5, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, true, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, false, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, null, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, void 0, 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, [], 1, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, {}, 1, 0 ); // $ExpectError + dlasv2.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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.ndarray( 2.0, 3.0, 4.0, out, '5', 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, true, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, false, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, null, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, void 0, 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, [], 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, {}, 0 ); // $ExpectError + dlasv2.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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, '5' ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, true ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, false ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, null ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, void 0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, [] ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, {} ); // $ExpectError + dlasv2.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, 3.0, 4.0, 5.0, 6.0 ] ); + + dlasv2.ndarray(); // $ExpectError + dlasv2.ndarray( 2.0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1 ); // $ExpectError + dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js new file mode 100644 index 000000000000..c9b8029f0dd7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dlasv2 = require( './../lib/' ); + +var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +out = dlasv2( 2.0, 3.0, 4.0, out ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js new file mode 100644 index 000000000000..3dec6d397639 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute singular value decomposition of a 2x2 triangular matrix. +* +* @module @stdlib/lapack/base/dlasv2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); +* var out = new Float64Array( 6 ); +* +* out = dlasv2( 2.0, 3.0, 4.0, out ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); +* var out = new Float64Array( 6 ); +* +* out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +*/ + +// 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 dlasv2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlasv2 = main; +} else { + dlasv2 = tmp; +} + + +// EXPORTS // + +module.exports = dlasv2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json new file mode 100644 index 000000000000..2268df5c3784 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/dlaswp", + "version": "0.0.0", + "description": "Compute singular value decomposition of a 2x2 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", + "svd", + "decomposition", + "dlasv2", + "exchange", + "permute", + "permutedims", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js new file mode 100644 index 000000000000..5c985596e01e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -0,0 +1,135 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlasv2 = require( './../lib/dlasv2.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlasv2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( dlasv2.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function correctly computes svd of triangular matrix with elements in increasing order', function test( t ) { + var expected; + var out; + + out = new Float64Array( 6 ); + expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] ); + out = dlasv2( 2.0, 3.0, 4.0, out ); + isApprox( t, out, expected, 1.0 ); + + expected = new Float64Array( [ -0.9522030268983716, 9.871844275289476, 0.999516648263737, -0.031088098102407546, 0.9517427779120455, 0.3068968632818896 ] ); + out = dlasv2( -1.0, 3.0, 9.4, out ); + isApprox( t, out, expected, 1.0 ); + + expected = new Float64Array( [ -3.518670509963777, -120.37955779052484, 0.5581876810704361, 0.8297147176597564, 0.019660445769845943, 0.9998067147564729 ] ); + out = dlasv2( -99.9, -67.124, -4.24, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correctly computes svd of triangular matrix with elements in decreasing order', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795, 0.6618025632357402, 0.7496781758158659, 0.25666793515702424, 0.9664996487646696 ] ); + out = new Float64Array( 6 ); + out = dlasv2( 4.0, 3.0, 2.0, out ); + isApprox( t, out, expected, 1.0 ); + + expected = new Float64Array( [ -0.9522030268983716, 9.871844275289476, 0.3068968632818896, 0.9517427779120455, -0.031088098102407546, 0.999516648263737 ] ); + out = dlasv2( 9.4, 3.0, -1.0, out ); + isApprox( t, out, expected, 1.0 ); + + expected = new Float64Array( [ -3.518670509963777, -120.37955779052484, 0.9998067147564729, 0.019660445769845943, 0.8297147176597564, 0.5581876810704361 ] ); + out = dlasv2( -4.24, -67.124, -99.9, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correcly computes svd of triangular matrix with parameter `G` greater than both', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 1.2125424343860751, 6.597707241520579, 0.8090383403577232, 0.5877558709457702, 0.2452483296822559, 0.9694602914962858 ] ); + out = new Float64Array( 6 ); + out = dlasv2( 4.0, 5.0, 2.0, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correctly computes svd of diagonal matrix', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 2.0, -12.0, 1.0, 0.0, 1.0, 0.0 ] ); + out = new Float64Array( 6 ); + out = dlasv2( 2.0, 0.0, -12.0, out ); + isApprox( t, out, expected, 1.0 ); + + expected = new Float64Array( [ 9.0, -122.0, 0.0, 1.0, 0.0, 1.0 ] ); + out = new Float64Array( 6 ); + out = dlasv2( -122.0, 0.0, 9.0, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js new file mode 100644 index 000000000000..d9cb0e889549 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlasv2 = 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 dlasv2, '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 dlasv2.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 dlasv2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlasv2, 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 dlasv2; + var main; + + main = require( './../lib/dlasv2.js' ); + + dlasv2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlasv2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js new file mode 100644 index 000000000000..c840b954eaa2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlasv2 = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlasv2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dlasv2.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access pattern to store computed values', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 999.9, 1.2125424343860751, 999.9, 6.597707241520579, 999.9, 0.8090383403577232, 999.9, 0.5877558709457702, 999.9, 0.2452483296822559, 999.9, 0.9694602914962858 ] ); + out = new Float64Array( [ 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0 ] ); + out = dlasv2( 4.0, 5.0, 2.0, out, 2, 1 ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 999.9, 0.9694602914962858, 999.9, 0.2452483296822559, 999.9, 0.5877558709457702, 999.9, 0.8090383403577232, 999.9, 6.597707241520579, 999.9, 1.2125424343860751 ] ); + out = new Float64Array( [ 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0 ] ); + out = dlasv2( 4.0, 5.0, 2.0, out, -2, out.length-1 ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); From ec39c56389ce458f4a0358edd89beec5349dcd0a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 22 Aug 2024 09:24:58 +0530 Subject: [PATCH 06/16] chore: add type notation in jsdoc of ndarray --- lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js index f0d34d7ec6aa..8cc3686f2019 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js @@ -28,6 +28,7 @@ var base = require( './base.js' ); /** * Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. * +* @type {Function} * @param {number} F - the (0,0) element of matrix * @param {number} G - the (0,1) element of matrix * @param {number} H - the (1,1) element of matrix From bd334569126f811b153661915159233b58cd06fb Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 12 May 2026 23:00:20 +0530 Subject: [PATCH 07/16] chore: update the `signum` implementation and improve test coverage --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlasv2/lib/base.js | 41 +++++------------ .../lapack/base/dlasv2/test/test.dlasv2.js | 44 +++++++++++++++++++ 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js index 7bbce99903f4..1180585a668c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -22,28 +22,10 @@ // MODULES // -var signum = require( '@stdlib/math/base/special/signum' ); +var dlamch = require( '@stdlib/lapack/base/dlamch' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var abs = require( '@stdlib/math/base/special/abs' ); - - -// FUNCTIONS // - -/** -* Returns `x` multipled by `signum( y )`. -* -* @private -* @param {number} x - scalar element -* @param {number} y - scalar element -* @returns {number} computed value -* -* @example -* var out = sign( 1.0, -0.9 ); -* // out => -1.0 -*/ -function sign( x, y ) { - return x * signum( y ); -} +var copysign = require( '@stdlib/math/base/special/copysign' ); // MAIN // @@ -62,6 +44,7 @@ function sign( x, y ) { * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); @@ -139,9 +122,7 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { gasmal = true; if ( ga > fa ) { PMAX = 2; - - // TODO: replace 1.11022302E-16 with dlamch( 'E' ) - if ( ( fa / ga ) < 1.11022302E-16 ) { + if ( ( fa / ga ) < dlamch( 'E' ) ) { // Case of very large GA gasmal = false; ssmax = ga; @@ -193,9 +174,9 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { if ( mm === 0.0 ) { // Note that M is very tiny if ( l === 0.0 ) { - t = sign( 2.0, ft ) * sign( 1.0, gt ); + t = copysign( 2.0, ft ) * copysign( 1.0, gt ); } else { - t = ( ( gt / sign( d, ft ) ) + ( m / t ) ); + t = ( ( gt / copysign( d, ft ) ) + ( m / t ) ); } } else { t = ( ( m / ( s + t ) ) + ( m / ( r + l ) ) ) * ( 1.0 + a ); @@ -221,16 +202,16 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { // Correct signs 0f ssmax and ssmin if ( PMAX === 1 ) { - tsign = sign( 1.0, csr ) * sign( 1.0, csl ) * sign( 1.0, F ); + tsign = copysign( 1.0, csr ) * copysign( 1.0, csl ) * copysign( 1.0, F ); } if ( PMAX === 2 ) { - tsign = sign( 1.0, snr ) * sign( 1.0, csl ) * sign( 1.0, G ); + tsign = copysign( 1.0, snr ) * copysign( 1.0, csl ) * copysign( 1.0, G ); } if ( PMAX === 3 ) { - tsign = sign( 1.0, snr ) * sign( 1.0, snl ) * sign( 1.0, H ); + tsign = copysign( 1.0, snr ) * copysign( 1.0, snl ) * copysign( 1.0, H ); } - ssmax = sign( ssmax, tsign ); - ssmin = sign( ssmin, tsign * sign( 1.0, F ) * sign( 1.0, H ) ); + ssmax = copysign( ssmax, tsign ); + ssmin = copysign( ssmin, tsign * copysign( 1.0, F ) * copysign( 1.0, H ) ); out[ offsetOut ] = ssmin; out[ offsetOut + strideOut ] = ssmax; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js index 5c985596e01e..320839307ae0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -133,3 +133,47 @@ tape( 'the function correctly computes svd of diagonal matrix', function test( t isApprox( t, out, expected, 1.0 ); t.end(); }); + +tape( 'the function correctly computes svd of diagonal matrix with a very large `G`', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 2.0e-20, 1.0e+20, 1.0, 2.0e-20, 1.0e-20, 1.0 ] ); + out = new Float64Array( 6 ); + out = dlasv2( 2.0, 1.0e+20, 1.0, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes svd of diagonal matrix with a very large `G` when `H` is greater than 1', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 6.0e-20, 1.0e+20, 1.0, 2.0e-20, 3.0e-20, 1.0 ] ); + out = new Float64Array( 6 ); + out = dlasv2( 2.0, 1.0e+20, 3.0, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correctly computes svd of diagonal matrix with an infinite `F`', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 1.0, Infinity, 0.0, 1.0, 0.0, 1.0 ] ); + out = new Float64Array( 6 ); + out = dlasv2( Infinity, 2.0, 1.0, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes svd of diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal', function test( t ) { + var expected; + var out; + + expected = new Float64Array( [ 3.0, 3.0, 0.7071067811865475, 0.7071067811865475, 0.7071067811865475, 0.7071067811865475 ] ); + out = new Float64Array( 6 ); + out = dlasv2( 3.0, 5e-324, 3.0, out ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); From d407c46853a0cb51dfc2b2da6a61e02d7266053f Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 12 May 2026 23:44:09 +0530 Subject: [PATCH 08/16] fix: lint errors --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/dlasv2/README.md | 4 ++-- .../@stdlib/lapack/base/dlasv2/benchmark/benchmark.js | 2 +- .../lapack/base/dlasv2/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dlasv2/docs/types/index.d.ts | 6 +++++- .../@stdlib/lapack/base/dlasv2/docs/types/test.ts | 2 +- .../@stdlib/lapack/base/dlasv2/examples/index.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js | 3 ++- lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js | 4 +++- lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js | 3 ++- .../@stdlib/lapack/base/dlasv2/test/test.dlasv2.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js | 2 +- .../@stdlib/lapack/base/dlasv2/test/test.ndarray.js | 2 +- 14 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md index 951666ccc00a..542ab2596a93 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +Copyright (c) 2026 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ limitations under the License. > Compute singular value decomposition of a 2x2 triangular matrix. -
+
## Usage diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js index c8576c644c81..dc9c4ead91f3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js index 86c149516c21..fde1cdb37843 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts index 045747286775..e7aff970904f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ interface Routine { * * @example * var Float64Array = require( '@stdlib/array/float64' ); + * * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out ); @@ -55,6 +56,7 @@ interface Routine { * * @example * var Float64Array = require( '@stdlib/array/float64' ); + * * var out = new Float64Array( 6 ); * * out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); @@ -74,6 +76,7 @@ interface Routine { * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out ); @@ -81,6 +84,7 @@ interface Routine { * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts index fdc8f1c98282..1adfd989e517 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js index c9b8029f0dd7..d5c5d0d34805 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js index 1180585a668c..200a3494cc2f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js index 0350ec64d253..d8216b315ac8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ var base = require( './base.js' ); * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js index 3dec6d397639..80434bba009d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ * @example * var Float64Array = require( '@stdlib/array/float64' ); * var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out ); @@ -34,6 +35,7 @@ * @example * var Float64Array = require( '@stdlib/array/float64' ); * var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js index ca8687ef6581..79357225880a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js index 8cc3686f2019..f46b4dccb10e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ var base = require( './base.js' ); * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js index 320839307ae0..c4d63b44dd6e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js index d9cb0e889549..82644bcbfe4d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js index c840b954eaa2..a65648e7829e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 691c1a9dcaabda9f194f674cc628443c3a2be595 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 12 May 2026 23:51:06 +0530 Subject: [PATCH 09/16] fix: module name in package.json --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/dlasv2/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json index 2268df5c3784..592afc41ea8a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/lapack/base/dlaswp", + "name": "@stdlib/lapack/base/dlasv2", "version": "0.0.0", "description": "Compute singular value decomposition of a 2x2 triangular matrix.", "license": "Apache-2.0", From f12a2af5d7070c03c621ce593e69999b8016afd9 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Thu, 14 May 2026 22:21:35 +0530 Subject: [PATCH 10/16] refactor: major updates to tests, benchmarks and README file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlasv2/README.md | 66 ++- .../lapack/base/dlasv2/benchmark/benchmark.js | 80 +-- .../dlasv2/benchmark/benchmark.ndarray.js | 80 +-- .../@stdlib/lapack/base/dlasv2/docs/repl.txt | 57 ++- .../lapack/base/dlasv2/docs/types/index.d.ts | 36 +- .../lapack/base/dlasv2/examples/index.js | 5 +- .../@stdlib/lapack/base/dlasv2/lib/base.js | 34 +- .../@stdlib/lapack/base/dlasv2/lib/dlasv2.js | 12 +- .../@stdlib/lapack/base/dlasv2/lib/index.js | 10 +- .../@stdlib/lapack/base/dlasv2/lib/ndarray.js | 15 +- .../@stdlib/lapack/base/dlasv2/package.json | 2 +- .../fixtures/decreasing_order_elements.json | 15 + .../dlasv2/test/fixtures/diagonal_matrix.json | 15 + .../dlasv2/test/fixtures/g_gt_f_and_h.json | 15 + .../fixtures/increasing_order_elements.json | 15 + .../test/fixtures/large_g_and_h_gt_1.json | 15 + .../test/fixtures/large_g_diagonal.json | 15 + .../decreasing_order_elements.json | 21 + .../large_strides/diagonal_matrix.json | 21 + .../fixtures/large_strides/g_gt_f_and_h.json | 21 + .../increasing_order_elements.json | 21 + .../large_strides/large_g_and_h_gt_1.json | 21 + .../large_strides/large_g_diagonal.json | 21 + .../large_strides/small_g_and_f_eq_h.json | 21 + .../decreasing_order_elements.json | 15 + .../negative_strides/diagonal_matrix.json | 15 + .../negative_strides/g_gt_f_and_h.json | 15 + .../increasing_order_elements.json | 15 + .../negative_strides/large_g_and_h_gt_1.json | 15 + .../negative_strides/large_g_diagonal.json | 15 + .../negative_strides/small_g_and_f_eq_h.json | 15 + .../offsets/decreasing_order_elements.json | 16 + .../fixtures/offsets/diagonal_matrix.json | 16 + .../test/fixtures/offsets/g_gt_f_and_h.json | 16 + .../offsets/increasing_order_elements.json | 16 + .../fixtures/offsets/large_g_and_h_gt_1.json | 16 + .../fixtures/offsets/large_g_diagonal.json | 16 + .../fixtures/offsets/small_g_and_f_eq_h.json | 16 + .../test/fixtures/small_g_and_f_eq_h.json | 15 + .../lapack/base/dlasv2/test/test.dlasv2.js | 113 +++-- .../lapack/base/dlasv2/test/test.ndarray.js | 456 +++++++++++++++++- 41 files changed, 1189 insertions(+), 246 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/decreasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/diagonal_matrix.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/g_gt_f_and_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/increasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_and_h_gt_1.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_diagonal.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/decreasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/diagonal_matrix.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/g_gt_f_and_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/increasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_and_h_gt_1.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_diagonal.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/small_g_and_f_eq_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/decreasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/diagonal_matrix.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/g_gt_f_and_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/increasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_and_h_gt_1.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_diagonal.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/small_g_and_f_eq_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/decreasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/diagonal_matrix.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/g_gt_f_and_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/increasing_order_elements.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_and_h_gt_1.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_diagonal.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/small_g_and_f_eq_h.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/small_g_and_f_eq_h.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md index 542ab2596a93..5606013db6d6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md @@ -20,7 +20,37 @@ limitations under the License. # dlasv2 -> Compute singular value decomposition of a 2x2 triangular matrix. +> Compute the singular value decomposition of a 2x2 upper triangular matrix. + +
+ +The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by - + + + +```math +\left[\begin{array}{rr}\mathrm{CSL} & \mathrm{SNL} \\ +-\mathrm{SNL} & \mathrm{CSL}\end{array}\right] + +\left[\begin{array}{rr}F & G \\ +0 & H\end{array}\right] + +\left[\begin{array}{rr}\mathrm{CSR} & -\mathrm{SNR} \\ +\mathrm{SNR} & \mathrm{CSR}\end{array}\right] + += + +\left[\begin{array}{rr}\mathrm{SSMAX} & 0 \\ +0 & \mathrm{SSMIN}\end{array}\right] +``` + + + +where `CSL`,`SNL`,`CSR`,`SNR` define orthogonal rotations and $\mathrm{SSMAX}^2, \mathrm{SSMIN}^2$ are the eigenvalues of $A^{T}A$. + +
+ +
@@ -32,14 +62,17 @@ var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); #### dlasv2( F, G, H, out ) -Computes singular value decomposition of a 2x2 triangular matrix. +Computes the singular value decomposition of a 2x2 upper triangular matrix. ```javascript var Float64Array = require( '@stdlib/array/float64' ); var out = new Float64Array( 6 ); -out = dlasv2( 2.0, 3.0, 4.0, out ); -// out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +var v = dlasv2( 2.0, 3.0, 4.0, out ); +// returns [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] + +var bool = ( v === out ); +// returns true ``` The function has the following parameters: @@ -47,7 +80,9 @@ The function has the following parameters: - **F**: the (0,0) element of matrix. - **G**: the (0,1) element of matrix. - **H**: the (1,1) element of matrix. -- **out**: [`Float64Array`][mdn-float64array] output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` respectively. +- **out**: [`Float64Array`][@stdlib/array/float64] output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and `CSL` respectively. + +On return, `abs(SSMAX)` is the larger singular value, `abs(SSMIN)` is the smaller singular value, and (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)` as described in the decomposition. Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -63,19 +98,19 @@ var OUT0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var OUT1 = new Float64Array( OUT0.buffer, OUT0.BYTES_PER_ELEMENT*1 ); // start at 2nd element dlasv2( 2.0, 3.0, 4.0, OUT1 ); -// OUT0 => [ 0.0, 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +// OUT0 => [ 0.0, ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] ``` #### dlasv2.ndarray( F, G, H, out, strideOut, offsetOut ) -Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. +Computes the singular value decomposition of a 2x2 upper triangular matrix using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); var out = new Float64Array( 6 ); -out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); -// out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +// out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] ``` The function has the following additional parameters: @@ -89,10 +124,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ); +var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ); -// out => [ 0.0, 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ); +// out => [ 0.0, ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] ```
@@ -121,7 +156,10 @@ var dlasv2 = require( '@stdlib/lapack/base/dlasv2' ); var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -out = dlasv2( 2.0, 3.0, 4.0, out ); +dlasv2( 1.0, 1e6, 2.0, out ); +console.log( out ); + +dlasv2.ndarray( 1.0, 1e6, 2.0, out, 1, 0 ); console.log( out ); ``` @@ -215,7 +253,7 @@ TODO [lapack-dlasv2]: https://www.netlib.org/lapack/explore-html/d8/da7/group__lasv2_ga96f9f244300d82921950e2c393b4b20f.html#ga96f9f244300d82921950e2c393b4b20f -[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array +[@stdlib/array/float64]: https://stdlib.io/docs/api/latest/@stdlib/array/float64 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js index dc9c4ead91f3..ebc3947e17b3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js @@ -21,72 +21,40 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var dlasv2 = require( './../lib/dlasv2.js' ); -// VARIABLES // +// MAIN // -var options = { - 'dtype': 'float64' -}; +bench( format( '%s', pkg ), function benchmark( b ) { + var out; + var f; + var g; + var h; + var i; + out = new Float64Array( 6 ); -// FUNCTIONS // + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = uniform( -10.0, 10.0 ); + g = uniform( -10.0, 10.0 ); + h = uniform( -10.0, 10.0 ); -/** -* Creates a benchmark function. -* -* @private -* @returns {Function} benchmark function -*/ -function createBenchmark( ) { - var out = uniform( 6, 0.0, 100.0, options ); - return benchmark; - - function benchmark( b ) { - var d; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - d = dlasv2( out[ 0 ], out[ 2 ], out[ 1 ], out ); - if ( isnan( d[ i%out.length ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( d[ i%out.length ] ) ) { + dlasv2( f, g, h, out ); + if ( isnan( out[ i%out.length ] ) ) { b.fail( 'should not return NaN' ); } - b.pass( 'benchmark finished' ); - b.end(); } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - f = createBenchmark(); - bench( pkg, f ); + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); } -} - -main(); + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js index fde1cdb37843..8b1982743613 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js @@ -21,72 +21,40 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var dlasv2 = require( './../lib/ndarray.js' ); -// VARIABLES // +// MAIN // -var options = { - 'dtype': 'float64' -}; +bench( format( '%s', pkg ), function benchmark( b ) { + var out; + var f; + var g; + var h; + var i; + out = new Float64Array( 6 ); -// FUNCTIONS // + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = uniform( -10.0, 10.0 ); + g = uniform( -10.0, 10.0 ); + h = uniform( -10.0, 10.0 ); -/** -* Creates a benchmark function. -* -* @private -* @returns {Function} benchmark function -*/ -function createBenchmark( ) { - var out = uniform( 6, 0.0, 100.0, options ); - return benchmark; - - function benchmark( b ) { - var d; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - d = dlasv2( out[ 0 ], out[ 2 ], out[ 1 ], out, 1, 0 ); - if ( isnan( d[ i%out.length ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( d[ i%out.length ] ) ) { + dlasv2( f, g, h, out, 1, 0 ); + if ( isnan( out[ i%out.length ] ) ) { b.fail( 'should not return NaN' ); } - b.pass( 'benchmark finished' ); - b.end(); } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - f = createBenchmark(); - bench( pkg+':ndarray', f ); + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); } -} - -main(); + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt index 522919449eda..2d7095b4e433 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( F, G, H, out ) - Computes singular value decomposition of a 2x2 triangular matrix. + Computes the singular value decomposition of a 2x2 upper triangular matrix. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -23,33 +23,43 @@ Returns ------- out: Float64Array - Mutated array. + Output array. + + Note that on return, `abs(SSMAX)` is the larger singular value, + `abs(SSMIN)` is the smaller singular value, and (`CSL`,`SNL`) + and (`CSR`,`SNR`) are the left and right singular vectors for + `abs(SSMAX)`. Examples -------- > var out = new {{alias:@stdlib/array/float64}}( 6 ); > {{alias}}( 2.0, 3.0, 4.0, out ); > out[ 0 ] - 1.5513263285176897 + ~1.5513 > out[ 1 ] - 5.1568776039816795 + ~5.1569 > out[ 2 ] - 0.9664996487646696 + ~0.9665 > out[ 3 ] - 0.25666793515702424 + ~0.2567 > out[ 4 ] - 0.7496781758158659 + ~0.7497 > out[ 5 ] - 0.6618025632357402 + ~0.6618 {{alias}}.ndarray( F, G, H, out, strideOut, offsetOut ) - Computes singular value decomposition of a 2x2 triangular matrix using - alternative indexing semantics. + Computes the singular value decomposition of a 2x2 upper triangular + matrix using alternative indexing semantics. + + Note that on return, `abs(SSMAX)` is the larger singular value, + `abs(SSMIN)` is the smaller singular value, and (`CSL`,`SNL`) + and (`CSR`,`SNR`) are the left and right singular vectors for + `abs(SSMAX)`. While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on starting - indices. + buffer, the offset parameter support indexing semantics based on + a starting index. Parameters ---------- @@ -63,8 +73,8 @@ The (1,1) element of matrix. out: Float64Array - Output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, and - `CSL` respectively. + Output array containing `SSMIN`, `SSMAX`, `SNR`, `CSR`, `SNL`, + and `CSL` respectively. strideOut: integer Stride length for `Out`. @@ -75,24 +85,29 @@ Returns ------- out: Float64Array - Mutated array. + Output array. + + Note that on return, `abs(SSMAX)` is the larger singular value, + `abs(SSMIN)` is the smaller singular value, and (`CSL`,`SNL`) + and (`CSR`,`SNR`) are the left and right singular vectors for + `abs(SSMAX)`. Examples -------- > var out = new {{alias:@stdlib/array/float64}}( 6 ); > {{alias}}.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); > out[ 0 ] - 1.5513263285176897 + ~1.5513 > out[ 1 ] - 5.1568776039816795 + ~5.1569 > out[ 2 ] - 0.9664996487646696 + ~0.9665 > out[ 3 ] - 0.25666793515702424 + ~0.2567 > out[ 4 ] - 0.7496781758158659 + ~0.7497 > out[ 5 ] - 0.6618025632357402 + ~0.6618 See Also -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts index e7aff970904f..e95142dd5172 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts @@ -25,7 +25,13 @@ */ interface Routine { /** - * Computes singular value decomposition of a 2x2 triangular matrix. + * Computes the singular value decomposition of a 2x2 upper triangular matrix. + * + * ## Notes + * + * - `abs(SSMAX)` is the larger singular value. + * - `abs(SSMIN)` is the smaller singular value. + * - (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)`. * * @param F - the (0,0) element of matrix * @param G - the (0,1) element of matrix @@ -38,13 +44,19 @@ interface Routine { * * var out = new Float64Array( 6 ); * - * out = dlasv2( 2.0, 3.0, 4.0, out ); + * dlasv2( 2.0, 3.0, 4.0, out ); * // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] */ ( F: number, G: number, H: number, out: Float64Array ): Float64Array; /** - * Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. + * Computes the singular value decomposition of a 2x2 upper triangular matrix using alternative indexing semantics. + * + * ## Notes + * + * - `abs(SSMAX)` is the larger singular value. + * - `abs(SSMIN)` is the smaller singular value. + * - (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)`. * * @param F - the (0,0) element of matrix * @param G - the (0,1) element of matrix @@ -59,14 +71,20 @@ interface Routine { * * var out = new Float64Array( 6 ); * - * out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); + * dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); * // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] */ ndarray( F: number, G: number, H: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; } /** -* Computes singular value decomposition of a 2x2 triangular matrix. +* Computes the singular value decomposition of a 2x2 upper triangular matrix. +* +* ## Notes +* +* - `abs(SSMAX)` is the larger singular value. +* - `abs(SSMIN)` is the smaller singular value. +* - (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)`. * * @param F - the (0,0) element of matrix * @param G - the (0,1) element of matrix @@ -79,16 +97,16 @@ interface Routine { * * var out = new Float64Array( 6 ); * -* out = dlasv2( 2.0, 3.0, 4.0, out ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* dlasv2( 2.0, 3.0, 4.0, out ); +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var out = new Float64Array( 6 ); * -* out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ declare var dlasv2: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js index d5c5d0d34805..25b0ab5ef41f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js @@ -23,5 +23,8 @@ var dlasv2 = require( './../lib/' ); var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -out = dlasv2( 2.0, 3.0, 4.0, out ); +dlasv2( 1.0, 1e6, 2.0, out ); +console.log( out ); + +dlasv2.ndarray( 1.0, 1e6, 2.0, out, 1, 0 ); console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js index 200a3494cc2f..71608646f3b0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -28,10 +28,21 @@ var abs = require( '@stdlib/math/base/special/abs' ); var copysign = require( '@stdlib/math/base/special/copysign' ); +// VARIABLES // + +var EPS = dlamch( 'E' ); + + // MAIN // /** -* Computes singular value decomposition of a 2x2 triangular matrix. +* Computes the singular value decomposition of a 2x2 upper triangular matrix. +* +* ## Notes +* +* - `abs(SSMAX)` is the larger singular value. +* - `abs(SSMIN)` is the smaller singular value. +* - (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)`. * * @private * @param {number} F - the (0,0) element of matrix @@ -47,8 +58,8 @@ var copysign = require( '@stdlib/math/base/special/copysign' ); * * var out = new Float64Array( 6 ); * -* out = dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ function dlasv2( F, G, H, out, strideOut, offsetOut ) { var gasmal; @@ -87,14 +98,13 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { ht = H; ha = abs( ht ); - // PMAX points to the maximum absolute element of matrix - - // PMAX = 1 if F largest in absolute values - - // PMAX = 2 if G largest in absolute values - - // PMAX = 3 if H largest in absolute values - + /* + * PMAX points to the maximum absolute element of the matrix. + * + * PMAX = 1 if F is the largest in absolute value + * PMAX = 2 if G is the largest in absolute value + * PMAX = 3 if H is the largest in absolute value + */ PMAX = 1; swap = ha > fa; if ( swap ) { @@ -122,7 +132,7 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { gasmal = true; if ( ga > fa ) { PMAX = 2; - if ( ( fa / ga ) < dlamch( 'E' ) ) { + if ( ( fa / ga ) < EPS ) { // Case of very large GA gasmal = false; ssmax = ga; diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js index d8216b315ac8..e19ebb9a93b8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/dlasv2.js @@ -26,7 +26,13 @@ var base = require( './base.js' ); // MAIN // /** -* Computes singular value decomposition of a 2x2 triangular matrix. +* Computes singular value decomposition of a 2x2 upper triangular matrix. +* +* ## Notes +* +* - `abs(SSMAX)` is the larger singular value. +* - `abs(SSMIN)` is the smaller singular value. +* - (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)`. * * @param {number} F - the (0,0) element of matrix * @param {number} G - the (0,1) element of matrix @@ -39,8 +45,8 @@ var base = require( './base.js' ); * * var out = new Float64Array( 6 ); * -* out = dlasv2( 2.0, 3.0, 4.0, out ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* dlasv2( 2.0, 3.0, 4.0, out ); +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ function dlasv2( F, G, H, out ) { return base( F, G, H, out, 1, 0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js index 80434bba009d..60bd4a5a4263 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to compute singular value decomposition of a 2x2 triangular matrix. +* LAPACK routine to compute the singular value decomposition of a 2x2 upper triangular matrix. * * @module @stdlib/lapack/base/dlasv2 * @@ -29,8 +29,8 @@ * * var out = new Float64Array( 6 ); * -* out = dlasv2( 2.0, 3.0, 4.0, out ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* dlasv2( 2.0, 3.0, 4.0, out ); +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -38,8 +38,8 @@ * * var out = new Float64Array( 6 ); * -* out = dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js index f46b4dccb10e..ec346777c7fa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/ndarray.js @@ -26,9 +26,14 @@ var base = require( './base.js' ); // MAIN // /** -* Computes singular value decomposition of a 2x2 triangular matrix using alternative indexing semantics. +* Computes the singular value decomposition of a 2x2 upper triangular matrix using alternative indexing semantics. +* +* ## Notes +* +* - `abs(SSMAX)` is the larger singular value. +* - `abs(SSMIN)` is the smaller singular value. +* - (`CSL`,`SNL`) and (`CSR`,`SNR`) are the left and right singular vectors for `abs(SSMAX)`. * -* @type {Function} * @param {number} F - the (0,0) element of matrix * @param {number} G - the (0,1) element of matrix * @param {number} H - the (1,1) element of matrix @@ -43,9 +48,11 @@ var base = require( './base.js' ); * var out = new Float64Array( 6 ); * * out = dlasv2( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] +* // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ -var dlasv2 = base; +function dlasv2( F, G, H, out, strideOut, offsetOut ) { + return base( F, G, H, out, strideOut, offsetOut ); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json index 592afc41ea8a..df04f78241e7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dlasv2", "version": "0.0.0", - "description": "Compute singular value decomposition of a 2x2 triangular matrix.", + "description": "Compute the singular value decomposition of a 2x2 upper triangular matrix.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/decreasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/decreasing_order_elements.json new file mode 100644 index 000000000000..35409522867c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/decreasing_order_elements.json @@ -0,0 +1,15 @@ +{ + "F": 4.0, + "G": 3.0, + "H": 2.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 1.5513263285176897, + 5.1568776039816795, + 0.6618025632357402, + 0.7496781758158659, + 0.25666793515702424, + 0.9664996487646696 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/diagonal_matrix.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/diagonal_matrix.json new file mode 100644 index 000000000000..814517855e8e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/diagonal_matrix.json @@ -0,0 +1,15 @@ +{ + "F": 2.0, + "G": 0.0, + "H": -12.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 2.0, + -12.0, + 1.0, + 0.0, + 1.0, + 0.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/g_gt_f_and_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/g_gt_f_and_h.json new file mode 100644 index 000000000000..44ff548c100a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/g_gt_f_and_h.json @@ -0,0 +1,15 @@ +{ + "F": 4.0, + "G": 5.0, + "H": 2.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 1.2125424343860751, + 6.597707241520579, + 0.8090383403577232, + 0.5877558709457702, + 0.2452483296822559, + 0.9694602914962858 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/increasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/increasing_order_elements.json new file mode 100644 index 000000000000..9925344bda65 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/increasing_order_elements.json @@ -0,0 +1,15 @@ +{ + "F": 2.0, + "G": 3.0, + "H": 4.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 1.5513263285176897, + 5.1568776039816795, + 0.9664996487646696, + 0.25666793515702424, + 0.7496781758158659, + 0.6618025632357402 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_and_h_gt_1.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_and_h_gt_1.json new file mode 100644 index 000000000000..0bff731a8a68 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_and_h_gt_1.json @@ -0,0 +1,15 @@ +{ + "F": 2.0, + "G": 1.0E+20, + "H": 3.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 6.0E-20, + 1.0E+20, + 1.0, + 2.0E-20, + 3.0E-20, + 1.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_diagonal.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_diagonal.json new file mode 100644 index 000000000000..ca5f429368ff --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_g_diagonal.json @@ -0,0 +1,15 @@ +{ + "F": 2.0, + "G": 1.0E+20, + "H": 1.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 2.0E-20, + 1.0E+20, + 1.0, + 2.0E-20, + 1.0E-20, + 1.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/decreasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/decreasing_order_elements.json new file mode 100644 index 000000000000..b321ae33bcf7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/decreasing_order_elements.json @@ -0,0 +1,21 @@ +{ + "F": 4, + "G": 3, + "H": 2, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 1.5513263285176897, + 9999, + 5.1568776039816795, + 9999, + 0.6618025632357402, + 9999, + 0.7496781758158659, + 9999, + 0.25666793515702424, + 9999, + 0.9664996487646696, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/diagonal_matrix.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/diagonal_matrix.json new file mode 100644 index 000000000000..f299d333f323 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/diagonal_matrix.json @@ -0,0 +1,21 @@ +{ + "F": 2, + "G": 0, + "H": -12, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 2, + 9999, + -12, + 9999, + 1, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/g_gt_f_and_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/g_gt_f_and_h.json new file mode 100644 index 000000000000..c3c181a0fdf9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/g_gt_f_and_h.json @@ -0,0 +1,21 @@ +{ + "F": 4, + "G": 5, + "H": 2, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 1.2125424343860751, + 9999, + 6.597707241520579, + 9999, + 0.8090383403577232, + 9999, + 0.5877558709457702, + 9999, + 0.2452483296822559, + 9999, + 0.9694602914962858, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/increasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/increasing_order_elements.json new file mode 100644 index 000000000000..f8ebcd12a5b4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/increasing_order_elements.json @@ -0,0 +1,21 @@ +{ + "F": 2, + "G": 3, + "H": 4, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 1.5513263285176897, + 9999, + 5.1568776039816795, + 9999, + 0.9664996487646696, + 9999, + 0.25666793515702424, + 9999, + 0.7496781758158659, + 9999, + 0.6618025632357402, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_and_h_gt_1.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_and_h_gt_1.json new file mode 100644 index 000000000000..2c45c3d30921 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_and_h_gt_1.json @@ -0,0 +1,21 @@ +{ + "F": 2, + "G": 100000000000000000000, + "H": 3, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 6e-20, + 9999, + 100000000000000000000, + 9999, + 1, + 9999, + 2e-20, + 9999, + 3e-20, + 9999, + 1, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_diagonal.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_diagonal.json new file mode 100644 index 000000000000..192510267c14 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/large_g_diagonal.json @@ -0,0 +1,21 @@ +{ + "F": 2, + "G": 100000000000000000000, + "H": 1, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 2e-20, + 9999, + 100000000000000000000, + 9999, + 1, + 9999, + 2e-20, + 9999, + 1e-20, + 9999, + 1, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/small_g_and_f_eq_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/small_g_and_f_eq_h.json new file mode 100644 index 000000000000..13e8e65a7ec3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/large_strides/small_g_and_f_eq_h.json @@ -0,0 +1,21 @@ +{ + "F": 3, + "G": 5e-324, + "H": 3, + "strideOut": 2, + "offsetOut": 0, + "out": [ + 3, + 9999, + 3, + 9999, + 0.7071067811865475, + 9999, + 0.7071067811865475, + 9999, + 0.7071067811865475, + 9999, + 0.7071067811865475, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/decreasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/decreasing_order_elements.json new file mode 100644 index 000000000000..51d6510a1774 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/decreasing_order_elements.json @@ -0,0 +1,15 @@ +{ + "F": 4, + "G": 3, + "H": 2, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 0.9664996487646696, + 0.25666793515702424, + 0.7496781758158659, + 0.6618025632357402, + 5.1568776039816795, + 1.5513263285176897 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/diagonal_matrix.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/diagonal_matrix.json new file mode 100644 index 000000000000..9e7b8cbed009 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/diagonal_matrix.json @@ -0,0 +1,15 @@ +{ + "F": 2, + "G": 0, + "H": -12, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 0, + 1, + 0, + 1, + -12, + 2 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/g_gt_f_and_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/g_gt_f_and_h.json new file mode 100644 index 000000000000..1c99e07a1c96 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/g_gt_f_and_h.json @@ -0,0 +1,15 @@ +{ + "F": 4.0, + "G": 5.0, + "H": 2.0, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 0.9694602914962858, + 0.2452483296822559, + 0.5877558709457702, + 0.8090383403577232, + 6.597707241520579, + 1.2125424343860751 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/increasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/increasing_order_elements.json new file mode 100644 index 000000000000..b16c6019c733 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/increasing_order_elements.json @@ -0,0 +1,15 @@ +{ + "F": 2, + "G": 3, + "H": 4, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 0.6618025632357402, + 0.7496781758158659, + 0.25666793515702424, + 0.9664996487646696, + 5.1568776039816795, + 1.5513263285176897 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_and_h_gt_1.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_and_h_gt_1.json new file mode 100644 index 000000000000..77c59e41a96d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_and_h_gt_1.json @@ -0,0 +1,15 @@ +{ + "F": 2, + "G": 100000000000000000000, + "H": 3, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 1, + 3e-20, + 2e-20, + 1, + 100000000000000000000, + 6e-20 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_diagonal.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_diagonal.json new file mode 100644 index 000000000000..1a1bde69d0b0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/large_g_diagonal.json @@ -0,0 +1,15 @@ +{ + "F": 2, + "G": 100000000000000000000, + "H": 1, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 1, + 1e-20, + 2e-20, + 1, + 100000000000000000000, + 2e-20 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/small_g_and_f_eq_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/small_g_and_f_eq_h.json new file mode 100644 index 000000000000..add225b46762 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/negative_strides/small_g_and_f_eq_h.json @@ -0,0 +1,15 @@ +{ + "F": 3, + "G": 5e-324, + "H": 3, + "strideOut": -1, + "offsetOut": 5, + "out": [ + 0.7071067811865475, + 0.7071067811865475, + 0.7071067811865475, + 0.7071067811865475, + 3, + 3 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/decreasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/decreasing_order_elements.json new file mode 100644 index 000000000000..31f88d89ed1e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/decreasing_order_elements.json @@ -0,0 +1,16 @@ +{ + "F": 4, + "G": 3, + "H": 2, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 1.5513263285176897, + 5.1568776039816795, + 0.6618025632357402, + 0.7496781758158659, + 0.25666793515702424, + 0.9664996487646696 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/diagonal_matrix.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/diagonal_matrix.json new file mode 100644 index 000000000000..3c6fe9fe9c62 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/diagonal_matrix.json @@ -0,0 +1,16 @@ +{ + "F": 2, + "G": 0, + "H": -12, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 2, + -12, + 1, + 0, + 1, + 0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/g_gt_f_and_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/g_gt_f_and_h.json new file mode 100644 index 000000000000..3d432ed52fc5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/g_gt_f_and_h.json @@ -0,0 +1,16 @@ +{ + "F": 4, + "G": 5, + "H": 2, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 1.2125424343860751, + 6.597707241520579, + 0.8090383403577232, + 0.5877558709457702, + 0.2452483296822559, + 0.9694602914962858 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/increasing_order_elements.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/increasing_order_elements.json new file mode 100644 index 000000000000..b864705ad0f2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/increasing_order_elements.json @@ -0,0 +1,16 @@ +{ + "F": 2, + "G": 3, + "H": 4, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 1.5513263285176897, + 5.1568776039816795, + 0.9664996487646696, + 0.25666793515702424, + 0.7496781758158659, + 0.6618025632357402 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_and_h_gt_1.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_and_h_gt_1.json new file mode 100644 index 000000000000..c1ac1cf0d8ca --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_and_h_gt_1.json @@ -0,0 +1,16 @@ +{ + "F": 2, + "G": 100000000000000000000, + "H": 3, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 6e-20, + 100000000000000000000, + 1, + 2e-20, + 3e-20, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_diagonal.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_diagonal.json new file mode 100644 index 000000000000..c5830d834549 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/large_g_diagonal.json @@ -0,0 +1,16 @@ +{ + "F": 2, + "G": 100000000000000000000, + "H": 1, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 2e-20, + 100000000000000000000, + 1, + 2e-20, + 1e-20, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/small_g_and_f_eq_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/small_g_and_f_eq_h.json new file mode 100644 index 000000000000..a1cdea93f161 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/offsets/small_g_and_f_eq_h.json @@ -0,0 +1,16 @@ +{ + "F": 3, + "G": 5e-324, + "H": 3, + "strideOut": 1, + "offsetOut": 1, + "out": [ + 9999, + 3, + 3, + 0.7071067811865475, + 0.7071067811865475, + 0.7071067811865475, + 0.7071067811865475 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/small_g_and_f_eq_h.json b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/small_g_and_f_eq_h.json new file mode 100644 index 000000000000..1cd2c29cbca2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/fixtures/small_g_and_f_eq_h.json @@ -0,0 +1,15 @@ +{ + "F": 3.0, + "G": 5.0E-324, + "H": 3.0, + "strideOut": 1, + "offsetOut": 0, + "out": [ + 3.0, + 3.0, + 0.7071067811865475, + 0.7071067811865475, + 0.7071067811865475, + 0.7071067811865475 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js index c4d63b44dd6e..51b6c20f803b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -22,11 +22,23 @@ var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); var dlasv2 = require( './../lib/dlasv2.js' ); +// FIXTURES // + +// NOTE: Expected outputs in fixtures were generated using the reference LAPACK Fortran implementation of DLASV2. +var INC_ORD_ELE = require( './fixtures/increasing_order_elements.json' ); +var DEC_ORD_ELE = require( './fixtures/decreasing_order_elements.json' ); +var LARGE_G = require( './fixtures/large_g_diagonal.json' ); +var LARGE_G_AND_H_GT_1 = require( './fixtures/large_g_and_h_gt_1.json' ); +var SMALL_G_AND_F_EQ_H = require( './fixtures/small_g_and_f_eq_h.json' ); +var DIA_MAT = require( './fixtures/diagonal_matrix.json' ); +var G_GT_F_AND_H = require( './fixtures/g_gt_f_and_h.json' ); + + // FUNCTIONS // /** @@ -39,8 +51,6 @@ var dlasv2 = require( './../lib/dlasv2.js' ); * @param {number} rtol - relative tolerance */ function isApprox( t, actual, expected, rtol ) { - var delta; - var tol; var i; t.strictEqual( actual.length, expected.length, 'returns expected value' ); @@ -48,9 +58,7 @@ function isApprox( t, actual, expected, rtol ) { if ( actual[ i ] === expected[ i ] ) { t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = rtol * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], rtol ), true, 'returns expected value' ); } } } @@ -69,111 +77,118 @@ tape( 'the function has an arity of 4', function test( t ) { t.end(); }); -tape( 'the function correctly computes svd of triangular matrix with elements in increasing order', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order', function test( t ) { var expected; + var data; var out; - out = new Float64Array( 6 ); - expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] ); - out = dlasv2( 2.0, 3.0, 4.0, out ); - isApprox( t, out, expected, 1.0 ); + data = INC_ORD_ELE; - expected = new Float64Array( [ -0.9522030268983716, 9.871844275289476, 0.999516648263737, -0.031088098102407546, 0.9517427779120455, 0.3068968632818896 ] ); - out = dlasv2( -1.0, 3.0, 9.4, out ); - isApprox( t, out, expected, 1.0 ); + out = new Float64Array( 6 ); - expected = new Float64Array( [ -3.518670509963777, -120.37955779052484, 0.5581876810704361, 0.8297147176597564, 0.019660445769845943, 0.9998067147564729 ] ); - out = dlasv2( -99.9, -67.124, -4.24, out ); + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function correctly computes svd of triangular matrix with elements in decreasing order', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795, 0.6618025632357402, 0.7496781758158659, 0.25666793515702424, 0.9664996487646696 ] ); - out = new Float64Array( 6 ); - out = dlasv2( 4.0, 3.0, 2.0, out ); - isApprox( t, out, expected, 1.0 ); + data = DEC_ORD_ELE; - expected = new Float64Array( [ -0.9522030268983716, 9.871844275289476, 0.3068968632818896, 0.9517427779120455, -0.031088098102407546, 0.999516648263737 ] ); - out = dlasv2( 9.4, 3.0, -1.0, out ); - isApprox( t, out, expected, 1.0 ); + out = new Float64Array( 6 ); - expected = new Float64Array( [ -3.518670509963777, -120.37955779052484, 0.9998067147564729, 0.019660445769845943, 0.8297147176597564, 0.5581876810704361 ] ); - out = dlasv2( -4.24, -67.124, -99.9, out ); + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function correcly computes svd of triangular matrix with parameter `G` greater than both', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H`', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 1.2125424343860751, 6.597707241520579, 0.8090383403577232, 0.5877558709457702, 0.2452483296822559, 0.9694602914962858 ] ); + data = G_GT_F_AND_H; + out = new Float64Array( 6 ); - out = dlasv2( 4.0, 5.0, 2.0, out ); + + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function correctly computes svd of diagonal matrix', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 2.0, -12.0, 1.0, 0.0, 1.0, 0.0 ] ); - out = new Float64Array( 6 ); - out = dlasv2( 2.0, 0.0, -12.0, out ); - isApprox( t, out, expected, 1.0 ); + data = DIA_MAT; - expected = new Float64Array( [ 9.0, -122.0, 0.0, 1.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); - out = dlasv2( -122.0, 0.0, 9.0, out ); + + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function correctly computes svd of diagonal matrix with a very large `G`', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G`', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 2.0e-20, 1.0e+20, 1.0, 2.0e-20, 1.0e-20, 1.0 ] ); + data = LARGE_G; + out = new Float64Array( 6 ); - out = dlasv2( 2.0, 1.0e+20, 1.0, out ); + + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function computes svd of diagonal matrix with a very large `G` when `H` is greater than 1', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 6.0e-20, 1.0e+20, 1.0, 2.0e-20, 3.0e-20, 1.0 ] ); + data = LARGE_G_AND_H_GT_1; + out = new Float64Array( 6 ); - out = dlasv2( 2.0, 1.0e+20, 3.0, out ); + + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function correctly computes svd of diagonal matrix with an infinite `F`', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with an infinite `F`', function test( t ) { var expected; var out; - expected = new Float64Array( [ 1.0, Infinity, 0.0, 1.0, 0.0, 1.0 ] ); + expected = new Float64Array( [ 1.0, PINF, 0.0, 1.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); - out = dlasv2( Infinity, 2.0, 1.0, out ); + out = dlasv2( PINF, 2.0, 1.0, out ); isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function computes svd of diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 3.0, 3.0, 0.7071067811865475, 0.7071067811865475, 0.7071067811865475, 0.7071067811865475 ] ); + data = SMALL_G_AND_F_EQ_H; + out = new Float64Array( 6 ); - out = dlasv2( 3.0, 5e-324, 3.0, out ); + + dlasv2( data.F, data.G, data.H, out ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js index a65648e7829e..50551ae7c6aa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js @@ -22,11 +22,43 @@ var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var dlasv2 = require( './../lib/ndarray.js' ); +// FIXTURES // + +// NOTE: Expected outputs in fixtures were generated using the reference LAPACK Fortran implementation of DLASV2. +var INC_ORD_ELE = require( './fixtures/increasing_order_elements.json' ); +var DEC_ORD_ELE = require( './fixtures/decreasing_order_elements.json' ); +var LARGE_G = require( './fixtures/large_g_diagonal.json' ); +var LARGE_G_AND_H_GT_1 = require( './fixtures/large_g_and_h_gt_1.json' ); +var SMALL_G_AND_F_EQ_H = require( './fixtures/small_g_and_f_eq_h.json' ); +var DIA_MAT = require( './fixtures/diagonal_matrix.json' ); +var G_GT_F_AND_H = require( './fixtures/g_gt_f_and_h.json' ); +var LAR_STR_INC_ORD_ELE = require( './fixtures/large_strides/increasing_order_elements.json' ); +var LAR_STR_DEC_ORD_ELE = require( './fixtures/large_strides/decreasing_order_elements.json' ); +var LAR_STR_LARGE_G = require( './fixtures/large_strides/large_g_diagonal.json' ); +var LAR_STR_LARGE_G_AND_H_GT_1 = require( './fixtures/large_strides/large_g_and_h_gt_1.json' ); +var LAR_STR_SMALL_G_AND_F_EQ_H = require( './fixtures/large_strides/small_g_and_f_eq_h.json' ); +var LAR_STR_DIA_MAT = require( './fixtures/large_strides/diagonal_matrix.json' ); +var LAR_STR_G_GT_F_AND_H = require( './fixtures/large_strides/g_gt_f_and_h.json' ); +var NEG_STR_INC_ORD_ELE = require( './fixtures/negative_strides/increasing_order_elements.json' ); +var NEG_STR_DEC_ORD_ELE = require( './fixtures/negative_strides/decreasing_order_elements.json' ); +var NEG_STR_LARGE_G = require( './fixtures/negative_strides/large_g_diagonal.json' ); +var NEG_STR_LARGE_G_AND_H_GT_1 = require( './fixtures/negative_strides/large_g_and_h_gt_1.json' ); +var NEG_STR_SMALL_G_AND_F_EQ_H = require( './fixtures/negative_strides/small_g_and_f_eq_h.json' ); +var NEG_STR_DIA_MAT = require( './fixtures/negative_strides/diagonal_matrix.json' ); +var NEG_STR_G_GT_F_AND_H = require( './fixtures/negative_strides/g_gt_f_and_h.json' ); +var OFF_INC_ORD_ELE = require( './fixtures/offsets/increasing_order_elements.json' ); +var OFF_DEC_ORD_ELE = require( './fixtures/offsets/decreasing_order_elements.json' ); +var OFF_LARGE_G = require( './fixtures/offsets/large_g_diagonal.json' ); +var OFF_LARGE_G_AND_H_GT_1 = require( './fixtures/offsets/large_g_and_h_gt_1.json' ); +var OFF_SMALL_G_AND_F_EQ_H = require( './fixtures/offsets/small_g_and_f_eq_h.json' ); +var OFF_DIA_MAT = require( './fixtures/offsets/diagonal_matrix.json' ); +var OFF_G_GT_F_AND_H = require( './fixtures/offsets/g_gt_f_and_h.json' ); + + // FUNCTIONS // /** @@ -39,8 +71,6 @@ var dlasv2 = require( './../lib/ndarray.js' ); * @param {number} rtol - relative tolerance */ function isApprox( t, actual, expected, rtol ) { - var delta; - var tol; var i; t.strictEqual( actual.length, expected.length, 'returns expected value' ); @@ -48,9 +78,7 @@ function isApprox( t, actual, expected, rtol ) { if ( actual[ i ] === expected[ i ] ) { t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = rtol * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], rtol ), true, 'returns expected value' ); } } } @@ -69,24 +97,422 @@ tape( 'the function has an arity of 6', function test( t ) { t.end(); }); -tape( 'the function supports complex access pattern to store computed values', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order', function test( t ) { + var expected; + var data; + var out; + + data = INC_ORD_ELE; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 999.9, 1.2125424343860751, 999.9, 6.597707241520579, 999.9, 0.8090383403577232, 999.9, 0.5877558709457702, 999.9, 0.2452483296822559, 999.9, 0.9694602914962858 ] ); - out = new Float64Array( [ 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0 ] ); - out = dlasv2( 4.0, 5.0, 2.0, out, 2, 1 ); + data = DEC_ORD_ELE; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); -tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H`', function test( t ) { var expected; + var data; var out; - expected = new Float64Array( [ 999.9, 0.9694602914962858, 999.9, 0.2452483296822559, 999.9, 0.5877558709457702, 999.9, 0.8090383403577232, 999.9, 6.597707241520579, 999.9, 1.2125424343860751 ] ); - out = new Float64Array( [ 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0, 999.9, 0.0 ] ); - out = dlasv2( 4.0, 5.0, 2.0, out, -2, out.length-1 ); + data = G_GT_F_AND_H; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix', function test( t ) { + var expected; + var data; + var out; + + data = DIA_MAT; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G`', function test( t ) { + var expected; + var data; + var out; + + data = LARGE_G; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1', function test( t ) { + var expected; + var data; + var out; + + data = LARGE_G_AND_H_GT_1; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal', function test( t ) { + var expected; + var data; + var out; + + data = SMALL_G_AND_F_EQ_H; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_INC_ORD_ELE; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_DEC_ORD_ELE; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_G_GT_F_AND_H; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_DIA_MAT; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_LARGE_G; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_LARGE_G_AND_H_GT_1; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (large stride)', function test( t ) { + var expected; + var data; + var out; + + data = LAR_STR_SMALL_G_AND_F_EQ_H; + + out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_INC_ORD_ELE; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_DEC_ORD_ELE; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_G_GT_F_AND_H; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_DIA_MAT; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_LARGE_G; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_LARGE_G_AND_H_GT_1; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (Negative Stride)', function test( t ) { + var expected; + var data; + var out; + + data = NEG_STR_SMALL_G_AND_F_EQ_H; + + out = new Float64Array( 6 ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_INC_ORD_ELE; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_DEC_ORD_ELE; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_G_GT_F_AND_H; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_DIA_MAT; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_LARGE_G; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_LARGE_G_AND_H_GT_1; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (Offset)', function test( t ) { + var expected; + var data; + var out; + + data = OFF_SMALL_G_AND_F_EQ_H; + + out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); + + dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); + expected = data.out; isApprox( t, out, expected, 1.0 ); t.end(); }); From 53d229f329192ead07a0e965325d9335bc5182c5 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Fri, 15 May 2026 08:54:40 +0530 Subject: [PATCH 11/16] fix: improve benchmarks and other minor changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlasv2/README.md | 2 +- .../lapack/base/dlasv2/benchmark/benchmark.js | 21 +++-- .../dlasv2/benchmark/benchmark.ndarray.js | 23 +++-- .../lapack/base/dlasv2/docs/types/index.d.ts | 4 +- .../@stdlib/lapack/base/dlasv2/lib/base.js | 2 +- .../lapack/base/dlasv2/test/test.dlasv2.js | 22 ++--- .../lapack/base/dlasv2/test/test.ndarray.js | 90 +++++++++---------- 7 files changed, 91 insertions(+), 73 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md index 5606013db6d6..72c7f8a70c04 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md @@ -24,7 +24,7 @@ limitations under the License.
-The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by - +The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js index ebc3947e17b3..1ec202f960e8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var format = require( '@stdlib/string/format' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); @@ -29,24 +29,33 @@ var pkg = require( './../package.json' ).name; var dlasv2 = require( './../lib/dlasv2.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( 6 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - f = uniform( -10.0, 10.0 ); - g = uniform( -10.0, 10.0 ); - h = uniform( -10.0, 10.0 ); - - dlasv2( f, g, h, out ); + dlasv2( 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' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js index 8b1982743613..b309bc51a4a2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var format = require( '@stdlib/string/format' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); @@ -29,24 +29,33 @@ var pkg = require( './../package.json' ).name; var dlasv2 = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // MAIN // -bench( format( '%s', pkg ), function benchmark( b ) { +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( 6 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - f = uniform( -10.0, 10.0 ); - g = uniform( -10.0, 10.0 ); - h = uniform( -10.0, 10.0 ); - - dlasv2( f, g, h, out, 1, 0 ); + dlasv2( 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' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts index e95142dd5172..d40b45104f42 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/docs/types/index.d.ts @@ -45,7 +45,7 @@ interface Routine { * var out = new Float64Array( 6 ); * * dlasv2( 2.0, 3.0, 4.0, out ); - * // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] + * // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ ( F: number, G: number, H: number, out: Float64Array ): Float64Array; @@ -72,7 +72,7 @@ interface Routine { * var out = new Float64Array( 6 ); * * dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); - * // out => [ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ] + * // out => [ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ] */ ndarray( F: number, G: number, H: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; } diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js index 71608646f3b0..e8a41a1672b6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -210,7 +210,7 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { snr = srt; } - // Correct signs 0f ssmax and ssmin + // Correct signs of ssmax and ssmin if ( PMAX === 1 ) { tsign = copysign( 1.0, csr ) * copysign( 1.0, csl ) * copysign( 1.0, F ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js index 51b6c20f803b..cf2d699925cf 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -48,9 +48,9 @@ var G_GT_F_AND_H = require( './fixtures/g_gt_f_and_h.json' ); * @param {Object} t - test object * @param {Collection} actual - actual values * @param {Collection} expected - expected values -* @param {number} rtol - relative tolerance +* @param {number} maxULPs - maximum allowed ULP difference */ -function isApprox( t, actual, expected, rtol ) { +function isApprox( t, actual, expected, maxULPs ) { var i; t.strictEqual( actual.length, expected.length, 'returns expected value' ); @@ -58,7 +58,7 @@ function isApprox( t, actual, expected, rtol ) { if ( actual[ i ] === expected[ i ] ) { t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); } else { - t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], rtol ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); } } } @@ -88,7 +88,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -103,7 +103,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -118,7 +118,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -133,7 +133,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -148,7 +148,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -163,7 +163,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -174,7 +174,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr expected = new Float64Array( [ 1.0, PINF, 0.0, 1.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); out = dlasv2( PINF, 2.0, 1.0, out ); - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -189,6 +189,6 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js index 50551ae7c6aa..a27f459b750f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js @@ -68,9 +68,9 @@ var OFF_G_GT_F_AND_H = require( './fixtures/offsets/g_gt_f_and_h.json' ); * @param {Object} t - test object * @param {Collection} actual - actual values * @param {Collection} expected - expected values -* @param {number} rtol - relative tolerance +* @param {number} maxULPs - maximum allowed ULP difference */ -function isApprox( t, actual, expected, rtol ) { +function isApprox( t, actual, expected, maxULPs ) { var i; t.strictEqual( actual.length, expected.length, 'returns expected value' ); @@ -78,7 +78,7 @@ function isApprox( t, actual, expected, rtol ) { if ( actual[ i ] === expected[ i ] ) { t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); } else { - t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], rtol ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); } } } @@ -108,7 +108,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -123,7 +123,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -138,7 +138,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -153,7 +153,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -168,7 +168,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -183,7 +183,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -198,7 +198,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -213,7 +213,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -228,7 +228,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -243,7 +243,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -258,7 +258,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -273,7 +273,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -288,7 +288,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); @@ -303,11 +303,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (negative stride)', function test( t ) { var expected; var data; var out; @@ -318,11 +318,11 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (negative stride)', function test( t ) { var expected; var data; var out; @@ -333,11 +333,11 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (negative stride)', function test( t ) { var expected; var data; var out; @@ -348,11 +348,11 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix (negative stride)', function test( t ) { var expected; var data; var out; @@ -363,11 +363,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (negative stride)', function test( t ) { var expected; var data; var out; @@ -378,11 +378,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (negative stride)', function test( t ) { var expected; var data; var out; @@ -393,11 +393,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (Negative Stride)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (negative stride)', function test( t ) { var expected; var data; var out; @@ -408,11 +408,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in increasing order (offset)', function test( t ) { var expected; var data; var out; @@ -423,11 +423,11 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with elements in decreasing order (offset)', function test( t ) { var expected; var data; var out; @@ -438,11 +438,11 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a triangular matrix with parameter `G` greater than `F` and `H` (offset)', function test( t ) { var expected; var data; var out; @@ -453,11 +453,11 @@ tape( 'the function computes the singular value decomposition of a triangular ma dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix (offset)', function test( t ) { var expected; var data; var out; @@ -468,11 +468,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` (offset)', function test( t ) { var expected; var data; var out; @@ -483,11 +483,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with a very large `G` when `H` is greater than 1 (offset)', function test( t ) { var expected; var data; var out; @@ -498,11 +498,11 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); -tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (Offset)', function test( t ) { +tape( 'the function computes the singular value decomposition of a diagonal matrix with tiny off-diagonal entries when `F` and `H` are equal (offset)', function test( t ) { var expected; var data; var out; @@ -513,6 +513,6 @@ tape( 'the function computes the singular value decomposition of a diagonal matr dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); expected = data.out; - isApprox( t, out, expected, 1.0 ); + isApprox( t, out, expected, 1 ); t.end(); }); From ad5abeef27e99c7242111781fa54de797c457b10 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 14 May 2026 20:52:50 -0700 Subject: [PATCH 12/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/lapack/base/dlasv2/test/test.dlasv2.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js index cf2d699925cf..5b9c1a758395 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -55,11 +55,7 @@ function isApprox( t, actual, expected, maxULPs ) { t.strictEqual( actual.length, expected.length, 'returns expected value' ); for ( i = 0; i < expected.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); - } + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); } } From 06d4091359bc804319f4c9fa488770d6c9b61ac8 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 14 May 2026 20:53:32 -0700 Subject: [PATCH 13/16] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/lapack/base/dlasv2/test/test.ndarray.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js index a27f459b750f..fc78d4ae4aee 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js @@ -75,11 +75,7 @@ function isApprox( t, actual, expected, maxULPs ) { t.strictEqual( actual.length, expected.length, 'returns expected value' ); for ( i = 0; i < expected.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); - } + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); } } From 6eb6d6a1096dc225542fc84bf721c6d903d3f761 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Fri, 15 May 2026 10:07:09 +0530 Subject: [PATCH 14/16] test: replace `isApprox` with `is-almost-same-value-float64array` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/dlasv2/test/test.dlasv2.js | 53 +++---- .../lapack/base/dlasv2/test/test.ndarray.js | 135 ++++++++---------- 2 files changed, 73 insertions(+), 115 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js index 5b9c1a758395..70080489d985 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js @@ -22,7 +22,7 @@ var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); -var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var isAlmostSameValueFloat64Array = require( '@stdlib/assert/is-almost-same-value-float64array' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var dlasv2 = require( './../lib/dlasv2.js' ); @@ -39,27 +39,6 @@ var DIA_MAT = require( './fixtures/diagonal_matrix.json' ); var G_GT_F_AND_H = require( './fixtures/g_gt_f_and_h.json' ); -// FUNCTIONS // - -/** -* Tests for element-wise approximate equality. -* -* @private -* @param {Object} t - test object -* @param {Collection} actual - actual values -* @param {Collection} expected - expected values -* @param {number} maxULPs - maximum allowed ULP difference -*/ -function isApprox( t, actual, expected, maxULPs ) { - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); - } -} - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -83,8 +62,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -98,8 +77,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -113,8 +92,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -128,8 +107,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -143,8 +122,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -158,8 +137,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -170,7 +149,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr expected = new Float64Array( [ 1.0, PINF, 0.0, 1.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); out = dlasv2( PINF, 2.0, 1.0, out ); - isApprox( t, out, expected, 1 ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -184,7 +163,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js index fc78d4ae4aee..a021e663049a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.ndarray.js @@ -22,7 +22,7 @@ var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); -var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var isAlmostSameValueFloat64Array = require( '@stdlib/assert/is-almost-same-value-float64array' ); var dlasv2 = require( './../lib/ndarray.js' ); @@ -59,27 +59,6 @@ var OFF_DIA_MAT = require( './fixtures/offsets/diagonal_matrix.json' ); var OFF_G_GT_F_AND_H = require( './fixtures/offsets/g_gt_f_and_h.json' ); -// FUNCTIONS // - -/** -* Tests for element-wise approximate equality. -* -* @private -* @param {Object} t - test object -* @param {Collection} actual - actual values -* @param {Collection} expected - expected values -* @param {number} maxULPs - maximum allowed ULP difference -*/ -function isApprox( t, actual, expected, maxULPs ) { - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' ); - } -} - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -103,8 +82,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -118,8 +97,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -133,8 +112,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -148,8 +127,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -163,8 +142,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -178,8 +157,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -193,8 +172,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -208,8 +187,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -223,8 +202,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -238,8 +217,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -253,8 +232,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -268,8 +247,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -283,8 +262,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -298,8 +277,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999, 0, 9999 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -313,8 +292,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -328,8 +307,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -343,8 +322,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -358,8 +337,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -373,8 +352,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -388,8 +367,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -403,8 +382,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( 6 ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -418,8 +397,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -433,8 +412,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -448,8 +427,8 @@ tape( 'the function computes the singular value decomposition of a triangular ma out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -463,8 +442,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -478,8 +457,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -493,8 +472,8 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -508,7 +487,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr out = new Float64Array( [ 9999, 0, 0, 0, 0, 0, 0 ] ); dlasv2( data.F, data.G, data.H, out, data.strideOut, data.offsetOut ); - expected = data.out; - isApprox( t, out, expected, 1 ); + expected = new Float64Array( data.out ); + t.strictEqual( isAlmostSameValueFloat64Array( out, expected, 1 ), true, 'returns expected value' ); t.end(); }); From 612611c899def43b6b97d8637060b4f8f936f1f0 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Fri, 15 May 2026 10:30:00 +0530 Subject: [PATCH 15/16] fix: minor changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/dlasv2/examples/index.js | 2 +- .../@stdlib/lapack/base/dlasv2/lib/base.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js index 25b0ab5ef41f..2cfba28f0ae6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/examples/index.js @@ -21,7 +21,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var dlasv2 = require( './../lib/' ); -var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +var out = new Float64Array( 6 ); dlasv2( 1.0, 1e6, 2.0, out ); console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js index e8a41a1672b6..e97cf89473d3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js @@ -72,6 +72,7 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { var crt; var csl; var csr; + var idx; var slt; var snl; var snr; @@ -223,12 +224,18 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) { ssmax = copysign( ssmax, tsign ); ssmin = copysign( ssmin, tsign * copysign( 1.0, F ) * copysign( 1.0, H ) ); - out[ offsetOut ] = ssmin; - out[ offsetOut + strideOut ] = ssmax; - out[ offsetOut + ( 2 * strideOut ) ] = snr; - out[ offsetOut + ( 3 * strideOut ) ] = csr; - out[ offsetOut + ( 4 * strideOut ) ] = snl; - out[ offsetOut + ( 5 * strideOut ) ] = csl; + idx = offsetOut; + out[ idx ] = ssmin; + idx += strideOut; + out[ idx ] = ssmax; + idx += strideOut; + out[ idx ] = snr; + idx += strideOut; + out[ idx ] = csr; + idx += strideOut; + out[ idx ] = snl; + idx += strideOut; + out[ idx ] = csl; return out; } From 926267708d22c79e66c823bfea3a67326aa3a4c0 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Fri, 15 May 2026 10:36:31 +0530 Subject: [PATCH 16/16] docs: define matrix `A` clearly --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/dlasv2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md index 72c7f8a70c04..59fe5266d112 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlasv2/README.md @@ -24,7 +24,7 @@ limitations under the License.
-The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by +The singular value decomposition of a 2x2 upper triangular matrix $ A = \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by