diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/README.md b/lib/node_modules/@stdlib/lapack/base/dgeequ/README.md new file mode 100644 index 000000000000..c20af6224e1d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/README.md @@ -0,0 +1,230 @@ + + +# dgeequ + +> Compute row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. + +
+ +## Usage + +```javascript +var dgeequ = require( '@stdlib/lapack/base/dgeequ' ); +``` + +#### dgeequ( order, M, N, A, LDA, R, C ) + +Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +var R = new Float64Array( 3 ); +var C = new Float64Array( 3 ); + +var out = dgeequ( 'row-major', 3, 3, A, 3, R, C ); +// returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +``` + +The function has the following parameters: + +- **order**: storage layout (either `'row-major'` or `'column-major'`). +- **M**: number of rows of matrix `A`. +- **N**: number of columns of matrix `A`. +- **A**: the M-by-N matrix `A` as a [`Float64Array`][mdn-float64array]. +- **LDA**: leading dimension of matrix `A`. +- **R**: output row scale factors as a [`Float64Array`][mdn-float64array]. +- **C**: output column scale factors as a [`Float64Array`][mdn-float64array]. + +The function returns a `Collection` containing: + +- **rowcnd**: ratio of the smallest `R[i]` to the largest `R[i]`. +- **colcnd**: ratio of the smallest `C[j]` to the largest `C[j]`. +- **amax**: absolute value of the largest matrix element. +- **info**: status code. If `0`, successful exit. If `> 0` and `<= M`, the `i`-th row is exactly zero (where `i` equals the status code); if `> M`, the `(i-M)`-th column is exactly zero. Note that the status code uses one-based indexing to match the LAPACK convention, so the corresponding zero-based JavaScript index is `info - 1`. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +#### dgeequ.ndarray( M, N, A, sa1, sa2, oa, R, sr, or, C, sc, oc ) + +Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +var R = new Float64Array( 3 ); +var C = new Float64Array( 3 ); + +var out = dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); +// returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +``` + +The function has the following additional parameters: + +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **sr**: stride length for `R`. +- **or**: starting index for `R`. +- **sc**: stride length for `C`. +- **oc**: starting index for `C`. + +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. + +
+ + + +
+ +## Notes + +- Both functions mutate the output arrays `R` and `C`. +- `dgeequ()` corresponds to the [LAPACK][LAPACK] routine [`dgeequ`][lapack-dgeequ]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dgeequ = require( '@stdlib/lapack/base/dgeequ' ); + +var A = new Float64Array( [ 1.0, 10.0, 100.0, 1000.0 ] ); +var R = new Float64Array( 2 ); +var C = new Float64Array( 2 ); + +var out = dgeequ( 'row-major', 2, 2, A, 2, R, C ); +console.log( R ); +// => [ 0.1, 0.001 ] + +console.log( C ); +// => [ 10.0, 1.0 ] + +console.log( out ); +// => [ 0.01, 0.1, 1000.0, 0 ] +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.js new file mode 100644 index 000000000000..a094d3c4bad8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.js @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var dgeequ = require( './../lib/dgeequ.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A; + var R; + var C; + + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + R = new Float64Array( N ); + C = new Float64Array( N ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dgeequ( order, N, N, A, N, R, C ); + if ( isnan( out[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::equidimensional:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..4409510a81df --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.ndarray.js @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var dgeequ = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sa1; + var sa2; + var A; + var R; + var C; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + R = new Float64Array( N ); + C = new Float64Array( N ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dgeequ( N, N, A, sa1, sa2, 0, R, 1, 0, C, 1, 0 ); + if ( isnan( out[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::equidimensional:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/repl.txt new file mode 100644 index 000000000000..6a8030cb30c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/repl.txt @@ -0,0 +1,120 @@ + +{{alias}}( order, M, N, A, LDA, R, C ) + Computes row and column scaling factors intended to equilibrate an M-by-N + real matrix `A` and reduce its condition number. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + M: integer + Number of rows of matrix `A`. + + N: integer + Number of columns of matrix `A`. + + A: Float64Array + Input matrix. + + LDA: integer + Leading dimension of matrix `A`. + + R: Float64Array + Output row scale factors. + + C: Float64Array + Output column scale factors. + + Returns + ------- + out: Array + A 4-element array containing: + - rowcnd: ratio of smallest R[i] to largest R[i]. + - colcnd: ratio of smallest C[j] to largest C[j]. + - amax: absolute value of the largest matrix element. + - info: status code. + + Examples + -------- + > var Float64Array = require( '@stdlib/array/float64' ); + > var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + > var R = new Float64Array( 3 ); + > var C = new Float64Array( 3 ); + > var out = {{alias}}( 'row-major', 3, 3, A, 3, R, C ); + > out + [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] + + +{{alias}}.ndarray( M, N, A, sa1, sa2, oa, R, sr, or, C, sc, oc ) + Computes row and column scaling factors intended to equilibrate an M-by-N + real matrix `A` and reduce its condition number 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 + ---------- + M: integer + Number of rows of matrix `A`. + + N: integer + Number of columns of matrix `A`. + + A: Float64Array + Input matrix. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + R: Float64Array + Output row scale factors. + + sr: integer + Stride length for `R`. + + or: integer + Starting index for `R`. + + C: Float64Array + Output column scale factors. + + sc: integer + Stride length for `C`. + + oc: integer + Starting index for `C`. + + Returns + ------- + out: Array + A 4-element array containing: + - rowcnd: ratio of smallest R[i] to largest R[i]. + - colcnd: ratio of smallest C[j] to largest C[j]. + - amax: absolute value of the largest matrix element. + - info: status code. + + Examples + -------- + > var Float64Array = require( '@stdlib/array/float64' ); + > var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + > var R = new Float64Array( 3 ); + > var C = new Float64Array( 3 ); + > var out = {{alias}}.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); + > out + [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/types/index.d.ts new file mode 100644 index 000000000000..c090a3c67872 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/types/index.d.ts @@ -0,0 +1,120 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `dgeequ`. +*/ +interface Routine { + /** + * Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. + * + * @param order - storage layout + * @param M - number of rows of matrix `A` + * @param N - number of columns of matrix `A` + * @param A - input matrix + * @param LDA - stride of the first/second dimension of `A` (a.k.a., leading dimension of matrix `A`) + * @param R - output row scale factors + * @param C - output column scale factors + * @returns a 4-element array containing `[ rowcnd, colcnd, amax, info ]` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + * var R = new Float64Array( 3 ); + * var C = new Float64Array( 3 ); + * + * var out = dgeequ( 'row-major', 3, 3, A, 3, R, C ); + * // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] + */ + ( order: Layout, M: number, N: number, A: Float64Array, LDA: number, R: Float64Array, C: Float64Array ): Array; + + /** + * Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number using alternative indexing semantics. + * + * @param M - number of rows of matrix `A` + * @param N - number of columns of matrix `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @param R - output row scale factors + * @param strideR - stride length for `R` + * @param offsetR - starting index for `R` + * @param C - output column scale factors + * @param strideC - stride length for `C` + * @param offsetC - starting index for `C` + * @returns a 4-element array containing `[ rowcnd, colcnd, amax, info ]` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + * var R = new Float64Array( 3 ); + * var C = new Float64Array( 3 ); + * + * var out = dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); + * // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] + */ + ndarray( M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, R: Float64Array, strideR: number, offsetR: number, C: Float64Array, strideC: number, offsetC: number ): Array; +} + +/** +* Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. +* +* @param order - storage layout +* @param M - number of rows of matrix `A` +* @param N - number of columns of matrix `A` +* @param A - input matrix +* @param LDA - stride of the first/second dimension of `A` (a.k.a., leading dimension of matrix `A`) +* @param R - output row scale factors +* @param C - output column scale factors +* @returns a 4-element array containing `[ rowcnd, colcnd, amax, info ]` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var R = new Float64Array( 3 ); +* var C = new Float64Array( 3 ); +* +* var out = dgeequ( 'row-major', 3, 3, A, 3, R, C ); +* // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var R = new Float64Array( 3 ); +* var C = new Float64Array( 3 ); +* +* var out = dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); +* // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +*/ +declare var dgeequ: Routine; + + +// EXPORTS // + +export = dgeequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/types/test.ts new file mode 100644 index 000000000000..ea568c050e9f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/docs/types/test.ts @@ -0,0 +1,381 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dgeequ = require( './index' ); + + +// TESTS // + +// The function returns an array of numbers... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ( 'column-major', 3, 3, A, 3, R, C ); // $ExpectType number[] +} + +// The compiler throws an error if the function is provided a first argument which is not a layout order... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ( 5, 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( true, 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( false, 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( null, 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( void 0, 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( [], 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( {}, 3, 3, A, 3, R, C ); // $ExpectError + dgeequ( ( x: number ): number => x, 3, 3, A, 3, R, C ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ( 'column-major', '5', 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', true, 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', false, 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', null, 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', void 0, 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', [], 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', {}, 3, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', ( x: number ): number => x, 3, A, 3, R, C ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ( 'column-major', 3, '5', A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, true, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, false, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, null, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, void 0, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, [], A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, {}, A, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, ( x: number ): number => x, A, 3, R, C ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ( 'column-major', 3, 3, '5', 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, 5, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, true, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, false, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, null, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, void 0, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, [], 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, {}, 3, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, ( x: number ): number => x, 3, R, C ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ( 'column-major', 3, 3, A, '5', R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, true, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, false, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, null, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, void 0, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, [], R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, {}, R, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, ( x: number ): number => x, R, C ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const A = new Float64Array( 9 ); + const C = new Float64Array( 3 ); + + dgeequ( 'column-major', 3, 3, A, 3, '5', C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, 5, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, true, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, false, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, null, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, void 0, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, [], C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, {}, C ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, ( x: number ): number => x, C ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + + dgeequ( 'column-major', 3, 3, A, 3, R, '5' ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, 5 ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, true ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, false ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, null ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, void 0 ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, [] ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, {} ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ(); // $ExpectError + dgeequ( 'column-major' ); // $ExpectError + dgeequ( 'column-major', 3 ); // $ExpectError + dgeequ( 'column-major', 3, 3 ); // $ExpectError + dgeequ( 'column-major', 3, 3, A ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3 ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R ); // $ExpectError + dgeequ( 'column-major', 3, 3, A, 3, R, C, 10 ); // $ExpectError +} + +// The function `ndarray` method returns an array of numbers... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( '5', 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( true, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( false, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( null, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( void 0, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( [], 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( {}, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( ( x: number ): number => x, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, '5', A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, true, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, false, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, null, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, void 0, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, [], A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, {}, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, ( x: number ): number => x, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... +{ + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, '5', 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, 5, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, true, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, false, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, null, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, void 0, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, [], 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, {}, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, ( x: number ): number => x, 3, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, '5', 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, true, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, false, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, null, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, void 0, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, [], 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, {}, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, ( x: number ): number => x, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, '5', 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, true, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, false, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, null, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, void 0, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, [], 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, {}, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, ( x: number ): number => x, 0, R, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, '5', R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, true, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, false, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, null, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, void 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, [], R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, {}, R, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, ( x: number ): number => x, R, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( 9 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, '5', 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, 5, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, true, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, false, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, null, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, void 0, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, [], 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, {}, 1, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, ( x: number ): number => x, 1, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, '5', 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, true, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, false, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, null, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, void 0, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, [], 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, {}, 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, ( x: number ): number => x, 0, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, '5', C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, true, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, false, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, null, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, void 0, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, [], C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, {}, C, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, ( x: number ): number => x, C, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a Float64Array... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, '5', 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, 5, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, true, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, false, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, null, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, void 0, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, [], 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, {}, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, '5', 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, true, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, false, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, null, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, void 0, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, [], 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, {}, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, '5' ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, true ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, false ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, null ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, void 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, [] ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, {} ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an invalid number of arguments... +{ + const A = new Float64Array( 9 ); + const R = new Float64Array( 3 ); + const C = new Float64Array( 3 ); + + dgeequ.ndarray(); // $ExpectError + dgeequ.ndarray( 3 ); // $ExpectError + dgeequ.ndarray( 3, 3 ); // $ExpectError + dgeequ.ndarray( 3, 3, A ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1 ); // $ExpectError + dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/examples/index.js new file mode 100644 index 000000000000..430250c09d1c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dgeequ = require( './../lib' ); + +var A = new Float64Array( [ 1.0, 10.0, 100.0, 1000.0 ] ); +var R = new Float64Array( 2 ); +var C = new Float64Array( 2 ); + +var out = dgeequ( 'row-major', 2, 2, A, 2, R, C ); +console.log( R ); +// => [ 0.1, 0.001 ] + +console.log( C ); +// => [ 10.0, 1.0 ] + +console.log( out ); +// => [ 0.01, 0.1, 1000.0, 0 ] diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/base.js new file mode 100644 index 000000000000..b72c4c053232 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/base.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var FLOAT64_SMALLEST_NORMAL = require( '@stdlib/constants/float64/smallest-normal' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); + + +// MAIN // + +/** +* Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. +* +* @private +* @param {NonNegativeInteger} M - number of rows of matrix `A` +* @param {NonNegativeInteger} N - number of columns of matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} R - output row scale factors +* @param {integer} strideR - stride length for `R` +* @param {NonNegativeInteger} offsetR - starting index for `R` +* @param {Float64Array} C - output column scale factors +* @param {integer} strideC - stride length for `C` +* @param {NonNegativeInteger} offsetC - starting index for `C` +* @returns {Array} a 4-element array containing `[ rowcnd, colcnd, amax, info ]` +*/ +function dgeequ( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC ) { // eslint-disable-line max-len, max-params + var smlnum; + var bignum; + var rowcnd; + var colcnd; + var rcmin; + var rcmax; + var amax; + var iaJ; + var ia; + var ir; + var ic; + var i; + var j; + + if ( M === 0 || N === 0 ) { + return [ 1.0, 1.0, 0.0, 0 ]; + } + + smlnum = FLOAT64_SMALLEST_NORMAL; + bignum = 1.0 / smlnum; + + // Initialize R to zero: + ir = offsetR; + for ( i = 0; i < M; i++ ) { + R[ ir ] = 0.0; + ir += strideR; + } + + // Find the maximum element in each row: + iaJ = offsetA; + for ( j = 0; j < N; j++ ) { + ia = iaJ; + ir = offsetR; + for ( i = 0; i < M; i++ ) { + R[ ir ] = max( R[ ir ], abs( A[ ia ] ) ); + ia += strideA1; + ir += strideR; + } + iaJ += strideA2; + } + + // Find the maximum and minimum row scale factors: + rcmin = bignum; + rcmax = 0.0; + ir = offsetR; + for ( i = 0; i < M; i++ ) { + rcmax = max( rcmax, R[ ir ] ); + rcmin = min( rcmin, R[ ir ] ); + ir += strideR; + } + amax = rcmax; + + if ( rcmin === 0.0 ) { + // Find the first zero scale factor and return an error code: + ir = offsetR; + for ( i = 0; i < M; i++ ) { + if ( R[ ir ] === 0.0 ) { + return [ 0.0, 0.0, amax, i + 1 ]; + } + ir += strideR; + } + } else { + // Invert the scale factors: + ir = offsetR; + for ( i = 0; i < M; i++ ) { + R[ ir ] = 1.0 / min( max( R[ ir ], smlnum ), bignum ); + ir += strideR; + } + // Compute ROWCND = min(R(i)) / max(R(i)) + rowcnd = max( rcmin, smlnum ) / min( rcmax, bignum ); + } + + // Initialize C to zero: + ic = offsetC; + for ( j = 0; j < N; j++ ) { + C[ ic ] = 0.0; + ic += strideC; + } + + // Find the maximum element in each column, assuming the row scaling: + iaJ = offsetA; + ic = offsetC; + for ( j = 0; j < N; j++ ) { + ia = iaJ; + ir = offsetR; + for ( i = 0; i < M; i++ ) { + C[ ic ] = max( C[ ic ], abs( A[ ia ] ) * R[ ir ] ); + ia += strideA1; + ir += strideR; + } + iaJ += strideA2; + ic += strideC; + } + + // Find the maximum and minimum col scale factors: + rcmin = bignum; + rcmax = 0.0; + ic = offsetC; + for ( j = 0; j < N; j++ ) { + rcmin = min( rcmin, C[ ic ] ); + rcmax = max( rcmax, C[ ic ] ); + ic += strideC; + } + + if ( rcmin === 0.0 ) { + // Find the first zero scale factor and return an error code: + ic = offsetC; + for ( j = 0; j < N; j++ ) { + if ( C[ ic ] === 0.0 ) { + return [ rowcnd, 0.0, amax, M + j + 1 ]; + } + ic += strideC; + } + } else { + // Invert the scale factors: + ic = offsetC; + for ( j = 0; j < N; j++ ) { + C[ ic ] = 1.0 / min( max( C[ ic ], smlnum ), bignum ); + ic += strideC; + } + // Compute COLCND = min(C(j)) / max(C(j)) + colcnd = max( rcmin, smlnum ) / min( rcmax, bignum ); + } + + return [ rowcnd, colcnd, amax, 0 ]; +} + + +// EXPORTS // + +module.exports = dgeequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/dgeequ.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/dgeequ.js new file mode 100644 index 000000000000..80d5c2d534d8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/dgeequ.js @@ -0,0 +1,90 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of rows of matrix `A` +* @param {NonNegativeInteger} N - number of columns of matrix `A` +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first/second dimension of `A` (a.k.a., leading dimension of matrix `A`) +* @param {Float64Array} R - output row scale factors +* @param {Float64Array} C - output column scale factors +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be greater than or equal to max(1, M) (for column-major) or max(1, N) (for row-major) +* @returns {Array} a 4-element array containing `[ rowcnd, colcnd, amax, info ]` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var R = new Float64Array( 3 ); +* var C = new Float64Array( 3 ); +* +* var out = dgeequ( 'row-major', 3, 3, A, 3, R, C ); +* // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +*/ +function dgeequ( order, M, N, A, LDA, R, C ) { + var strideA1; + var strideA2; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( isColumnMajor( order ) ) { + if ( LDA < max( 1, M ) ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDA ) ); + } + strideA1 = 1; + strideA2 = LDA; + } else { // order === 'row-major' + if ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + strideA1 = LDA; + strideA2 = 1; + } + return base( M, N, A, strideA1, strideA2, 0, R, 1, 0, C, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dgeequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/index.js new file mode 100644 index 000000000000..d0976d3554c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number. +* +* @module @stdlib/lapack/base/dgeequ +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dgeequ = require( '@stdlib/lapack/base/dgeequ' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var R = new Float64Array( 3 ); +* var C = new Float64Array( 3 ); +* +* var out = dgeequ( 'row-major', 3, 3, A, 3, R, C ); +* // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dgeequ = require( '@stdlib/lapack/base/dgeequ' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var R = new Float64Array( 3 ); +* var C = new Float64Array( 3 ); +* +* var out = dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); +* // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +*/ + +// 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 dgeequ; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgeequ = main; +} else { + dgeequ = tmp; +} + + +// EXPORTS // + +module.exports = dgeequ; + +// exports: { "ndarray": "dgeequ.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/main.js new file mode 100644 index 000000000000..7ad4468a8d34 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dgeequ = require( './dgeequ.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgeequ, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgeequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/ndarray.js new file mode 100644 index 000000000000..fa783083e2b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/lib/ndarray.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number using alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of rows of matrix `A` +* @param {NonNegativeInteger} N - number of columns of matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} R - output row scale factors +* @param {integer} strideR - stride length for `R` +* @param {NonNegativeInteger} offsetR - starting index for `R` +* @param {Float64Array} C - output column scale factors +* @param {integer} strideC - stride length for `C` +* @param {NonNegativeInteger} offsetC - starting index for `C` +* @throws {RangeError} first argument must be a nonnegative integer +* @throws {RangeError} second argument must be a nonnegative integer +* @returns {Array} a 4-element array containing `[ rowcnd, colcnd, amax, info ]` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var R = new Float64Array( 3 ); +* var C = new Float64Array( 3 ); +* +* var out = dgeequ( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 ); +* // returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ] +*/ +function dgeequ( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC ) { // eslint-disable-line max-len, max-params + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + return base( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgeequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/package.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/package.json new file mode 100644 index 000000000000..81ddd33e16cb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dgeequ", + "version": "0.0.0", + "description": "Compute row and column scaling factors intended to equilibrate an M-by-N real matrix A and reduce its condition number", + "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", + "dgeequ", + "scaling", + "factorization", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_3x3.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_3x3.json new file mode 100644 index 000000000000..b0ac0aaef52d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_3x3.json @@ -0,0 +1,65 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ] + ], + "A": [ + 1, + 4, + 7, + 2, + 5, + 8, + 3, + 6, + 9 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_3x4.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_3x4.json new file mode 100644 index 000000000000..298a4eb13db1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_3x4.json @@ -0,0 +1,73 @@ +{ + "order": "column-major", + "M": 3, + "N": 4, + "A_mat": [ + [ + 1, + 5, + 9, + 13 + ], + [ + 2, + 6, + 10, + 14 + ], + [ + 3, + 7, + 11, + 15 + ] + ], + "A": [ + 1, + 2, + 3, + 5, + 6, + 7, + 9, + 10, + 11, + 13, + 14, + 15 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.07692307692307693, + 0.07142857142857142, + 0.06666666666666667 + ], + "C_expected": [ + 5, + 2.142857142857143, + 1.3636363636363638, + 1 + ], + "rowcnd": 0.8666666666666667, + "colcnd": 0.2, + "amax": 15, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_lda.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_lda.json new file mode 100644 index 000000000000..248c94ffcc23 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_lda.json @@ -0,0 +1,71 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ] + ], + "A": [ + 1, + 4, + 7, + 0, + 0, + 2, + 5, + 8, + 0, + 0, + 3, + 6, + 9, + 0, + 0 + ], + "LDA": 5, + "strideA1": 1, + "strideA2": 5, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_zero_column.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_zero_column.json new file mode 100644 index 000000000000..3e6acbff4fcd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/column_major_zero_column.json @@ -0,0 +1,65 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A_mat": [ + [ + 1, + 0, + 3 + ], + [ + 4, + 0, + 6 + ], + [ + 7, + 0, + 9 + ] + ], + "A": [ + 1, + 4, + 7, + 0, + 0, + 0, + 3, + 6, + 9 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 0.7777777777777777, + 0, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0, + "amax": 9, + "info": 5 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_a_offset.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_a_offset.json new file mode 100644 index 000000000000..a53c6bc97363 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_a_offset.json @@ -0,0 +1,51 @@ +{ + "M": 3, + "N": 3, + "A": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "R": [ + 9999, + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 1, + "C": [ + 9999, + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 1, + "R_expected": [ + 9999, + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 9999, + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_a_strides.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_a_strides.json new file mode 100644 index 000000000000..7fb7dbfbf875 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_a_strides.json @@ -0,0 +1,67 @@ +{ + "M": 3, + "N": 3, + "A": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 9, + 9999 + ], + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "R": [ + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideR": 2, + "offsetR": 0, + "C": [ + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideC": 2, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 9999, + 0.16666666666666666, + 9999, + 0.1111111111111111, + 9999 + ], + "C_expected": [ + 1.2857142857142858, + 9999, + 1.125, + 9999, + 1, + 9999 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_mixed_strides.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_mixed_strides.json new file mode 100644 index 000000000000..953a5749df61 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_mixed_strides.json @@ -0,0 +1,46 @@ +{ + "M": 3, + "N": 3, + "A": [ + 3, + 2, + 1, + 6, + 5, + 4, + 9, + 8, + 7 + ], + "strideA1": 3, + "strideA2": -1, + "offsetA": 2, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_negative_strides.json new file mode 100644 index 000000000000..67c3f3b8c911 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_negative_strides.json @@ -0,0 +1,46 @@ +{ + "M": 3, + "N": 3, + "A": [ + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideA1": -1, + "strideA2": -3, + "offsetA": 8, + "R": [ + 0, + 0, + 0 + ], + "strideR": -1, + "offsetR": 2, + "C": [ + 0, + 0, + 0 + ], + "strideC": -1, + "offsetC": 2, + "R_expected": [ + 0.1111111111111111, + 0.125, + 0.14285714285714285 + ], + "C_expected": [ + 1, + 1.5, + 3 + ], + "rowcnd": 0.7777777777777778, + "colcnd": 0.3333333333333333, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_r_c_offset.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_r_c_offset.json new file mode 100644 index 000000000000..d3b94a83493b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_r_c_offset.json @@ -0,0 +1,50 @@ +{ + "M": 3, + "N": 3, + "A": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "R": [ + 9999, + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 1, + "C": [ + 9999, + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 1, + "R_expected": [ + 9999, + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 9999, + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_r_c_strides.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_r_c_strides.json new file mode 100644 index 000000000000..13da71e36103 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/ndarray_r_c_strides.json @@ -0,0 +1,58 @@ +{ + "M": 3, + "N": 3, + "A": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "R": [ + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideR": 2, + "offsetR": 0, + "C": [ + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideC": 2, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 9999, + 0.16666666666666666, + 9999, + 0.1111111111111111, + 9999 + ], + "C_expected": [ + 1.2857142857142858, + 9999, + 1.125, + 9999, + 1, + 9999 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_3x3.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_3x3.json new file mode 100644 index 000000000000..7e3d27b62d24 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_3x3.json @@ -0,0 +1,65 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ] + ], + "A": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_3x4.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_3x4.json new file mode 100644 index 000000000000..28459a3b8a2f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_3x4.json @@ -0,0 +1,73 @@ +{ + "order": "row-major", + "M": 3, + "N": 4, + "A_mat": [ + [ + 1, + 5, + 9, + 13 + ], + [ + 2, + 6, + 10, + 14 + ], + [ + 3, + 7, + 11, + 15 + ] + ], + "A": [ + 1, + 5, + 9, + 13, + 2, + 6, + 10, + 14, + 3, + 7, + 11, + 15 + ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.07692307692307693, + 0.07142857142857142, + 0.06666666666666667 + ], + "C_expected": [ + 5, + 2.142857142857143, + 1.3636363636363638, + 1 + ], + "rowcnd": 0.8666666666666667, + "colcnd": 0.2, + "amax": 15, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_lda.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_lda.json new file mode 100644 index 000000000000..e32c918490e1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_lda.json @@ -0,0 +1,71 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ] + ], + "A": [ + 1, + 2, + 3, + 0, + 0, + 4, + 5, + 6, + 0, + 0, + 7, + 8, + 9, + 0, + 0 + ], + "LDA": 5, + "strideA1": 5, + "strideA2": 1, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.3333333333333333, + 0.16666666666666666, + 0.1111111111111111 + ], + "C_expected": [ + 1.2857142857142858, + 1.125, + 1 + ], + "rowcnd": 0.3333333333333333, + "colcnd": 0.7777777777777777, + "amax": 9, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_varied_magnitudes.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_varied_magnitudes.json new file mode 100644 index 000000000000..7f80e7708d5b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_varied_magnitudes.json @@ -0,0 +1,55 @@ +{ + "order": "row-major", + "M": 2, + "N": 3, + "A_mat": [ + [ + 1, + 100, + 10 + ], + [ + 0.01, + 1, + 0.1 + ] + ], + "A": [ + 1, + 100, + 10, + 0.01, + 1, + 0.1 + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "R": [ + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 0.01, + 1 + ], + "C_expected": [ + 100, + 1, + 10 + ], + "rowcnd": 0.01, + "colcnd": 0.01, + "amax": 100, + "info": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_zero_row.json b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_zero_row.json new file mode 100644 index 000000000000..b449c07a6322 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/fixtures/row_major_zero_row.json @@ -0,0 +1,57 @@ +{ + "order": "row-major", + "M": 3, + "N": 2, + "A_mat": [ + [ + 1, + 2 + ], + [ + 0, + 0 + ], + [ + 5, + 6 + ] + ], + "A": [ + 1, + 2, + 0, + 0, + 5, + 6 + ], + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "R": [ + 0, + 0, + 0 + ], + "strideR": 1, + "offsetR": 0, + "C": [ + 0, + 0 + ], + "strideC": 1, + "offsetC": 0, + "R_expected": [ + 2, + 0, + 6 + ], + "C_expected": [ + 0, + 0 + ], + "rowcnd": 0, + "colcnd": 0, + "amax": 6, + "info": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.dgeequ.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.dgeequ.js new file mode 100644 index 000000000000..e56bb6afd6dc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.dgeequ.js @@ -0,0 +1,465 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dgeequ = require( './../lib/dgeequ.js' ); + + +// FIXTURES // + +var ROW_MAJOR_3X3 = require( './fixtures/row_major_3x3.json' ); +var COLUMN_MAJOR_3X3 = require( './fixtures/column_major_3x3.json' ); +var ROW_MAJOR_3X4 = require( './fixtures/row_major_3x4.json' ); +var COLUMN_MAJOR_3X4 = require( './fixtures/column_major_3x4.json' ); +var ROW_MAJOR_ZERO_ROW = require( './fixtures/row_major_zero_row.json' ); +var COLUMN_MAJOR_ZERO_COL = require( './fixtures/column_major_zero_column.json' ); +var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); +var COLUMN_MAJOR_LDA = require( './fixtures/column_major_lda.json' ); +var ROW_MAJOR_VARIED = require( './fixtures/row_major_varied_magnitudes.json' ); + + +// FUNCTIONS // + +/** +* Tests approximate equality of two arrays. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance multiplier +*/ +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 dgeequ, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dgeequ.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR_3X3; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( value, data.M, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.M ), new Float64Array( data.N ) ); + }; + } +}); + +tape( 'the function throws an error if provided a row dimension less than zero', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR_3X3; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( data.order, value, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.M ), new Float64Array( data.N ) ); + }; + } +}); + +tape( 'the function throws an error if provided a column dimension less than zero', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR_3X3; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( data.order, data.M, value, new Float64Array( data.A ), data.LDA, new Float64Array( data.M ), new Float64Array( data.N ) ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid LDA value (row-major)', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR_3X3; + + values = [ + 0, + 1, + 2 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( data.order, data.M, data.N, new Float64Array( data.A ), value, new Float64Array( data.M ), new Float64Array( data.N ) ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid LDA value (column-major)', function test( t ) { + var values; + var data; + var i; + + data = COLUMN_MAJOR_3X3; + + values = [ + 0, + 1, + 2 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( data.order, data.M, data.N, new Float64Array( data.A ), value, new Float64Array( data.M ), new Float64Array( data.N ) ); + }; + } +}); + +tape( 'the function computes row and column scaling factors (row-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_3X3; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function computes row and column scaling factors (column-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = COLUMN_MAJOR_3X3; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function computes row and column scaling factors for rectangular matrices (row-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_3X4; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function computes row and column scaling factors for rectangular matrices (column-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = COLUMN_MAJOR_3X4; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function returns a non-zero info code when a row is zero (row-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_ZERO_ROW; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + t.strictEqual( out[ 0 ], data.rowcnd, 'returns expected rowcnd' ); + t.strictEqual( out[ 1 ], data.colcnd, 'returns expected colcnd' ); + t.strictEqual( out[ 2 ], data.amax, 'returns expected amax' ); + t.deepEqual( R, new Float64Array( data.R_expected ), 'returns expected R' ); + + t.end(); +}); + +tape( 'the function returns a non-zero info code when a column is zero (column-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = COLUMN_MAJOR_ZERO_COL; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + t.strictEqual( out[ 1 ], data.colcnd, 'returns expected colcnd' ); + t.strictEqual( out[ 2 ], data.amax, 'returns expected amax' ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an LDA parameter (row-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_LDA; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an LDA parameter (column-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = COLUMN_MAJOR_LDA; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function handles matrices with varied magnitudes', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_VARIED; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.order, data.M, data.N, A, data.LDA, R, C ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function returns early if M = 0 or N = 0', function test( t ) { + var out; + var A; + var R; + var C; + + A = new Float64Array( 0 ); + R = new Float64Array( 0 ); + C = new Float64Array( 0 ); + + out = dgeequ( 'row-major', 0, 0, A, 1, R, C ); + t.deepEqual( out, [ 1.0, 1.0, 0.0, 0 ], 'returns expected value' ); + + out = dgeequ( 'row-major', 0, 3, A, 3, R, C ); + t.deepEqual( out, [ 1.0, 1.0, 0.0, 0 ], 'returns expected value' ); + + out = dgeequ( 'row-major', 3, 0, A, 1, R, C ); + t.deepEqual( out, [ 1.0, 1.0, 0.0, 0 ], 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.js new file mode 100644 index 000000000000..8ec3fae17fe5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dgeequ = 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 dgeequ, '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 dgeequ.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 dgeequ = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgeequ, 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 dgeequ; + var main; + + main = require( './../lib/dgeequ.js' ); + + dgeequ = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgeequ, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.ndarray.js new file mode 100644 index 000000000000..984376f58010 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgeequ/test/test.ndarray.js @@ -0,0 +1,416 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dgeequ = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ROW_MAJOR_3X3 = require( './fixtures/row_major_3x3.json' ); +var COLUMN_MAJOR_3X3 = require( './fixtures/column_major_3x3.json' ); +var ROW_MAJOR_3X4 = require( './fixtures/row_major_3x4.json' ); +var COLUMN_MAJOR_3X4 = require( './fixtures/column_major_3x4.json' ); +var NDARRAY_A_STRIDES = require( './fixtures/ndarray_a_strides.json' ); +var NDARRAY_A_OFFSET = require( './fixtures/ndarray_a_offset.json' ); +var NDARRAY_RC_STRIDES = require( './fixtures/ndarray_r_c_strides.json' ); +var NDARRAY_RC_OFFSET = require( './fixtures/ndarray_r_c_offset.json' ); +var NDARRAY_NEG_STRIDES = require( './fixtures/ndarray_negative_strides.json' ); +var NDARRAY_MIXED_STRIDES = require( './fixtures/ndarray_mixed_strides.json' ); + + +// FUNCTIONS // + +/** +* Tests approximate equality of two arrays. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance multiplier +*/ +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 dgeequ, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dgeequ.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a row dimension less than zero', function test( t ) { + var values; + var A; + var R; + var C; + var i; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + R = new Float64Array( 2 ); + C = new Float64Array( 2 ); + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( value, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a column dimension less than zero', function test( t ) { + var values; + var A; + var R; + var C; + var i; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + R = new Float64Array( 2 ); + C = new Float64Array( 2 ); + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgeequ( 2, value, A, 2, 1, 0, R, 1, 0, C, 1, 0 ); + }; + } +}); + +tape( 'the function computes scaling factors (row-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_3X3; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function computes scaling factors (column-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = COLUMN_MAJOR_3X3; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function computes scaling factors for rectangular matrices (row-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = ROW_MAJOR_3X4; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function computes scaling factors for rectangular matrices (column-major)', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = COLUMN_MAJOR_3X4; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports non-unit strides for A, R, and C', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = NDARRAY_A_STRIDES; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports index offsets for A, R, and C', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = NDARRAY_A_OFFSET; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports non-unit strides for R and C', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = NDARRAY_RC_STRIDES; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports index offsets for R and C', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = NDARRAY_RC_OFFSET; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = NDARRAY_NEG_STRIDES; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function supports mixed strides', function test( t ) { + var data; + var out; + var A; + var R; + var C; + + data = NDARRAY_MIXED_STRIDES; + + A = new Float64Array( data.A ); + R = new Float64Array( data.R ); + C = new Float64Array( data.C ); + + out = dgeequ( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, R, data.strideR, data.offsetR, C, data.strideC, data.offsetC ); + + t.strictEqual( out[ 3 ], data.info, 'returns expected info' ); + isApprox( t, [ out[ 0 ] ], [ data.rowcnd ], 2.0 ); + isApprox( t, [ out[ 1 ] ], [ data.colcnd ], 2.0 ); + isApprox( t, [ out[ 2 ] ], [ data.amax ], 2.0 ); + isApprox( t, R, new Float64Array( data.R_expected ), 2.0 ); + isApprox( t, C, new Float64Array( data.C_expected ), 2.0 ); + + t.end(); +}); + +tape( 'the function returns early if M = 0 or N = 0', function test( t ) { + var out; + var A; + var R; + var C; + + A = new Float64Array( 0 ); + R = new Float64Array( 0 ); + C = new Float64Array( 0 ); + + out = dgeequ( 0, 0, A, 1, 1, 0, R, 1, 0, C, 1, 0 ); + t.deepEqual( out, [ 1.0, 1.0, 0.0, 0 ], 'returns expected value' ); + + out = dgeequ( 0, 3, A, 1, 1, 0, R, 1, 0, C, 1, 0 ); + t.deepEqual( out, [ 1.0, 1.0, 0.0, 0 ], 'returns expected value' ); + + out = dgeequ( 3, 0, A, 1, 1, 0, R, 1, 0, C, 1, 0 ); + t.deepEqual( out, [ 1.0, 1.0, 0.0, 0 ], 'returns expected value' ); + + t.end(); +});