From 8e7ce9f64544198ec1090cbb46aaf932285af3e4 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 7 Aug 2024 18:34:50 +0530 Subject: [PATCH 1/5] feat: init lapack/base/dlaqge --- .../lapack/base/dlaqge/examples/index.js | 30 ++++ .../@stdlib/lapack/base/dlaqge/lib/base.js | 143 ++++++++++++++++++ .../@stdlib/lapack/base/dlaqge/lib/dlaqge.js | 76 ++++++++++ .../@stdlib/lapack/base/dlaqge/lib/ndarray.js | 68 +++++++++ 4 files changed, 317 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/lib/dlaqge.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js new file mode 100644 index 00000000000..54a3eef27b8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js @@ -0,0 +1,30 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dlaqge = require( './../lib/base.js' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var R = new Float64Array( [ 1.0, 11.0 ] ); +var C = new Float64Array( [ 1.0, 11.0 ] ); + +var out = dlaqge( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); +console.log( out ); +console.log( A ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js new file mode 100644 index 00000000000..987feaa04e2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in 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 - row scale factors +* @param {NonNegativeInteger} strideR - stride length for `R` +* @param {NonNegativeInteger} offsetR - starting index of `R` +* @param {Float64Array} C - column scale factors +* @param {NonNegativeInteger} strideC - stride length for `C` +* @param {NonNegativeInteger} offsetC - starting index of `C` +* @param {number} rowcnd - ratio of the smallest to the largest row scale factor +* @param {number} colcnd - ratio of the smallest to the largest column scale factor +* @param {number} amax - absolute value of the largest matrix entry +* @returns {string} equilibration factor +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.0 ] +*/ +function dlaqge( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC, rowcnd, colcnd, amax ) { + var thresh; + var large; + var small; + var cj; + var i; + var j; + + if ( M <= 0 || N <= 0 ) { + return 'N'; + } + + thresh = 0.1; + small = 1.0020841800044864E-292; + large = 1.0 / small; + if ( rowcnd >= thresh && amax >= small && amax <= large ) { + // No row scaling + if ( colcnd >= thresh ) { + // No column scaling + return 'N'; + } + // Column scaling + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( j = 0; j < N; j++ ) { + cj = C[ offsetC + ( j * strideC ) ]; + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] *= cj; + } + } + return 'C'; + } + // column-major + for ( j = 0; j < N; j++ ) { + cj = C[ offsetC + ( j * strideC ) ]; + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * strideA2 ) + ( j * strideA1 ) ] *= cj; + } + } + return 'C'; + } + if ( colcnd >= thresh ) { + // Row scaling, no column scaling + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( j = 0; j < N; j++ ) { + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] *= R[ offsetR + ( i * strideR ) ]; + } + } + return 'R'; + } + // column-major + for ( j = 0; j < N; j++ ) { + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * strideA2 ) + ( j * strideA1 ) ] *= R[ offsetR + ( i * strideR ) ]; + } + } + return 'R'; + } + // Row and column scaling + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( j = 0; j < N; j++ ) { + cj = C[ offsetC + ( j * strideC ) ]; + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] *= cj * R[ offsetR + ( i * strideR ) ]; + } + } + return 'B'; + } + // column-major + for ( j = 0; j < N; j++ ) { + cj = C[ offsetC + ( j * strideC ) ]; + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * strideA2 ) + ( j * strideA1 ) ] *= cj * R[ offsetR + ( i * strideR ) ]; + } + } + return 'B'; +} + + +// EXPORTS // + +module.exports = dlaqge; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/dlaqge.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/dlaqge.js new file mode 100644 index 00000000000..1e423877d1d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/dlaqge.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} R - row scale factors +* @param {Float64Array} C - column scale factors +* @param {number} rowcnd - ratio of the smallest to the largest row scale factor +* @param {number} colcnd - ratio of the smallest to the largest column scale factor +* @param {number} amax - absolute value of the largest matrix entry +* @throws {TypeError} first argument must be a valid order +* @returns {string} equilibration factor +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.0 ] +*/ +function dlaqge( order, M, N, A, LDA, R, C, rowcnd, colcnd, amax ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( M, N, A, sa1, sa2, 0, R, 1, 0, C, 1, 0, rowcnd, colcnd, amax ); +} + + +// EXPORTS // + +module.exports = dlaqge; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js new file mode 100644 index 00000000000..0a48c455025 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. +* +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in 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 - row scale factors +* @param {NonNegativeInteger} strideR - stride length for `R` +* @param {NonNegativeInteger} offsetR - starting index of `R` +* @param {Float64Array} C - column scale factors +* @param {NonNegativeInteger} strideC - stride length for `C` +* @param {NonNegativeInteger} offsetC - starting index of `C` +* @param {number} rowcnd - ratio of the smallest to the largest row scale factor +* @param {number} colcnd - ratio of the smallest to the largest column scale factor +* @param {number} amax - absolute value of the largest matrix entry +* @returns {string} equilibration factor +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.0 ] +*/ +function dlaqge( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC, rowcnd, colcnd, amax ) { + return base( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC, rowcnd, colcnd, amax ); +} + + +// EXPORTS // + +module.exports = dlaqge; From 48115537748d2a96411649a74b19245e49147706 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 7 Aug 2024 19:48:12 +0530 Subject: [PATCH 2/5] docs: add README --- .../@stdlib/lapack/base/dlaqge/README.md | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/README.md diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md b/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md new file mode 100644 index 00000000000..c43d87127d6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md @@ -0,0 +1,259 @@ + + +# dlaqge + +> Equilibrate a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. + +
+ +## Usage + +```javascript +var dlaqge = require( '@stdlib/lapack/base/dlaqge' ); +``` + +#### dlaqge( order, M, N, A, LDA, R, C, rowcnd, colcnd, amax ) + +Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var R = new Float64Array( [ 1.0, 11.0 ] ); +var C = new Float64Array( [ 1.0, 11.0 ] ); + +var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); +// out => 'B' +// A => [ 1.0, 22.0, 33.0, 484.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **R**: row scale factors. +- **C**: column scale factors. +- **rowcnd**: ratio of the smallest to the largest row scale factor. +- **colcnd**: ratio of the smallest to the largest column scale factor. +- **amax**: absolute value of the largest matrix entry. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var R0 = new Float64Array( [ 0.0, 1.0, 11.0 ] ); +var C0 = new Float64Array( [ 0.0, 1.0, 11.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var R1 = new Float64Array( R0.buffer, R0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var C1 = new Float64Array( C0.buffer, C0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = dlaqge( 'row-major', 2, 2, A1, 2, R1, C1, 1.0/11.0, 1.0/11.0, 4.0 ); +// A0 => [ 0.0, 1.0, 22.0, 33.0, 484.0 ] +``` + +#### dlaqge.ndarray( M, N, A, sa1, sa2, oa, R, sr, or, C, sc, oc, rc, cc, ax ) + +Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var R = new Float64Array( [ 1.0, 11.0 ] ); +var C = new Float64Array( [ 1.0, 11.0 ] ); + +var out = dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // eslint-disable-line max-len +// out => 'B' +// A => [ 1.0, 22.0, 33.0, 484.0 ] +``` + +The function has the following parameters: + +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **R**: row scale factors. +- **sr**: stride length for `R`. +- **or**: starting index of `R`. +- **C**: row scale factors. +- **sc**: stride length for `C`. +- **oc**: starting index of `C`. +- **rc**: ratio of the smallest to the largest row scale factor. +- **cc**: ratio of the smallest to the largest column scale factor. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var R = new Float64Array( [ 0.0, 1.0, 11.0 ] ); +var C = new Float64Array( [ 0.0, 0.0, 1.0, 11.0 ] ); + +var out = dlaqge.ndarray( 2, 2, A, 2, 1, 1, R, 1, 1, C, 1, 2, 1.0/11.0, 1.0/11.0, 4.0 ); // eslint-disable-line max-len +// out => 'B' +// A => [ 0.0, 1.0, 22.0, 33.0, 484.0 ] +``` + +
+ + + +
+ +## Notes + +- `dlaqge()` corresponds to the [LAPACK][lapack] routine [`dlaqge`][lapack-dlaqge]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlaqge = require( '@stdlib/lapack/base/dlaqge' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var R = new Float64Array( [ 1.0, 11.0 ] ); +var C = new Float64Array( [ 1.0, 11.0 ] ); + +var out = dlaqge( 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); +console.log( out ); +console.log( A ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + From 74caf45b48fce4c75e8cc87b123cb78a6605694a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 7 Aug 2024 20:00:04 +0530 Subject: [PATCH 3/5] chore: add other files --- .../@stdlib/lapack/base/dlaqge/README.md | 5 + .../lapack/base/dlaqge/benchmark/benchmark.js | 116 +++++ .../dlaqge/benchmark/benchmark.ndarray.js | 116 +++++ .../@stdlib/lapack/base/dlaqge/docs/repl.txt | 129 +++++ .../lapack/base/dlaqge/docs/types/index.d.ts | 133 +++++ .../lapack/base/dlaqge/docs/types/test.ts | 483 ++++++++++++++++++ .../@stdlib/lapack/base/dlaqge/lib/index.js | 72 +++ .../@stdlib/lapack/base/dlaqge/lib/main.js | 35 ++ .../@stdlib/lapack/base/dlaqge/lib/ndarray.js | 2 +- .../@stdlib/lapack/base/dlaqge/package.json | 70 +++ .../lapack/base/dlaqge/test/test.dlaqge.js | 242 +++++++++ .../@stdlib/lapack/base/dlaqge/test/test.js | 83 +++ .../lapack/base/dlaqge/test/test.ndarray.js | 148 ++++++ 13 files changed, 1633 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.dlaqge.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md b/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md index c43d87127d6..4093bc2eb01 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md @@ -136,6 +136,11 @@ var out = dlaqge.ndarray( 2, 2, A, 2, 1, 1, R, 1, 1, C, 1, 2, 1.0/11.0, 1.0/11.0 ## Notes - `dlaqge()` corresponds to the [LAPACK][lapack] routine [`dlaqge`][lapack-dlaqge]. +- The output of function specifies form of equilibration that was done. +- 'N' signifies No equilibration +- 'R' signifies `A` has been premultiplied by `diag(R)` i.e. Row Equilibration +- 'C' signifies `A` has been premultiplied by `diag(C)` i.e. Column Equilibration +- 'B' signifies `A` has been replaced by `diag(R) * A * diag(C)` i.e. both row and column equilibration diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.js new file mode 100644 index 00000000000..244cea9d892 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlaqge = require( './../lib/dlaqge.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var A; + var M; + var R; + var C; + + opts = { + 'dtype': 'float64' + }; + M = floor( N / 2 ); + + R = uniform( N, -10.0, 10.0, opts ); + C = uniform( N, -10.0, 10.0, opts ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + A = uniform( M*N, -10.0, 10.0, opts ); + z = dlaqge( 'row-major', M, N, A, N, R, C, 1.0/11.0, 1.0/11.0, 10.0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':order=row-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..00e1baba57d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/benchmark/benchmark.ndarray.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlaqge = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var A; + var M; + var R; + var C; + + opts = { + 'dtype': 'float64' + }; + M = floor( N / 2 ); + + R = uniform( N, -10.0, 10.0, opts ); + C = uniform( N, -10.0, 10.0, opts ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + A = uniform( M*N, -10.0, 10.0, opts ); + z = dlaqge( M, N, A, N, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 10.0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:order=row-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/repl.txt new file mode 100644 index 00000000000..1886a1d2812 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/repl.txt @@ -0,0 +1,129 @@ + +{{alias}}( order, M, N, A, LDA, R, C, rowcnd, colcnd, amax ) + Equilibrates a general `M` by `N` matrix `A` using the row and scaling + factors in vectors `R` and `C`. + + 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 in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + R: Float64Array + Row scale factors. + + C: Float64Array + Column scale factors. + + rowcnd: number + Ratio of the smallest to the largest row scale factor. + + colcnd: number + Ratio of the smallest to the largest column scale factor. + + amax: number + Absolute value of the largest matrix entry. + + Returns + ------- + out: string + Equilibration factor. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var R = new {{alias:@stdlib/array/float64}}( [ 1.0, 11.0 ] ); + > var C = new {{alias:@stdlib/array/float64}}( [ 1.0, 11.0 ] ); + > {{alias}}( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); + > A + [ 1.0, 22.0, 33.0, 484.0 ] + + +{{alias}}.ndarray( M, N, A, sa1, sa2, oa, R, sr, or, C, sc, oc, rc, cc, ax ) + Equilibrates a general `M` by `N` matrix `A` using the row and scaling + factors in vectors `R` and `C` 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 in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + 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 + Row scale factors. + + sr: integer + Stride length for `R`. + + or: integer + Starting index of `R`. + + C: Float64Array + Column scale factors. + + sc: integer + Stride length for `C`. + + oc: integer + Starting index of `C`. + + rc: number + Ratio of the smallest to the largest row scale factor. + + cc: number + Ratio of the smallest to the largest column scale factor. + + ax: number + Absolute value of the largest matrix entry. + + Returns + ------- + out: string + Equilibration factor. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var R = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 11.0 ] ); + > var C = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 11.0 ] ); + > var s = 1.0/11.0; + > {{alias}}.ndarray( 2, 2, A, 2, 1, 0, R, 1, 1, C, 1, 1, s, s, 4.0 ); + > A + [ 1.0, 22.0, 33.0, 484.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/index.d.ts new file mode 100644 index 00000000000..179be01fa9e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/index.d.ts @@ -0,0 +1,133 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `dlaqge`. +*/ +interface Routine { + /** + * Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. + * + * @param order - storage layout + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param R - row scale factors + * @param C - column scale factors + * @param rowcnd - ratio of the smallest to the largest row scale factor + * @param colcnd - ratio of the smallest to the largest column scale factor + * @param amax - absolute value of the largest matrix entry + * @returns equilibration factor + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var R = new Float64Array( [ 1.0, 11.0 ] ); + * var C = new Float64Array( [ 1.0, 11.0 ] ); + * + * var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); + * // out => 'B' + * // A => [ 1.0, 22.0, 33.0, 484.0 ] + */ + ( order: Layout, M: number, N: number, A: Float64Array, LDA: number, R: Float64Array, C: Float64Array, rowcnd: number, colcnd: number, amax: number ): string; + + /** + * Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C` using alternative indexing semantics. + * + * @param M - number of rows in matrix `A` + * @param N - number of columns in 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 - row scale factors + * @param strideR - stride length for `R` + * @param offsetR - starting index of `R` + * @param C - column scale factors + * @param strideC - stride length for `C` + * @param offsetC - starting index of `C` + * @param rowcnd - ratio of the smallest to the largest row scale factor + * @param colcnd - ratio of the smallest to the largest column scale factor + * @param amax - absolute value of the largest matrix entry + * @returns equilibration factor + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var R = new Float64Array( [ 1.0, 11.0 ] ); + * var C = new Float64Array( [ 1.0, 11.0 ] ); + * + * var out = dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); + * // out => 'B' + * // A => [ 1.0, 22.0, 33.0, 484.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, rowcnd: number, colcnd: number, amax: number ): string; +} + +/** +* Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. +* +* @param order - storage layout +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param R - row scale factors +* @param C - column scale factors +* @param rowcnd - ratio of the smallest to the largest row scale factor +* @param colcnd - ratio of the smallest to the largest column scale factor +* @param amax - absolute value of the largest matrix entry +* @returns equilibration factor +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.0 ] +*/ +declare var dlaqge: Routine; + + +// EXPORTS // + +export = dlaqge; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/test.ts new file mode 100644 index 00000000000..5993c51682c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/docs/types/test.ts @@ -0,0 +1,483 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dlaqge = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectType string +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 5, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( true, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( false, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( null, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( void 0, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( [], 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( {}, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( ( x: number ): number => x, 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', '5', 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', true, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', false, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', null, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', void 0, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', [], 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', {}, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', ( x: number ): number => x, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, '5', A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, true, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, false, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, null, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, void 0, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, [], A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, {}, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, ( x: number ): number => x, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, '5', 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, 5, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, true, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, false, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, null, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, void 0, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, [], 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, {}, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, ( x: number ): number => x, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, '5', R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, true, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, false, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, null, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, void 0, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, [], R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, {}, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, ( x: number ): number => x, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, 2, '5', C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, 5, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, true, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, false, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, null, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, void 0, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, [], C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, {}, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, ( x: number ): number => x, C, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, 2, R, '5', 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, 5, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, true, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, false, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, null, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, void 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, [], 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, {}, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, ( x: number ): number => x, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, 2, R, C, '5', 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, true, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, false, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, null, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, void 0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, [], 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, {}, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, ( x: number ): number => x, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, '5', 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, true, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, false, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, null, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, void 0, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, [], 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, {}, 4.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, ( x: number ): number => x, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, '5' ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, true ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, false ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, null ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, void 0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, [] ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, {} ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge(); // $ExpectError + dlaqge( 'row-major' ); // $ExpectError + dlaqge( 'row-major', 2 ); // $ExpectError + dlaqge( 'row-major', 2, 2 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0 ); // $ExpectError + dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectType string +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( '5', 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( true, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( false, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( null, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( void 0, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( [], 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( {}, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, '5', A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, true, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, false, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, null, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, void 0, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, [], A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, {}, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, ( x: number ): number => x, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, '5', 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, 5, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, true, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, false, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, null, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, void 0, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, [], 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, {}, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, ( x: number ): number => x, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, '5', 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, true, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, false, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, null, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, void 0, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, [], 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, {}, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, ( x: number ): number => x, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, '5', 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, true, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, false, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, null, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, void 0, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, [], 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, {}, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, ( x: number ): number => x, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, '5', R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, true, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, false, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, null, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, void 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, [], R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, {}, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, ( x: number ): number => x, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, '5', 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, 5, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, true, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, false, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, null, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, void 0, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, [], 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, {}, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, '5', 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, true, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, false, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, null, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, void 0, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, [], 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, {}, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, ( x: number ): number => x, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, '5', C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, true, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, false, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, null, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, void 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, [], C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, {}, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, ( x: number ): number => x, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, '5', 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, 5, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, true, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, false, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, null, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, void 0, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, [], 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, {}, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, ( x: number ): number => x, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, '5', 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, true, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, false, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, null, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, void 0, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, [], 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, {}, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, ( x: number ): number => x, 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, '5', 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, true, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, false, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, null, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, void 0, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, [], 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, {}, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, ( x: number ): number => x, 1.0/11.0, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, '5', 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, true, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, false, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, null, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, void 0, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, [], 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, {}, 1.0/11.0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, ( x: number ): number => x, 1.0/11.0, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, '5', 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, true, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, false, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, null, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, void 0, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, [], 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, {}, 4.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, ( x: number ): number => x, 4.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifteenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, '5' ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, true ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, false ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, null ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, void 0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, [] ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, {} ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + const R = new Float64Array( [ 1.0, 11.0 ] ); + const C = new Float64Array( [ 1.0, 11.0 ] ); + + dlaqge.ndarray(); // $ExpectError + dlaqge.ndarray( 2 ); // $ExpectError + dlaqge.ndarray( 2, 2 ); // $ExpectError + dlaqge.ndarray( 2, 2, A ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0 ); // $ExpectError + dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/index.js new file mode 100644 index 00000000000..6bcdccd0885 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to equilibrate a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. +* +* @module @stdlib/lapack/base/dlaqge +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaqge = require( '@stdlib/lapack/base/dlaqge' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaqge = require( '@stdlib/lapack/base/dlaqge' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var R = new Float64Array( [ 1.0, 11.0 ] ); +* var C = new Float64Array( [ 1.0, 11.0 ] ); +* +* var out = dlaqge.ndarray( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); +* // out => 'B' +* // A => [ 1.0, 22.0, 33.0, 484.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 dlaqge; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlaqge = main; +} else { + dlaqge = tmp; +} + + +// EXPORTS // + +module.exports = dlaqge; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/main.js new file mode 100644 index 00000000000..9e8614e2565 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlaqge = require( './dlaqge.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlaqge, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlaqge; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js index 0a48c455025..6c30bfd262f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/ndarray.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`. +* Equilibrates a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C` using alternative indexing semantics. * * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/package.json b/lib/node_modules/@stdlib/lapack/base/dlaqge/package.json new file mode 100644 index 00000000000..32960868220 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/lapack/base/dlacpy", + "version": "0.0.0", + "description": "Equilibrate a general `M` by `N` matrix `A` using the row and scaling factors in vectors `R` and `C`.", + "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", + "dlaqge", + "equilibrate", + "scaling", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.dlaqge.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.dlaqge.js new file mode 100644 index 00000000000..6de3ba7b46b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.dlaqge.js @@ -0,0 +1,242 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlaqge = require( './../lib/dlaqge.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaqge, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlaqge.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var R; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + R = new Float64Array( 4 ); + + 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() { + dlaqge( value, 2, 2, A, 2, R, R, 1.0, 1.0, 4.0 ); + }; + } +}); + +tape( 'the function scales both row and column of a square matrix (row-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + R = new Float64Array( [ 1.0, 11.0 ] ); + C = new Float64Array( [ 1.0, 11.0 ] ); + + out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); + expected = new Float64Array( [ 1.0, 22.0, 33.0, 484.0 ] ); + t.strictEqual( out, 'B', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales both row and column of a square matrix (column-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + R = new Float64Array( [ 1.0, 11.0 ] ); + C = new Float64Array( [ 1.0, 11.0 ] ); + + out = dlaqge( 'column-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); + expected = new Float64Array( [ 1.0, 33.0, 22.0, 484.0 ] ); + t.strictEqual( out, 'B', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales both row and column of a rectangular matrix (row-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + R = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + C = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + + out = dlaqge( 'row-major', 2, 3, A, 3, R, C, 1.0/13.0, 1.0/13.0, 4.0 ); + expected = new Float64Array( [ 1.0, 22.0, 39.0, 44.0, 605.0, 858.0 ] ); + t.strictEqual( out, 'B', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales both row and column of a rectangular matrix (column-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + R = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + C = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + + out = dlaqge( 'column-major', 2, 3, A, 3, R, C, 1.0/13.0, 1.0/13.0, 4.0 ); + expected = new Float64Array( [ 1.0, 22.0, 39.0, 44.0, 605.0, 858.0 ] ); + t.strictEqual( out, 'B', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales column of a rectangular matrix (column-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + R = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + C = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + + out = dlaqge( 'column-major', 2, 3, A, 3, R, C, 1.0, 1.0/13.0, 4.0 ); + expected = new Float64Array( [ 1.0, 22.0, 39.0, 4.0, 55.0, 78.0 ] ); + t.strictEqual( out, 'C', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales column of a rectangular matrix (row-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + R = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + C = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + + out = dlaqge( 'row-major', 2, 3, A, 3, R, C, 1.0, 1.0/13.0, 4.0 ); + expected = new Float64Array( [ 1.0, 22.0, 39.0, 4.0, 55.0, 78.0 ] ); + t.strictEqual( out, 'C', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales row of a rectangular matrix (row-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + R = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + C = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + out = dlaqge( 'row-major', 2, 3, A, 3, R, C, 1.0/13.0, 1.0, 4.0 ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 44.0, 55.0, 66.0 ] ); + t.strictEqual( out, 'R', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function scales column of a rectangular matrix (column-major)', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + R = new Float64Array( [ 1.0, 11.0, 13.0 ] ); + C = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + out = dlaqge( 'column-major', 2, 3, A, 3, R, C, 1.0/13.0, 1.0, 4.0 ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 44.0, 55.0, 66.0 ] ); + t.strictEqual( out, 'R', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.js new file mode 100644 index 00000000000..ebbfe435dbe --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.js @@ -0,0 +1,83 @@ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlaqge = 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 dlaqge, '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 dlaqge.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 dlaqge = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaqge, 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 dlaqge; + var main; + + main = require( './../lib/dlaqge.js' ); + + dlaqge = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaqge, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.ndarray.js new file mode 100644 index 00000000000..d4063b7cfc4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/test/test.ndarray.js @@ -0,0 +1,148 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlaqge = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaqge, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 15', function test( t ) { + t.strictEqual( dlaqge.length, 15, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports accessing elements from non-contiguous alignment of row and column ( row-major )', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 4, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 4, 999, 2, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 4, + 999, 999, 999, 999, 999, 999 + ]); + + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 22, 999, 52, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 484, 999, 286, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 676, + 999, 999, 999, 999, 999, 999 + ]); + + R = new Float64Array( [ 999.9, 999.9, 1.0, 999.9, 999.9, 11.0, 999.9, 999.9, 13.0 ] ); + C = new Float64Array( [ 999.9, 999.9, 999.9, 1.0, 999.9, 11.0, 999.9, 13.0 ] ); + + // out = dtrti2( 'upper', 'non-unit', 3, A, 12, 2, 7 ); + out = dlaqge( 3, 3, A, 12, 2, 7, R, 3, 2, C, 2, 3, 1.0/13.0, 1.0/13.0, 4.0 ); + t.strictEqual( out, 'B', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function supports accessing elements from non-contiguous alignment of row and column in reverse and different order ( row-major )', function test( t ) { + var expected; + var out; + var A; + var R; + var C; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 4, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 4, 999, 2, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 4, + 999, 999, 999, 999, 999, 999 + ]); + + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 169, 999, 286, 999, 52, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 484, 999, 22, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 4, + 999, 999, 999, 999, 999, 999 + ]); + + R = new Float64Array( [ 999.9, 999.9, 13.0, 999.9, 999.9, 11.0, 999.9, 999.9, 1.0 ] ); + C = new Float64Array( [ 999.9, 999.9, 999.9, 1.0, 999.9, 11.0, 999.9, 13.0 ] ); + + // out = dtrti2( 'upper', 'non-unit', 3, A, 12, 2, 7 ); + out = dlaqge( 3, 3, A, -12, -2, 35, R, -3, 8, C, 2, 3, 1.0/13.0, 1.0/13.0, 4.0 ); + t.strictEqual( out, 'B', 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); From 1f1a369c2921d3813999cc6aacb96cb6615543d2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 7 Aug 2024 20:05:42 +0530 Subject: [PATCH 4/5] fix: incorrect example --- lib/node_modules/@stdlib/lapack/base/dlaqge/README.md | 2 +- lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md b/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md index 4093bc2eb01..47a87c20c52 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/README.md @@ -160,7 +160,7 @@ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var R = new Float64Array( [ 1.0, 11.0 ] ); var C = new Float64Array( [ 1.0, 11.0 ] ); -var out = dlaqge( 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); +var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); console.log( out ); console.log( A ); ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js index 54a3eef27b8..e40cdd91c64 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/examples/index.js @@ -19,12 +19,12 @@ 'use strict'; var Float64Array = require( '@stdlib/array/float64' ); -var dlaqge = require( './../lib/base.js' ); +var dlaqge = require( './../lib/' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var R = new Float64Array( [ 1.0, 11.0 ] ); var C = new Float64Array( [ 1.0, 11.0 ] ); -var out = dlaqge( 2, 2, A, 2, 1, 0, R, 1, 0, C, 1, 0, 1.0/11.0, 1.0/11.0, 4.0 ); +var out = dlaqge( 'row-major', 2, 2, A, 2, R, C, 1.0/11.0, 1.0/11.0, 4.0 ); console.log( out ); console.log( A ); From fa20747c54a76031c52c39ec103744fc8cf9ca6a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 8 Aug 2024 15:44:15 +0530 Subject: [PATCH 5/5] refactor: base implementation --- .../@stdlib/lapack/base/dlaqge/lib/base.js | 69 ++++++++----------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js index 987feaa04e2..9964c5a6c4a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaqge/lib/base.js @@ -63,7 +63,10 @@ function dlaqge( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, s var thresh; var large; var small; - var cj; + var sa0; + var sa1; + var rj; + var ia; var i; var j; @@ -71,6 +74,16 @@ function dlaqge( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, s return 'N'; } + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // 'column-major' + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + thresh = 0.1; small = 1.0020841800044864E-292; large = 1.0 / small; @@ -81,57 +94,31 @@ function dlaqge( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, s return 'N'; } // Column scaling - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - for ( j = 0; j < N; j++ ) { - cj = C[ offsetC + ( j * strideC ) ]; - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] *= cj; - } - } - return 'C'; - } - // column-major - for ( j = 0; j < N; j++ ) { - cj = C[ offsetC + ( j * strideC ) ]; - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA2 ) + ( j * strideA1 ) ] *= cj; + for ( j = 0; j < M; j++ ) { + ia = offsetA + ( j * sa1 ); + for ( i = 0; i < N; i++ ) { + A[ ia + ( i * sa0 ) ] *= C[ offsetC + ( i * strideC ) ]; } } return 'C'; } if ( colcnd >= thresh ) { // Row scaling, no column scaling - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - for ( j = 0; j < N; j++ ) { - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] *= R[ offsetR + ( i * strideR ) ]; - } - } - return 'R'; - } - // column-major - for ( j = 0; j < N; j++ ) { - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA2 ) + ( j * strideA1 ) ] *= R[ offsetR + ( i * strideR ) ]; + for ( j = 0; j < M; j++ ) { + ia = offsetA + ( j * sa1 ); + rj = R[ offsetR + ( j * strideR ) ]; + for ( i = 0; i < N; i++ ) { + A[ ia + ( i * sa0 ) ] *= rj; } } return 'R'; } // Row and column scaling - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - for ( j = 0; j < N; j++ ) { - cj = C[ offsetC + ( j * strideC ) ]; - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] *= cj * R[ offsetR + ( i * strideR ) ]; - } - } - return 'B'; - } - // column-major - for ( j = 0; j < N; j++ ) { - cj = C[ offsetC + ( j * strideC ) ]; - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA2 ) + ( j * strideA1 ) ] *= cj * R[ offsetR + ( i * strideR ) ]; + for ( j = 0; j < M; j++ ) { + ia = offsetA + ( j * sa1 ); + rj = R[ offsetR + ( j * strideR ) ]; + for ( i = 0; i < N; i++ ) { + A[ ia + ( i * sa0 ) ] *= C[ offsetC + ( i * strideC ) ] * rj; } } return 'B';