From 5a16006f11ba3157df4a8179452abb919e0cd03c Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 3 Feb 2026 22:21:52 +0530 Subject: [PATCH 1/9] feat: add `lapack/base/dgetc2` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/README.md | 411 ++++++++++ .../lapack/base/dgetc2/benchmark/benchmark.js | 124 ++++ .../dgetc2/benchmark/benchmark.ndarray.js | 131 ++++ .../@stdlib/lapack/base/dgetc2/docs/repl.txt | 115 +++ .../lapack/base/dgetc2/docs/types/index.d.ts | 157 ++++ .../lapack/base/dgetc2/docs/types/test.ts | 348 +++++++++ .../lapack/base/dgetc2/examples/index.js | 40 + .../@stdlib/lapack/base/dgetc2/lib/base.js | 178 +++++ .../@stdlib/lapack/base/dgetc2/lib/dgetc2.js | 89 +++ .../@stdlib/lapack/base/dgetc2/lib/index.js | 84 +++ .../@stdlib/lapack/base/dgetc2/lib/main.js | 35 + .../@stdlib/lapack/base/dgetc2/lib/ndarray.js | 72 ++ .../@stdlib/lapack/base/dgetc2/package.json | 73 ++ .../dgetc2/test/fixtures/column_major.json | 79 ++ .../test/fixtures/column_major_i_gt_0.json | 79 ++ .../fixtures/large_strides/column_major.json | 103 +++ .../large_strides/column_major_i_gt_0.json | 103 +++ .../fixtures/large_strides/row_major.json | 102 +++ .../large_strides/row_major_i_gt_0.json | 103 +++ .../fixtures/mixed_strides/column_major.json | 79 ++ .../mixed_strides/column_major_i_gt_0.json | 79 ++ .../fixtures/mixed_strides/row_major.json | 79 ++ .../mixed_strides/row_major_i_gt_0.json | 79 ++ .../negative_strides/column_major.json | 79 ++ .../negative_strides/column_major_i_gt_0.json | 79 ++ .../fixtures/negative_strides/row_major.json | 79 ++ .../negative_strides/row_major_i_gt_0.json | 79 ++ .../test/fixtures/offsets/column_major.json | 83 +++ .../fixtures/offsets/column_major_i_gt_0.json | 83 +++ .../test/fixtures/offsets/row_major.json | 83 +++ .../fixtures/offsets/row_major_i_gt_0.json | 83 +++ .../base/dgetc2/test/fixtures/row_major.json | 79 ++ .../test/fixtures/row_major_i_gt_0.json | 79 ++ .../lapack/base/dgetc2/test/test.dgetc2.js | 334 +++++++++ .../@stdlib/lapack/base/dgetc2/test/test.js | 82 ++ .../lapack/base/dgetc2/test/test.ndarray.js | 702 ++++++++++++++++++ 36 files changed, 4666 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md new file mode 100644 index 000000000000..e1e068cdb930 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md @@ -0,0 +1,411 @@ + + +# dgetc2 + +> LAPACK routine to compute the LU factorization with complete pivoting of the general N-by-N matrix `A`. + +
+ +The `dgetc2` routine computes an LU factorization of with complete pivoting a real N-by-N matrix `A`. The factorization has the form: + + + +```math +A = P L U Q +``` + + + +where `P` and `Q` are permutation matrices, `L` is lower triangular with unit diagonal elements and `U` is upper triangular. + +For a 5-by-5 matrix `A`, elements are stored in three arrays: + + + +```math +A = \left[ +\begin{array}{rrrrr} + a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} \\ + a_{2,1} & a_{2,2} & a_{2,3} & a_{2,4} & a_{2,5} \\ + a_{3,1} & a_{3,2} & a_{3,3} & a_{3,4} & a_{3,5} \\ + a_{4,1} & a_{4,2} & a_{4,3} & a_{4,4} & a_{4,5} \\ + a_{5,1} & a_{5,2} & a_{5,3} & a_{5,4} & a_{5,5} + \end{array} +\right] +``` + + + +After factorization, the elements of `L` and `U` are used to update `A`, where: + +- The unit diagonal elements of `L` are not stored. +- If $U_{kk}$ appears to be less than `SMIN`, $U_{kk}$ is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + +The resulting `L` and `U` matrices have the following structure: + + + +```math +L = \left[ +\begin{array}{rrrrr} + 0 & 0 & 0 & 0 & 0 \\ + l_{2,1} & 0 & 0 & 0 & 0 \\ + l_{3,1} & l_{3,2} & 0 & 0 & 0 \\ + l_{4,1} & l_{4,2} & l_{4,3} & 0 & 0 \\ + l_{5,1} & l_{5,2} & l_{5,3} & l_{5,4} & 0 + \end{array} +\right] +``` + + + + + +```math +U = \left[ + \begin{array}{rrrrr} + u_{1,1} & u_{1,2} & u_{1,3} & u_{1,4} & u_{1,5} \\ + 0 & u_{2,2} & u_{2,3} & u_{2,4} & u_{2,5} \\ + 0 & 0 & u_{3,3} & u_{3,4} & u_{3,5} \\ + 0 & 0 & 0 & u_{4,4} & u_{4,5} \\ + 0 & 0 & 0 & 0 & u_{5,5} + \end{array} +\right] +``` + + + +where the values of `L` and `U` are stored in A, as follows: + +```math +A_{out} = L + U +``` + +
+ + + + +
+ +## Usage + +```javascript +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +``` + +#### dgetc2( order, N, A, LDA, IPIV, JPIV ) + +Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV = new Int32Array( 3 ); +var JPIV = new Int32Array( 3 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +// A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV = [ 3, 3, 3 ] +// IPIV = [ 3, 3, 3 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **N**: number of columns in matrix `A`. +- **A**: input matrix (overwritten by `L` and `U`) stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-float64array]. +- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-float64array]. + +The function returns the status code `info`. + +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' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV0 = new Int32Array( 4 ); +var JPIV0 = new Int32Array( 4 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +// Create offset views... +var A = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var JPIV = new Int32Array( JPIV0.buffer, JPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +// A0 => [ 0, 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV0 = [ 0, 3, 3, 3 ] +// IPIV0 = [ 0, 3, 3, 3 ] +``` + + + +#### dgetc2.ndarray( N, A, sa1, sa2, oa, IPIV, si, oi, JPIV, sj, oj ) + +Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV = new Int32Array( 3 ); +var JPIV = new Int32Array( 3 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +// A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV = [ 3, 3, 3 ] +// IPIV = [ 3, 3, 3 ] +``` + +The function has the following parameters: + +- **N**: number of columns in matrix `A`. +- **A**: input matrix (overwritten by `L` and `U`) stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: index offset for `A`. +- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-float64array]. +- **si**: stride length for `IPIV`. +- **oi**: index offset for `IPIV`. +- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-float64array]. +- **sj**: stride length for `JPIV`. +- **oj**: index offset for `JPIV`. + +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 Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +// Initial arrays... +var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV = new Int32Array( 4 ); +var JPIV = new Int32Array( 4 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +dgetc2( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); +// A => [ 0, 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV = [ 0, 3, 3, 3 ] +// IPIV = [ 0, 3, 3, 3 ] +``` + +
+ + + +
+ +## Notes + +- `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q`; the unit diagonal elements of L are not stored. + +- If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + +- `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). + +- `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + +- Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. + +- `dgetc2()` corresponds to the [LAPACK][LAPACK] function [`dgetc2`][lapack-dgetc2]. + +
+ + + +
+ +## Examples + + + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgetc2 = require( './../lib' ); + +var N = 3; +var LDA = 3; + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + +console.log( 'The n-by-n matrix A to be factored:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); + +var IPIV = new Int32Array( N ); +var JPIV = new Int32Array( N ); + + +// Perform the `A = LU` factorization: +var info = dgetc2( 'column-major', N, A, LDA, IPIV, JPIV ); + +console.log( 'The factors L and U from the factorization:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js new file mode 100644 index 000000000000..bbaa6ef00695 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js @@ -0,0 +1,124 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var 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 Int32Array = require( '@stdlib/array/int32' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgetc2 = require( './../lib/dgetc2.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - matrix order (N-by-N) +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var IPIV; + var JPIV; + var opts; + var A; + + opts = { + 'dtype': 'float64' + }; + + // Random input matrix and auxiliary arrays: + A = uniform( N*N, -1.0, 1.0, opts ); + IPIV = new Int32Array( N ); + JPIV = new Int32Array( N ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dgetc2( order, N, A, N, IPIV, JPIV ); + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + 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 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:order=%s,size=%d', pkg, ord, (N*N) ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..b3360b61c5d0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var 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 Int32Array = require( '@stdlib/array/int32' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgetc2 = 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 - matrix order (N-by-N) +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var IPIV; + var JPIV; + var sa1; + var sa2; + var A; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { + sa1 = N; + sa2 = 1; + } + + A = uniform( N*N, -1.0, 1.0, { + 'dtype': 'float64' + }); + IPIV = new Int32Array( N ); + JPIV = new Int32Array( N ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dgetc2( N, A, sa1, sa2, 0, IPIV, 1, 0, JPIV, 1, 0 ); + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + 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 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:ndarray:order=%s,size=%d', pkg, ord, (N*N) ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt new file mode 100644 index 000000000000..ec9a3e902306 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt @@ -0,0 +1,115 @@ +{{alias}}( order, N, A, LDA, IPIV, JPIV ) + Computes the LU factorization with complete pivoting of the general + n-by-n matrix `A`. + + The function overwrites the input matrix A with the factors L and U + from the factorization A = P*L*U*Q; the unit diagonal elements of L + are not stored. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + N: integer + Number of columns in matrix A. + + A: Float64Array + Input matrix (overwritten with `L` and `U` on output). + + LDA: integer + Stride of the first dimension of A (a.k.a., leading dimension of the + matrix A) `LDA` >= max(1,N). + + IPIV: Int32Array + Vector of `N` pivot indices of rows. + + JPIV: Int32Array + Vector of `N` pivot indices of rows. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}([ 1,2,3,4,5,6,7,8,10 ]); + > var IPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > var JPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > {{alias}}( 'column-major', 3, A, 3, IPIV, JPIV ) + 0 + > A + [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + > IPIV + [ 3, 3, 3 ] + > JPIV + [ 3, 3, 3 ] + + +{{alias}}.ndarray( N, A, sa1, sa2, oa, IPIV, si, oi, JPIV, sj, oj ) + Computes the LU factorization with complete pivoting of the general + n-by-n matrix `A` using alternating 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 + ---------- + N: integer + Number of columns in matrix A. + + A: Float64Array + Input matrix (overwritten with `L` and `U` on output). + + sa1: integer + Stride of the first dimension of A. + + sa2: integer + Stride of the second dimension of A. + + oa: integer + Index offset for A. + + IPIV: Int32Array + Vector of `N` pivot indices of rows. + + si: integer + Stride length for IPIV. + + oi: integer + Index offset for IPIV. + + JPIV: Int32Array + Vector of `N` pivot indices of columns. + + sj: integer + Stride length for JPIV. + + oj: integer + Index offset for JPIV. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}([ 1,2,3,4,5,6,7,8,10 ]); + > var IPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > var JPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > {{alias}}.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ) + 0 + > A + [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + > IPIV + [ 3, 3, 3 ] + > JPIV + [ 3, 3, 3 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts new file mode 100644 index 000000000000..405be2bcd43b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts @@ -0,0 +1,157 @@ +/* +* @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 `dgetc2`. +*/ +interface Routine { + /** + * Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. + * + * ## Notes + * + * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q; the unit diagonal elements of L are not stored. + * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). + * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. + * + * @param order - storage layout + * @param N - number of columns in `A` + * @param A - input matrix (overwritten with `L` and `U` on output) + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) `LDA` >= max(1,N). + * @param IPIV - vector of `N` pivot indices of rows + * @param JPIV - vector of `N` pivot indices of columns + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + * var IPIV = new Int32Array( 3 ); + * var JPIV = new Int32Array( 3 ); + * + * dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); + * // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + * // JPIV = [ 3, 3, 3 ] + * // IPIV = [ 3, 3, 3 ] + */ + ( order: Layout, N: number, A: Float64Array, LDA: number, IPIV: Int32Array, JPIV: Int32Array ): number; + + /** + * Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternating indexing semantics. + * + * ## Notes + * + * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. + * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). + * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. + * + * @param N - number of columns in `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 - index offset for `A` + * @param IPIV - vector of pivot indices of rows + * @param strideIPIV - stride length for `IPIV` + * @param offsetIPIV - index offset for `IPIV` + * @param JPIV - vector of pivot indices of rows + * @param strideJPIV - stride length for `JPIV` + * @param offsetJPIV - index offset for `JPIV` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + * var IPIV = new Int32Array( 3 ); + * var JPIV = new Int32Array( 3 ); + * + * dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); + * // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + * // JPIV = [ 3, 3, 3 ] + * // IPIV = [ 3, 3, 3 ] + */ + ndarray( N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number, JPIV: Int32Array, strideJPIV: number, offsetJPIV: number ): number; // eslint-disable-line max-len +} + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternating indexing semantics. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @param order - storage layout +* @param N - number of columns in `A` +* @param A - input matrix (overwritten with `Q` on output) +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) `LDA` >= max(1,N). +* @param IPIV - vector of `N` pivot indices of rows +* @param JPIV - vector of `N` pivot indices of columns +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +declare var dgetc2: Routine; + + +// EXPORTS // + +export = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts new file mode 100644 index 000000000000..4ccfee59930a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts @@ -0,0 +1,348 @@ +/* +* @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 dgetc2 = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 5, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( true, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( false, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( null, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( void 0, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( [], 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( {}, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( ( x: number ): number => x, 3, A, 3, IPIV, JPIV ); // $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 IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', '3', A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', true, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', false, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', null, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', void 0, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', [], A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', {}, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', ( x: number ): number => x, A, 3, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, '5', 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, 5, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, true, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, false, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, null, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, void 0, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, [], 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, {}, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, ( x: number ): number => x, 3, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, '3', IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, true, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, false, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, null, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, void 0, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, [], IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, {}, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, ( x: number ): number => x, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, 3, '5', JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, 5, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, true, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, false, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, null, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, void 0, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, [], JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, {}, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, ( x: number ): number => x, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided an sixth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, 3, IPIV, '5' ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, 5 ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, true ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, false ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, null ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, void 0 ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, [] ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, {} ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2(); // $ExpectError + dgetc2( 'column-major' ); // $ExpectError + dgetc2( 'column-major', 3 ); // $ExpectError + dgetc2( 'column-major', 3, A ); // $ExpectError + dgetc2( 'column-major', 3, A, 3 ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, JPIV, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( '3', A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( true, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( false, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( null, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( void 0, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( [], A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( {}, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( ( x: number ): number => x, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, '5', 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, 5, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, true, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, false, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, null, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, void 0, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, [], 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, {}, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, ( x: number ): number => x, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $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 IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, '1', 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, true, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, false, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, null, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, void 0, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, [], 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, {}, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, ( x: number ): number => x, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, '3', 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, true, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, false, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, null, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, void 0, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, [], 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, {}, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, ( x: number ): number => x, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $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 IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, '0', IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, true, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, false, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, null, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, void 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, [], IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, {}, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, ( x: number ): number => x, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an sixth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, '5', 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, 5, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, true, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, false, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, null, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, void 0, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, [], 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, {}, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, ( x: number ): number => x, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, '1', 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, true, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, false, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, null, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, void 0, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, [], 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, {}, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, ( x: number ): number => x, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, '0', JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, true, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, false, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, null, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, void 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, [], JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, {}, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, ( x: number ): number => x, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an ninth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, '5', 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, 5, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, true, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, false, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, null, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, void 0, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, [], 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, {}, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, '1', 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, true, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, false, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, null, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, void 0, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, [], 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, {}, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eleventh argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, '0' ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, true ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, false ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, null ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, void 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, [] ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, {} ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, ( 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( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray(); // $ExpectError + dgetc2.ndarray( 3 ); // $ExpectError + dgetc2.ndarray( 3, A ); // $ExpectError + dgetc2.ndarray( 3, A, 1 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js new file mode 100644 index 000000000000..aa2abe3dd986 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js @@ -0,0 +1,40 @@ +/** +* @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 Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgetc2 = require( './../lib' ); + +var N = 3; +var LDA = 3; + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + +console.log( 'The n-by-n matrix A to be factored:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); + +var IPIV = new Int32Array( N ); +var JPIV = new Int32Array( N ); + +dgetc2( 'column-major', N, A, LDA, IPIV, JPIV ); + +console.log( 'The factors L and U from the factorization:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js new file mode 100644 index 000000000000..295d9569b78b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -0,0 +1,178 @@ +/** +* @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 dlamch = require( '@stdlib/lapack/base/dlamch' ); +var dswap = require( '@stdlib/blas/base/dswap' ); +var dger = require( '@stdlib/blas/base/dger' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @private +* @param {PositiveInteger} 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 - index offset for `A` +* @param {Int32Array} IPIV - vector of pivot indices for rows +* @param {integer} strideIPIV - stride length for `IPIV` +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @param {Int32Array} JPIV - vector of pivot indices for columns +* @param {integer} strideJPIV - stride length for `JPIV` +* @param {NonNegativeInteger} offsetJPIV - index offset for `JPIV` +* @returns {integer} - status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ) { // eslint-disable-line max-params, max-len + var smlnum; + var info; + var smin; + var xmax; + var eps; + var ipv; + var jpv; + var sA1; + var sA2; + var ip; + var jp; + var oA; + var i; + var j; + + sA1 = strideA1; + sA2 = strideA2; + oA = offsetA; + + info = 0; + + // Quick return if possible + if ( N === 0 ) { + return info; + } + + // Set constants to control overflow + eps = dlamch( 'P' ); + smlnum = dlamch( 'S' ) / eps; + + // Handle the case N=1 by itself + if ( N === 1 ) { + IPIV[ offsetIPIV ] = 1; + JPIV[ offsetJPIV ] = 1; + if ( abs( A[ oA ] )< smlnum ) { + info = 1; + A[ oA ] = smlnum; + } + return info; + } + + // Factorize A using complete pivoting. + // Set pivots less than SMIN to SMIN. + for ( i = 0; i < N - 1; i++ ) { + // Find max element in matrix A + xmax = 0.0; + if ( isRowMajor( [ sA1, sA2 ] ) ) { + for ( ip = i; ip < N; ip++ ) { + for ( jp = i; jp < N; jp++ ) { + if ( abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ) >= xmax ) { + xmax = abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ); + ipv = ip; + jpv = jp; + } + } + } + } else { // column-major + for ( jp = i; jp < N; jp++ ) { + for ( ip = i; ip < N; ip++ ) { + if ( abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ]) >= xmax ) { + xmax = abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ); + ipv = ip; + jpv = jp; + } + } + } + } + + if ( i === 0 ) { + smin = max( eps*xmax, smlnum ); + } + + // Swap rows + if ( ipv !== i ) { + dswap.ndarray( N, A, sA2, oA + ( sA1*ipv ), A, sA2, oA+( sA1*i ) ); + } + IPIV[ offsetIPIV + ( i*strideIPIV ) ] = ipv+1; + + // Swap columns + if ( jpv !== i ) { + dswap.ndarray( N, A, sA1, oA + ( sA2*jpv ), A, sA1, oA+( sA2*i ) ); + } + JPIV[ offsetJPIV + ( i*strideJPIV ) ] = jpv+1; + + // Check for singularity + for ( j = i+1; j < N; j++ ) { + A[ oA + ( j*sA1 ) + ( i*sA2 ) ] /= A[ oA + ( i*( sA1 + sA2 ) ) ]; + } + + dger.ndarray( N - i-1, N - i-1, -1, A, sA1, oA + ( ( i + 1 )*sA1 ) + ( i*sA2 ), A, sA2, oA + ( i*sA1 ) + ( ( i + 1 )*sA2 ), A, sA1, sA2, oA + ( ( i + 1 )*( sA1 + sA2 ) ) ); // eslint-disable-line max-len + } + + if ( abs( A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] ) < smin ) { + info = N; + A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] = smin; + } + + IPIV[ offsetIPIV + ( ( N - 1 )*strideIPIV ) ] = N; + JPIV[ offsetJPIV + ( ( N - 1 )*strideJPIV ) ] = N; + + return info; +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js new file mode 100644 index 000000000000..ebc066e44a1f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js @@ -0,0 +1,89 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 the LU factorization with complete pivoting of the general n-by-n matrix `A`. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @param {string} order - storage layout +* @param {PositiveInteger} 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 {Int32Array} IPIV - vector of pivot indices for rows +* @param {Int32Array} JPIV - vector of pivot indices for columns +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,M) +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +function dgetc2( order, N, A, LDA, IPIV, JPIV ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( N, A, sa1, sa2, 0, IPIV, 1, 0, JPIV, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js new file mode 100644 index 000000000000..2fc3a9ba2f89 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute the LU factorization with complete pivoting of the general n-by-n matrix `A`. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @module @stdlib/lapack/base/dgetc2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ + +// 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 dgetc2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgetc2 = main; +} else { + dgetc2 = tmp; +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/main.js new file mode 100644 index 000000000000..c11e9f28e28e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/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 dgetc2 = require( './dgetc2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgetc2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js new file mode 100644 index 000000000000..3dcb61185689 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.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'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternating indexing semantics. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization `A = P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @param {PositiveInteger} 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 - index offset for `A` +* @param {Int32Array} IPIV - the pivot indices for rows +* @param {integer} strideIPIV - stride length for `IPIV` +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @param {Int32Array} JPIV - the pivot indices for columns +* @param {integer} strideJPIV - stride length for `JPIV` +* @param {NonNegativeInteger} offsetJPIV - index offset for `JPIV` +* @returns {integer} - status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ) { // eslint-disable-line max-len, max-params + return base( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/package.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/package.json new file mode 100644 index 000000000000..b15e4ec3029c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/lapack/base/dgetc2", + "version": "0.0.0", + "description": "LAPACK routine to compute the LU factorization with complete pivoting of the general n-by-n matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "dgetc2", + "orthogonal", + "qr", + "decomposition", + "householder", + "reflectors", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json new file mode 100644 index 000000000000..d82deec5d31b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1.0, + 4.0, + 7.0 + ], + [ + 2.0, + 5.0, + 8.0 + ], + [ + 3.0, + 6.0, + 10.0 + ] + ], + "A": [ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 10.0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10.0, + 3.0, + 6.0 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 10.0, + 0.7, + 0.8, + 3.0, + -1.0999999999999996, + 0.3636363636363641, + 6.0, + -0.1999999999999993, + 0.2727272727272718 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json new file mode 100644 index 000000000000..cc4ee3637d46 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + "A": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] + ], + "A_out": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json new file mode 100644 index 000000000000..38a9ae69e57f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json @@ -0,0 +1,103 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 10, + 9999 + ], + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "IPIV": [ + 3, + 0, + 3, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 3, + 0, + 3, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 10, + 9999, + 0.7, + 9999, + 0.8, + 9999, + 3, + 9999, + -1.0999999999999996, + 9999, + 0.3636363636363641, + 9999, + 6, + 9999, + -0.1999999999999993, + 9999, + 0.2727272727272718, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json new file mode 100644 index 000000000000..562cc4590c98 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json @@ -0,0 +1,103 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "IPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 2.220446049250313e-16, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json new file mode 100644 index 000000000000..4fb71f9ba7eb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json @@ -0,0 +1,102 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 10, + 9999 + ], + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "IPIV": [ + 3, + 0, + 3, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 3,0, + 3, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 10, + 9999, + 7, + 9999, + 8, + 9999, + 0.3, + 9999, + -1.1, + 9999, + -0.3999999999999999, + 9999, + 0.6, + 9999, + 0.181818181818182, + 9999, + 0.2727272727272729, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json new file mode 100644 index 000000000000..861b5885cde1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json @@ -0,0 +1,103 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "IPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 2.220446049250313e-16, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json new file mode 100644 index 000000000000..fc71cb4477f7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 7, + 8, + 10, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideA1": 1, + "strideA2": -3, + "offsetA": 6, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 6, + -0.1999999999999993, + 0.2727272727272718, + 3, + -1.0999999999999996, + 0.3636363636363641, + 10, + 0.7, + 0.8 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json new file mode 100644 index 000000000000..50e7687d77c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0 + ], + "strideA1": -3, + "strideA2": 1, + "offsetA": 6, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 0, + 0, + 2.220446049250313e-16, + 0, + 1, + 0, + 1, + 0, + 0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json new file mode 100644 index 000000000000..539bfda870b8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 7, + 8, + 10, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideA1": -3, + "strideA2": 1, + "offsetA": 6, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 0.6, + 0.181818181818182, + 0.2727272727272729, + 0.3, + -1.1, + -0.3999999999999999, + 10, + 7, + 8 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json new file mode 100644 index 000000000000..bd3c96d3a998 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0 + ], + "strideA1": 1, + "strideA2": -3, + "offsetA": 6, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 0, + 0, + 2.220446049250313e-16, + 0, + 1, + 0, + 1, + 0, + 0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json new file mode 100644 index 000000000000..8f2ddb4f7e56 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 10, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideA1": -1, + "strideA2": -3, + "offsetA": 8, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 0.2727272727272718, + -0.1999999999999993, + 6, + 0.3636363636363641, + -1.0999999999999996, + 3, + 0.8, + 0.7, + 10 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json new file mode 100644 index 000000000000..281b75ce54cd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], + "strideA1": -3, + "strideA2": -1, + "offsetA": 8, + "IPIV": [ + 3, + 2, + 2 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 2, + 2 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 2.220446049250313e-16, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json new file mode 100644 index 000000000000..2af325229364 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 10, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideA1": -3, + "strideA2": -1, + "offsetA": 8, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 0.2727272727272729, + 0.181818181818182, + 0.6, + -0.3999999999999999, + -1.1, + 0.3, + 8, + 7, + 10 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json new file mode 100644 index 000000000000..74c02d84da04 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], + "strideA1": -1, + "strideA2": -3, + "offsetA": 8, + "IPIV": [ + 3, + 2, + 2 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 2, + 2 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 2.220446049250313e-16, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json new file mode 100644 index 000000000000..765897d2bda5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json @@ -0,0 +1,83 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 10 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "IPIV": [ + 0, + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 9999, + 10, + 0.7, + 0.8, + 3, + -1.0999999999999996, + 0.3636363636363641, + 6, + -0.1999999999999993, + 0.2727272727272718 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json new file mode 100644 index 000000000000..9752bd383398 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json @@ -0,0 +1,83 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "IPIV": [ + 0, + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 2.220446049250313e-16 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json new file mode 100644 index 000000000000..215e234f9618 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json @@ -0,0 +1,83 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 10 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "IPIV": [ + 0, + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 9999, + 10, + 7, + 8, + 0.3, + -1.1, + -0.3999999999999999, + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json new file mode 100644 index 000000000000..91aa4dd3c4e1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json @@ -0,0 +1,83 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "IPIV": [ + 0, + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 2.220446049250313e-16 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json new file mode 100644 index 000000000000..808671d82be8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1.0, + 2.0, + 3.0 + ], + [ + 4.0, + 5.0, + 6.0 + ], + [ + 7.0, + 8.0, + 10.0 + ] + ], + "A": [ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 10.0 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10.0, + 7.0, + 8.0 + ], + [ + 0.3, + -1.1000000000000001, + -0.3999999999999999 + ], + [ + 0.6, + 0.1818181818181820, + 0.2727272727272729 + ] + ], + "A_out": [ + 10.0, + 7.0, + 8.0, + 0.3, + -1.1000000000000001, + -0.3999999999999999, + 0.6, + 0.1818181818181820, + 0.2727272727272729 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json new file mode 100644 index 000000000000..a7d88dc678bb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + "A": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] + ], + "A_out": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js new file mode 100644 index 000000000000..09911b9a3504 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js @@ -0,0 +1,334 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dgetc2 = require( './../lib/dgetc2.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+'.' ); + } + } +} + + +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +/* eslint-disable vars-on-top */ +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); +var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); + +/* eslint-enable vars-on-top */ + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetc2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dgetc2.length, 6, '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 IPIV; + var JPIV; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + 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() { + dgetc2( value, 3, A, 3, IPIV, JPIV ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var IPIV; + var JPIV; + var A; + var i; + + values = [ + 0, + 1, + 2 + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 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() { + dgetc2( 'row-major', 3, A, value, IPIV, JPIV ); + }; + } +}); + +tape( 'the function returns the input matrix unchanged if `N` <= 0', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var info; + var IPIV; + var JPIV; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = A; + expectedIPIV = IPIV; + expectedJPIV = JPIV; + + info = dgetc2( 'row-major', 0, A, 1, IPIV, JPIV ); + + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` when `N` is 1', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var info; + var IPIV; + var JPIV; + var A; + + A = new Float64Array( [ 1.0 ] ); + IPIV = new Int32Array( 1 ); + JPIV = new Int32Array( 1 ); + + expectedA = new Float64Array( [ 1.0 ] ); + expectedIPIV = new Int32Array( [ 1 ] ); + expectedJPIV = new Int32Array( [ 1 ] ); + + info = dgetc2( 'row-major', 1, A, 1, IPIV, JPIV ); + + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + A = new Float64Array( [ 1.0e-300 ] ); + + expectedA = new Float64Array( [ 1.0020841800044864e-292 ] ); + + info = dgetc2( 'column-major', 1, A, 1, IPIV, JPIV ); + + t.strictEqual( info, 1, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.js new file mode 100644 index 000000000000..67b3dc9aa081 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/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 dgetc2 = 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 dgetc2, '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 dgetc2.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 dgetc2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgetc2, 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 dgetc2; + var main; + + main = require( './../lib/dgetc2.js' ); + + dgetc2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgetc2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js new file mode 100644 index 000000000000..7ece58599999 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js @@ -0,0 +1,702 @@ +/** +* @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 Int32Array = require( '@stdlib/array/int32' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dgetc2 = 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+'.' ); + } + } +} + + +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +/* eslint-disable vars-on-top, id-length */ +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); +var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); +var LARGE_STRIDES_COL_MAJOR = require( './fixtures/large_strides/column_major.json' ); +var LARGE_STRIDES_ROW_MAJOR = require( './fixtures/large_strides/row_major.json' ); +var LARGE_STRIDES_COL_I_GT_0 = require( './fixtures/large_strides/column_major_i_gt_0.json' ); +var LARGE_STRIDES_ROW_I_GT_0 = require( './fixtures/large_strides/row_major_i_gt_0.json' ); +var NEGATIVE_STRIDES_COL_MAJOR = require( './fixtures/negative_strides/column_major.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR = require( './fixtures/negative_strides/row_major.json' ); +var NEGATIVE_STRIDES_COL_I_GT_0 = require( './fixtures/negative_strides/column_major_i_gt_0.json' ); +var NEGATIVE_STRIDES_ROW_I_GT_0 = require( './fixtures/negative_strides/row_major_i_gt_0.json' ); +var MIXED_STRIDES_COL_MAJOR = require( './fixtures/mixed_strides/column_major.json' ); +var MIXED_STRIDES_ROW_MAJOR = require( './fixtures/mixed_strides/row_major.json' ); +var MIXED_STRIDES_COL_I_GT_0 = require( './fixtures/mixed_strides/column_major_i_gt_0.json' ); +var MIXED_STRIDES_ROW_I_GT_0 = require( './fixtures/mixed_strides/row_major_i_gt_0.json' ); +var OFFSETS_COL_MAJOR = require( './fixtures/offsets/column_major.json' ); +var OFFSETS_ROW_MAJOR = require( './fixtures/offsets/row_major.json' ); +var OFFSETS_COL_I_GT_0 = require( './fixtures/offsets/column_major_i_gt_0.json' ); +var OFFSETS_ROW_I_GT_0 = require( './fixtures/offsets/row_major_i_gt_0.json' ); + +/* eslint-enable vars-on-top, id-length */ + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetc2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dgetc2.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); From acbf0e719faed4ddab487f83e452c07cf8e98e57 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 3 Feb 2026 22:38:40 +0530 Subject: [PATCH 2/9] fix: copyright years and examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/README.md | 14 ++------------ .../lapack/base/dgetc2/benchmark/benchmark.js | 2 +- .../base/dgetc2/benchmark/benchmark.ndarray.js | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md index e1e068cdb930..ffda0ab437f3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md @@ -119,7 +119,6 @@ Computes the LU factorization with complete pivoting of the general n-by-n matri ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); -var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); var IPIV = new Int32Array( 3 ); @@ -157,7 +156,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); -var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); // Initial arrays... var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); @@ -232,7 +230,6 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); -var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); // Initial arrays... var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); @@ -247,7 +244,7 @@ var JPIV = new Int32Array( 4 ); ] */ -dgetc2( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); +dgetc2.ndarray( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); // A => [ 0, 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] // JPIV = [ 0, 3, 3, 3 ] // IPIV = [ 0, 3, 3, 3 ] @@ -261,16 +258,11 @@ dgetc2( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); ## Notes -- `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q`; the unit diagonal elements of L are not stored. - +- `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization `A = P*L*U*Q`, the unit diagonal elements of L are not stored. - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. - - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). - - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). - - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. - - `dgetc2()` corresponds to the [LAPACK][LAPACK] function [`dgetc2`][lapack-dgetc2]. @@ -289,7 +281,6 @@ dgetc2( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); -var dgetc2 = require( './../lib' ); var N = 3; var LDA = 3; @@ -302,7 +293,6 @@ console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); var IPIV = new Int32Array( N ); var JPIV = new Int32Array( N ); - // Perform the `A = LU` factorization: var info = dgetc2( 'column-major', N, A, LDA, IPIV, JPIV ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js index bbaa6ef00695..81008acfb3d3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js index b3360b61c5d0..8e1ffbdf79f0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 87f5fc6e3439b5b50187f340fa6991eebc09ad1b Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 3 Feb 2026 22:45:14 +0530 Subject: [PATCH 3/9] fix: imports in README file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md index ffda0ab437f3..6c8b42c209b9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md @@ -119,6 +119,7 @@ Computes the LU factorization with complete pivoting of the general n-by-n matri ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); var IPIV = new Int32Array( 3 ); @@ -144,8 +145,8 @@ The function has the following parameters: - **N**: number of columns in matrix `A`. - **A**: input matrix (overwritten by `L` and `U`) stored in linear memory as a [`Float64Array`][mdn-float64array]. - **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). -- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-float64array]. -- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-float64array]. +- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-int32array]. +- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-int32array]. The function returns the status code `info`. @@ -156,6 +157,7 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); // Initial arrays... var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); @@ -190,6 +192,7 @@ Computes the LU factorization with complete pivoting of the general n-by-n matri ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); var IPIV = new Int32Array( 3 ); @@ -216,10 +219,10 @@ The function has the following parameters: - **sa1**: stride of the first dimension of `A`. - **sa2**: stride of the second dimension of `A`. - **oa**: index offset for `A`. -- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-float64array]. +- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-int32array]. - **si**: stride length for `IPIV`. - **oi**: index offset for `IPIV`. -- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-float64array]. +- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-int32array]. - **sj**: stride length for `JPIV`. - **oj**: index offset for `JPIV`. @@ -230,6 +233,7 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); // Initial arrays... var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); @@ -281,6 +285,7 @@ dgetc2.ndarray( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); var N = 3; var LDA = 3; From 37a18bb9dd8f2fe2f74606d27c54bc935df5ac47 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Sat, 7 Feb 2026 23:55:27 +0530 Subject: [PATCH 4/9] fix: improve the indexing method inside `for` loop --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/lib/base.js | 37 ++++++--- .../base/dgetc2/test/fixtures/sym_mat.json | 79 +++++++++++++++++++ .../lapack/base/dgetc2/test/test.dgetc2.js | 54 ++++++++++--- .../lapack/base/dgetc2/test/test.ndarray.js | 55 ++++++------- 4 files changed, 174 insertions(+), 51 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js index 295d9569b78b..c3e0ede60912 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -53,7 +53,7 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * @param {Int32Array} JPIV - vector of pivot indices for columns * @param {integer} strideJPIV - stride length for `JPIV` * @param {NonNegativeInteger} offsetJPIV - index offset for `JPIV` -* @returns {integer} - status code +* @returns {integer} status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -73,6 +73,8 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV var info; var smin; var xmax; + var idx1; + var idx2; var eps; var ipv; var jpv; @@ -81,6 +83,7 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV var ip; var jp; var oA; + var sN; var i; var j; @@ -114,26 +117,33 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV // Set pivots less than SMIN to SMIN. for ( i = 0; i < N - 1; i++ ) { // Find max element in matrix A + idx1 = oA + ( i*( sA1 + sA2 ) ); xmax = 0.0; if ( isRowMajor( [ sA1, sA2 ] ) ) { for ( ip = i; ip < N; ip++ ) { + idx2 = idx1; for ( jp = i; jp < N; jp++ ) { - if ( abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ) >= xmax ) { - xmax = abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ); + if ( abs( A[ idx2 ] ) >= xmax ) { + xmax = abs( A[ idx2 ] ); ipv = ip; jpv = jp; } + idx2 += sA2; } + idx1 += sA1; } } else { // column-major for ( jp = i; jp < N; jp++ ) { + idx2 = idx1; for ( ip = i; ip < N; ip++ ) { - if ( abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ]) >= xmax ) { - xmax = abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ); + if ( abs( A[ idx2 ]) >= xmax ) { + xmax = abs( A[ idx2 ] ); ipv = ip; jpv = jp; } + idx2 += sA1; } + idx1 += sA2; } } @@ -145,20 +155,29 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV if ( ipv !== i ) { dswap.ndarray( N, A, sA2, oA + ( sA1*ipv ), A, sA2, oA+( sA1*i ) ); } - IPIV[ offsetIPIV + ( i*strideIPIV ) ] = ipv+1; + IPIV[ offsetIPIV + ( i*strideIPIV ) ] = ipv + 1; // Swap columns if ( jpv !== i ) { dswap.ndarray( N, A, sA1, oA + ( sA2*jpv ), A, sA1, oA+( sA2*i ) ); } - JPIV[ offsetJPIV + ( i*strideJPIV ) ] = jpv+1; + JPIV[ offsetJPIV + ( i*strideJPIV ) ] = jpv + 1; // Check for singularity + idx1 = oA + ( i*( sA1 + sA2 ) ); + if ( abs( A[ idx1 ] ) < smin ) { + info = i+1; + A[ idx1 ] = smin; + } + idx2 = oA + ( ( i + 1 )*sA1 ) + ( i*sA2 ); for ( j = i+1; j < N; j++ ) { - A[ oA + ( j*sA1 ) + ( i*sA2 ) ] /= A[ oA + ( i*( sA1 + sA2 ) ) ]; + A[ idx2 ] /= A[ idx1 ]; + idx2 += sA1; } - dger.ndarray( N - i-1, N - i-1, -1, A, sA1, oA + ( ( i + 1 )*sA1 ) + ( i*sA2 ), A, sA2, oA + ( i*sA1 ) + ( ( i + 1 )*sA2 ), A, sA1, sA2, oA + ( ( i + 1 )*( sA1 + sA2 ) ) ); // eslint-disable-line max-len + // Sub Matrix size + sN = N - i - 1; + dger.ndarray( sN, sN, -1, A, sA1, idx1 + sA1, A, sA2, idx1 + sA2, A, sA1, sA2, idx1 + sA1 + sA2 ); // eslint-disable-line max-len } if ( abs( A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] ) < smin ) { diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json new file mode 100644 index 000000000000..1a0638d59a19 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1.0, + 2.0, + 3.0 + ], + [ + 2.0, + 4.0, + 6.0 + ], + [ + 3.0, + 6.0, + 9.0 + ] + ], + "A": [ + 1.0, + 2.0, + 3.0, + 2.0, + 4.0, + 6.0, + 3.0, + 6.0, + 9.0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 9.0, + 3.0, + 6.0 + ], + [ + 0.3333333333333333, + 0.000000000000001998401444325282, + 0.0 + ], + [ + 0.6666666666666666, + 0.0, + 0.000000000000001998401444325282 + ] + ], + "A_out": [ + 9.0, + 0.3333333333333333, + 0.6666666666666666, + 3.0, + 0.000000000000001998401444325282, + 0.0, + 6.0, + 0.0, + 0.000000000000001998401444325282 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js index 09911b9a3504..c5f1d4ba5c14 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js @@ -28,6 +28,17 @@ var abs = require( '@stdlib/math/base/special/abs' ); var dgetc2 = require( './../lib/dgetc2.js' ); +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +var SYM_MAT = require( './fixtures/sym_mat.json' ); +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); +var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); + + // FUNCTIONS // /** @@ -57,19 +68,6 @@ function isApprox( t, actual, expected, rtol ) { } -// FIXTURES // - -// Note: the outputs are tested against the outputs of the Fortran implementation. - -/* eslint-disable vars-on-top */ -var COL_MAJOR = require( './fixtures/column_major.json' ); -var ROW_MAJOR = require( './fixtures/row_major.json' ); -var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); -var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); - -/* eslint-enable vars-on-top */ - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -216,6 +214,36 @@ tape( 'the function computes the LU factorization with complete pivoting of the t.end(); }); +tape( 'the function cannot successfully complete the LU factorization with complete pivoting of a singular matrix `A`', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = SYM_MAT; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major)', function test( t ) { var expectedIPIV; var expectedJPIV; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js index 7ece58599999..5bbc94ba5685 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js @@ -30,6 +30,32 @@ var abs = require( '@stdlib/math/base/special/abs' ); var dgetc2 = require( './../lib/ndarray.js' ); +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); +var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); +var LARGE_STRIDES_COL_MAJOR = require( './fixtures/large_strides/column_major.json' ); +var LARGE_STRIDES_ROW_MAJOR = require( './fixtures/large_strides/row_major.json' ); +var LARGE_STRIDES_COL_I_GT_0 = require( './fixtures/large_strides/column_major_i_gt_0.json' ); +var LARGE_STRIDES_ROW_I_GT_0 = require( './fixtures/large_strides/row_major_i_gt_0.json' ); +var NEGATIVE_STRIDES_COL_MAJOR = require( './fixtures/negative_strides/column_major.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR = require( './fixtures/negative_strides/row_major.json' ); +var NEGATIVE_STRIDES_COL_I_GT_0 = require( './fixtures/negative_strides/column_major_i_gt_0.json' ); +var NEGATIVE_STRIDES_ROW_I_GT_0 = require( './fixtures/negative_strides/row_major_i_gt_0.json' ); +var MIXED_STRIDES_COL_MAJOR = require( './fixtures/mixed_strides/column_major.json' ); +var MIXED_STRIDES_ROW_MAJOR = require( './fixtures/mixed_strides/row_major.json' ); +var MIXED_STRIDES_COL_I_GT_0 = require( './fixtures/mixed_strides/column_major_i_gt_0.json' ); +var MIXED_STRIDES_ROW_I_GT_0 = require( './fixtures/mixed_strides/row_major_i_gt_0.json' ); +var OFFSETS_COL_MAJOR = require( './fixtures/offsets/column_major.json' ); +var OFFSETS_ROW_MAJOR = require( './fixtures/offsets/row_major.json' ); +var OFFSETS_COL_I_GT_0 = require( './fixtures/offsets/column_major_i_gt_0.json' ); +var OFFSETS_ROW_I_GT_0 = require( './fixtures/offsets/row_major_i_gt_0.json' ); + + // FUNCTIONS // /** @@ -59,35 +85,6 @@ function isApprox( t, actual, expected, rtol ) { } -// FIXTURES // - -// Note: the outputs are tested against the outputs of the Fortran implementation. - -/* eslint-disable vars-on-top, id-length */ -var COL_MAJOR = require( './fixtures/column_major.json' ); -var ROW_MAJOR = require( './fixtures/row_major.json' ); -var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); -var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); -var LARGE_STRIDES_COL_MAJOR = require( './fixtures/large_strides/column_major.json' ); -var LARGE_STRIDES_ROW_MAJOR = require( './fixtures/large_strides/row_major.json' ); -var LARGE_STRIDES_COL_I_GT_0 = require( './fixtures/large_strides/column_major_i_gt_0.json' ); -var LARGE_STRIDES_ROW_I_GT_0 = require( './fixtures/large_strides/row_major_i_gt_0.json' ); -var NEGATIVE_STRIDES_COL_MAJOR = require( './fixtures/negative_strides/column_major.json' ); -var NEGATIVE_STRIDES_ROW_MAJOR = require( './fixtures/negative_strides/row_major.json' ); -var NEGATIVE_STRIDES_COL_I_GT_0 = require( './fixtures/negative_strides/column_major_i_gt_0.json' ); -var NEGATIVE_STRIDES_ROW_I_GT_0 = require( './fixtures/negative_strides/row_major_i_gt_0.json' ); -var MIXED_STRIDES_COL_MAJOR = require( './fixtures/mixed_strides/column_major.json' ); -var MIXED_STRIDES_ROW_MAJOR = require( './fixtures/mixed_strides/row_major.json' ); -var MIXED_STRIDES_COL_I_GT_0 = require( './fixtures/mixed_strides/column_major_i_gt_0.json' ); -var MIXED_STRIDES_ROW_I_GT_0 = require( './fixtures/mixed_strides/row_major_i_gt_0.json' ); -var OFFSETS_COL_MAJOR = require( './fixtures/offsets/column_major.json' ); -var OFFSETS_ROW_MAJOR = require( './fixtures/offsets/row_major.json' ); -var OFFSETS_COL_I_GT_0 = require( './fixtures/offsets/column_major_i_gt_0.json' ); -var OFFSETS_ROW_I_GT_0 = require( './fixtures/offsets/row_major_i_gt_0.json' ); - -/* eslint-enable vars-on-top, id-length */ - - // TESTS // tape( 'main export is a function', function test( t ) { From 65774259fdd5bd357501e232f04bd47769d5d457 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Sat, 14 Feb 2026 16:15:43 +0530 Subject: [PATCH 5/9] fix: improve indexing --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/lib/base.js | 92 +++++++++---------- .../test/fixtures/column_major_i_gt_0.json | 2 +- .../large_strides/column_major_i_gt_0.json | 2 +- .../large_strides/row_major_i_gt_0.json | 2 +- .../mixed_strides/column_major_i_gt_0.json | 2 +- .../mixed_strides/row_major_i_gt_0.json | 2 +- .../negative_strides/column_major_i_gt_0.json | 2 +- .../negative_strides/row_major_i_gt_0.json | 2 +- .../fixtures/offsets/column_major_i_gt_0.json | 2 +- .../fixtures/offsets/row_major_i_gt_0.json | 2 +- .../test/fixtures/row_major_i_gt_0.json | 2 +- .../lapack/base/dgetc2/test/test.dgetc2.js | 2 +- 12 files changed, 54 insertions(+), 60 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js index c3e0ede60912..117dcc409d4e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -21,8 +21,8 @@ // MODULES // var dlamch = require( '@stdlib/lapack/base/dlamch' ); -var dswap = require( '@stdlib/blas/base/dswap' ); -var dger = require( '@stdlib/blas/base/dger' ); +var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; +var dger = require( '@stdlib/blas/base/dger' ).ndarray; var abs = require( '@stdlib/math/base/special/abs' ); var max = require( '@stdlib/math/base/special/max' ); var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); @@ -73,24 +73,19 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV var info; var smin; var xmax; - var idx1; - var idx2; + var dx0; + var dx1; var eps; var ipv; var jpv; - var sA1; - var sA2; - var ip; - var jp; - var oA; + var ix1; + var ix2; + var i0; + var i1; var sN; var i; var j; - sA1 = strideA1; - sA2 = strideA2; - oA = offsetA; - info = 0; // Quick return if possible @@ -106,9 +101,9 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV if ( N === 1 ) { IPIV[ offsetIPIV ] = 1; JPIV[ offsetJPIV ] = 1; - if ( abs( A[ oA ] )< smlnum ) { + if ( abs( A[ offsetA ] )< smlnum ) { info = 1; - A[ oA ] = smlnum; + A[ offsetA ] = smlnum; } return info; } @@ -117,34 +112,33 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV // Set pivots less than SMIN to SMIN. for ( i = 0; i < N - 1; i++ ) { // Find max element in matrix A - idx1 = oA + ( i*( sA1 + sA2 ) ); xmax = 0.0; - if ( isRowMajor( [ sA1, sA2 ] ) ) { - for ( ip = i; ip < N; ip++ ) { - idx2 = idx1; - for ( jp = i; jp < N; jp++ ) { - if ( abs( A[ idx2 ] ) >= xmax ) { - xmax = abs( A[ idx2 ] ); - ipv = ip; - jpv = jp; - } - idx2 += sA2; - } - idx1 += sA1; - } + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + dx0 = strideA2; + dx1 = strideA1 - ( N*strideA2 ); } else { // column-major - for ( jp = i; jp < N; jp++ ) { - idx2 = idx1; - for ( ip = i; ip < N; ip++ ) { - if ( abs( A[ idx2 ]) >= xmax ) { - xmax = abs( A[ idx2 ] ); - ipv = ip; - jpv = jp; + dx0 = strideA1; + dx1 = strideA2 - ( N*strideA1 ); + } + + ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )` + + for ( i1 = i; i1 < N; i1++ ) { + for ( i0 = i; i0 < N; i0++ ) { + if ( abs( A[ ix1 ] ) >= xmax ) { + xmax = abs( A[ ix1 ] ); + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ipv = i1; + jpv = i0; + } else { // column-major + ipv = i0; + jpv = i1; } - idx2 += sA1; } - idx1 += sA2; + ix1 += dx0; } + ix1 += dx1 + ( i*dx0 ); } if ( i === 0 ) { @@ -153,36 +147,36 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV // Swap rows if ( ipv !== i ) { - dswap.ndarray( N, A, sA2, oA + ( sA1*ipv ), A, sA2, oA+( sA1*i ) ); + dswap( N, A, strideA2, offsetA + ( strideA1*ipv ), A, strideA2, offsetA+( strideA1*i ) ); // eslint-disable-line max-len } IPIV[ offsetIPIV + ( i*strideIPIV ) ] = ipv + 1; // Swap columns if ( jpv !== i ) { - dswap.ndarray( N, A, sA1, oA + ( sA2*jpv ), A, sA1, oA+( sA2*i ) ); + dswap( N, A, strideA1, offsetA + ( strideA2*jpv ), A, strideA1, offsetA+( strideA2*i ) ); // eslint-disable-line max-len } JPIV[ offsetJPIV + ( i*strideJPIV ) ] = jpv + 1; // Check for singularity - idx1 = oA + ( i*( sA1 + sA2 ) ); - if ( abs( A[ idx1 ] ) < smin ) { + ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )` + if ( abs( A[ ix1 ] ) < smin ) { info = i+1; - A[ idx1 ] = smin; + A[ ix1 ] = smin; } - idx2 = oA + ( ( i + 1 )*sA1 ) + ( i*sA2 ); + ix2 = ix1 + strideA1; // Index of `A( i+1, i )` for ( j = i+1; j < N; j++ ) { - A[ idx2 ] /= A[ idx1 ]; - idx2 += sA1; + A[ ix2 ] /= A[ ix1 ]; + ix2 += strideA1; } // Sub Matrix size sN = N - i - 1; - dger.ndarray( sN, sN, -1, A, sA1, idx1 + sA1, A, sA2, idx1 + sA2, A, sA1, sA2, idx1 + sA1 + sA2 ); // eslint-disable-line max-len + dger( sN, sN, -1, A, strideA1, ix1 + strideA1, A, strideA2, ix1 + strideA2, A, strideA1, strideA2, ix1 + strideA1 + strideA2 ); // eslint-disable-line max-len } - if ( abs( A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] ) < smin ) { + if ( abs( A[ ( offsetA ) + ( ( N-1 )*( strideA1+strideA2 ) ) ] ) < smin ) { info = N; - A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] = smin; + A[ ( offsetA ) + ( ( N - 1 )*( strideA1 + strideA2 ) ) ] = smin; } IPIV[ offsetIPIV + ( ( N - 1 )*strideIPIV ) ] = N; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json index cc4ee3637d46..f30ea7e85696 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "row-major", + "order": "column-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json index 562cc4590c98..e40270c05ad3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "row-major", + "order": "column-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json index 861b5885cde1..cda439154a32 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "column-major", + "order": "row-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json index 50e7687d77c9..d2ea2326ff6d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "row-major", + "order": "column-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json index bd3c96d3a998..86f37e8020d5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "column-major", + "order": "row-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json index 281b75ce54cd..9d6f479d1aea 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "row-major", + "order": "column-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json index 74c02d84da04..b0b5f270b05a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "column-major", + "order": "row-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json index 9752bd383398..1dd69c11118d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "row-major", + "order": "column-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json index 91aa4dd3c4e1..f48eb69be707 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "column-major", + "order": "row-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json index a7d88dc678bb..c36ebcb6a914 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json @@ -1,5 +1,5 @@ { - "order": "column-major", + "order": "row-major", "N": 3, "LDA": 3, "info": 3, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js index c5f1d4ba5c14..8e9ed0616332 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js @@ -332,7 +332,7 @@ tape( 'the function computes the LU factorization with complete pivoting of the t.end(); }); -tape( 'the function computes computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { +tape( 'the function computes computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0)', function test( t ) { var expectedIPIV; var expectedJPIV; var expectedA; From 809a4971603101a5849e833cd446cea073fb5c39 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Sat, 14 Feb 2026 16:18:54 +0530 Subject: [PATCH 6/9] fix: improve indexing --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js index 117dcc409d4e..e98d34bf938b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -116,10 +116,10 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV if ( isRowMajor( [ strideA1, strideA2 ] ) ) { dx0 = strideA2; - dx1 = strideA1 - ( N*strideA2 ); + dx1 = strideA1 - ( N*strideA2 ) + ( i*dx0 ); } else { // column-major dx0 = strideA1; - dx1 = strideA2 - ( N*strideA1 ); + dx1 = strideA2 - ( N*strideA1 ) + ( i*dx0 ); } ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )` @@ -138,7 +138,7 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV } ix1 += dx0; } - ix1 += dx1 + ( i*dx0 ); + ix1 += dx1; } if ( i === 0 ) { From 842df893d494e313d39af1137eb548fb6e16fd9b Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Sun, 15 Feb 2026 09:41:00 +0530 Subject: [PATCH 7/9] refactor: pre-calculate bound variables --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/lib/base.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js index e98d34bf938b..8c45205bb515 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -28,6 +28,12 @@ var max = require( '@stdlib/math/base/special/max' ); var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +// VARIABLES // + +var EPS = dlamch( 'P' ); +var SMLNUM = dlamch( 'S' ) / EPS; + + // MAIN // /** @@ -69,13 +75,11 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * // IPIV = [ 3, 3, 3 ] */ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ) { // eslint-disable-line max-params, max-len - var smlnum; var info; var smin; var xmax; var dx0; var dx1; - var eps; var ipv; var jpv; var ix1; @@ -93,17 +97,13 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV return info; } - // Set constants to control overflow - eps = dlamch( 'P' ); - smlnum = dlamch( 'S' ) / eps; - // Handle the case N=1 by itself if ( N === 1 ) { IPIV[ offsetIPIV ] = 1; JPIV[ offsetJPIV ] = 1; - if ( abs( A[ offsetA ] )< smlnum ) { + if ( abs( A[ offsetA ] )< SMLNUM ) { info = 1; - A[ offsetA ] = smlnum; + A[ offsetA ] = SMLNUM; } return info; } @@ -142,7 +142,7 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV } if ( i === 0 ) { - smin = max( eps*xmax, smlnum ); + smin = max( EPS*xmax, SMLNUM ); } // Swap rows From c4adfeaba51c21a59a8a5afd022b52d9fbb940c7 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Tue, 3 Mar 2026 20:57:01 +0530 Subject: [PATCH 8/9] chore: minor cleanup --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/README.md | 24 +++++++------ .../lapack/base/dgetc2/benchmark/benchmark.js | 2 +- .../dgetc2/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dgetc2/docs/repl.txt | 1 + .../lapack/base/dgetc2/docs/types/index.d.ts | 20 +++++------ .../@stdlib/lapack/base/dgetc2/lib/base.js | 8 ++--- .../@stdlib/lapack/base/dgetc2/lib/dgetc2.js | 4 +-- .../@stdlib/lapack/base/dgetc2/lib/index.js | 4 +-- .../@stdlib/lapack/base/dgetc2/lib/ndarray.js | 6 ++-- .../dgetc2/test/fixtures/column_major.json | 36 ++++--------------- .../test/fixtures/column_major_i_gt_0.json | 36 ++++--------------- .../fixtures/large_strides/column_major.json | 36 ++++--------------- .../large_strides/column_major_i_gt_0.json | 36 ++++--------------- .../fixtures/large_strides/row_major.json | 36 ++++--------------- .../large_strides/row_major_i_gt_0.json | 36 ++++--------------- .../fixtures/mixed_strides/column_major.json | 36 ++++--------------- .../mixed_strides/column_major_i_gt_0.json | 36 ++++--------------- .../fixtures/mixed_strides/row_major.json | 36 ++++--------------- .../mixed_strides/row_major_i_gt_0.json | 36 ++++--------------- .../negative_strides/column_major.json | 36 ++++--------------- .../negative_strides/column_major_i_gt_0.json | 36 ++++--------------- .../fixtures/negative_strides/row_major.json | 36 ++++--------------- .../negative_strides/row_major_i_gt_0.json | 36 ++++--------------- .../test/fixtures/offsets/column_major.json | 36 ++++--------------- .../fixtures/offsets/column_major_i_gt_0.json | 36 ++++--------------- .../test/fixtures/offsets/row_major.json | 36 ++++--------------- .../fixtures/offsets/row_major_i_gt_0.json | 36 ++++--------------- .../base/dgetc2/test/fixtures/row_major.json | 36 ++++--------------- .../test/fixtures/row_major_i_gt_0.json | 36 ++++--------------- .../base/dgetc2/test/fixtures/sym_mat.json | 36 ++++--------------- 30 files changed, 164 insertions(+), 663 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md index 6c8b42c209b9..6ee9cc9710e7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md @@ -26,7 +26,7 @@ limitations under the License. The `dgetc2` routine computes an LU factorization of with complete pivoting a real N-by-N matrix `A`. The factorization has the form: - + ```math A = P L U Q @@ -36,9 +36,9 @@ A = P L U Q where `P` and `Q` are permutation matrices, `L` is lower triangular with unit diagonal elements and `U` is upper triangular. -For a 5-by-5 matrix `A`, elements are stored in three arrays: +For a 5-by-5 matrix `A`, elements are stored in the following way: - + ```math A = \left[ @@ -47,7 +47,7 @@ A = \left[ a_{2,1} & a_{2,2} & a_{2,3} & a_{2,4} & a_{2,5} \\ a_{3,1} & a_{3,2} & a_{3,3} & a_{3,4} & a_{3,5} \\ a_{4,1} & a_{4,2} & a_{4,3} & a_{4,4} & a_{4,5} \\ - a_{5,1} & a_{5,2} & a_{5,3} & a_{5,4} & a_{5,5} + a_{5,1} & a_{5,2} & a_{5,3} & a_{5,4} & a_{5,5} \end{array} \right] ``` @@ -61,7 +61,7 @@ After factorization, the elements of `L` and `U` are used to update `A`, where: The resulting `L` and `U` matrices have the following structure: - + ```math L = \left[ @@ -70,14 +70,14 @@ L = \left[ l_{2,1} & 0 & 0 & 0 & 0 \\ l_{3,1} & l_{3,2} & 0 & 0 & 0 \\ l_{4,1} & l_{4,2} & l_{4,3} & 0 & 0 \\ - l_{5,1} & l_{5,2} & l_{5,3} & l_{5,4} & 0 + l_{5,1} & l_{5,2} & l_{5,3} & l_{5,4} & 0 \end{array} \right] ``` - + ```math U = \left[ @@ -95,10 +95,14 @@ U = \left[ where the values of `L` and `U` are stored in A, as follows: + + ```math A_{out} = L + U ``` + + @@ -264,9 +268,9 @@ dgetc2.ndarray( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization `A = P*L*U*Q`, the unit diagonal elements of L are not stored. - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. -- `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). -- `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). -- Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +- `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). +- `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). +- Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in `Ax = b`. So U is perturbed to avoid the overflow. - `dgetc2()` corresponds to the [LAPACK][LAPACK] function [`dgetc2`][lapack-dgetc2]. diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js index 81008acfb3d3..05fc555796a5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js @@ -116,7 +116,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( ord, N ); - bench( format( '%s:order=%s,size=%d', pkg, ord, (N*N) ), f ); + bench( format( '%s:order=%s,size=%d', pkg, ord, N*N ), f ); } } } diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js index 8e1ffbdf79f0..cf3d5012ee4f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js @@ -123,7 +123,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( ord, N ); - bench( format( '%s:ndarray:order=%s,size=%d', pkg, ord, (N*N) ), f ); + bench( format( '%s:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); } } } diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt index ec9a3e902306..05cb428f28af 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt @@ -1,3 +1,4 @@ + {{alias}}( order, N, A, LDA, IPIV, JPIV ) Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts index 405be2bcd43b..53b0f9a3ee8d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts @@ -31,10 +31,10 @@ interface Routine { * * ## Notes * - * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q; the unit diagonal elements of L are not stored. + * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. - * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). - * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). + * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @param order - storage layout @@ -68,8 +68,8 @@ interface Routine { * * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. - * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). - * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). + * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @param N - number of columns in `A` @@ -107,11 +107,11 @@ interface Routine { * * ## Notes * -* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q; the unit diagonal elements of L are not stored. -* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. -* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). -* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). -* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @param order - storage layout * @param N - number of columns in `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js index 8c45205bb515..7e435d9650b5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -43,8 +43,8 @@ var SMLNUM = dlamch( 'S' ) / EPS; * * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. -* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). -* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @private @@ -147,13 +147,13 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV // Swap rows if ( ipv !== i ) { - dswap( N, A, strideA2, offsetA + ( strideA1*ipv ), A, strideA2, offsetA+( strideA1*i ) ); // eslint-disable-line max-len + dswap( N, A, strideA2, offsetA + ( strideA1*ipv ), A, strideA2, offsetA + ( strideA1*i ) ); // eslint-disable-line max-len } IPIV[ offsetIPIV + ( i*strideIPIV ) ] = ipv + 1; // Swap columns if ( jpv !== i ) { - dswap( N, A, strideA1, offsetA + ( strideA2*jpv ), A, strideA1, offsetA+( strideA2*i ) ); // eslint-disable-line max-len + dswap( N, A, strideA1, offsetA + ( strideA2*jpv ), A, strideA1, offsetA + ( strideA2*i ) ); // eslint-disable-line max-len } JPIV[ offsetJPIV + ( i*strideJPIV ) ] = jpv + 1; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js index ebc066e44a1f..482e14efe2e3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js @@ -37,8 +37,8 @@ var base = require( './base.js' ); * * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. -* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). -* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @param {string} order - storage layout diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js index 2fc3a9ba2f89..1ec106bc58e8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js @@ -25,8 +25,8 @@ * * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. -* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). -* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @module @stdlib/lapack/base/dgetc2 diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js index 3dcb61185689..d67a5957a747 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js @@ -30,10 +30,10 @@ var base = require( './base.js' ); * * ## Notes * -* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization `A = P*L*U*Q`; the unit diagonal elements of L are not stored. +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. -* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). -* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 0 <= i <= N-1, column i of the matrix has been interchanged with column JPIV(i). * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. * * @param {PositiveInteger} N - number of columns in matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json index d82deec5d31b..f8d1ea6b0731 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1.0, - 4.0, - 7.0 - ], - [ - 2.0, - 5.0, - 8.0 - ], - [ - 3.0, - 6.0, - 10.0 - ] + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] ], "A": [ 1.0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 10.0, - 3.0, - 6.0 - ], - [ - 0.7, - -1.0999999999999996, - -0.1999999999999993 - ], - [ - 0.8, - 0.3636363636363641, - 0.2727272727272718 - ] + [ 10.0, 3.0, 6.0 ], + [ 0.7, -1.0999999999999996, -0.1999999999999993 ], + [ 0.8, 0.3636363636363641, 0.2727272727272718 ] ], "A_out": [ 10.0, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json index f30ea7e85696..474c83645440 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1.0, - 0.0, - 0.0 - ], - [ - 0.0, - 1.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0 - ] + [ 1.0, 0.0, 0.0 ], + [ 0.0, 1.0, 0.0 ], + [ 0.0, 0.0, 0.0 ] ], "A": [ 1.0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 1.0, - 0.0, - 0.0 - ], - [ - 0.0, - 1.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0000000000000002220446049250313 - ] + [ 1.0, 0.0, 0.0 ], + [ 0.0, 1.0, 0.0 ], + [ 0.0, 0.0, 0.0000000000000002220446049250313 ] ], "A_out": [ 1.0, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json index 38a9ae69e57f..40fb97fc5e44 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 4, - 7 - ], - [ - 2, - 5, - 8 - ], - [ - 3, - 6, - 10 - ] + [ 1, 4, 7 ], + [ 2, 5, 8 ], + [ 3, 6, 10 ] ], "A": [ 1, @@ -64,21 +52,9 @@ "strideJPIV": 2, "offsetJPIV": 0, "A_out_mat": [ - [ - 10, - 3, - 6 - ], - [ - 0.7, - -1.0999999999999996, - -0.1999999999999993 - ], - [ - 0.8, - 0.3636363636363641, - 0.2727272727272718 - ] + [ 10, 3, 6 ], + [ 0.7, -1.0999999999999996, -0.1999999999999993 ], + [ 0.8, 0.3636363636363641, 0.2727272727272718 ] ], "A_out": [ 10, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json index e40270c05ad3..f5450ac8413f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 1, @@ -64,21 +52,9 @@ "strideJPIV": 2, "offsetJPIV": 0, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 1, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json index 4fb71f9ba7eb..b478be2074e7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 2, - 3 - ], - [ - 4, - 5, - 6 - ], - [ - 7, - 8, - 10 - ] + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 10 ] ], "A": [ 1, @@ -63,21 +51,9 @@ "strideJPIV": 2, "offsetJPIV": 0, "A_out_mat": [ - [ - 10, - 7, - 8 - ], - [ - 0.3, - -1.1, - -0.3999999999999999 - ], - [ - 0.6, - 0.181818181818182, - 0.2727272727272729 - ] + [ 10, 7, 8 ], + [ 0.3, -1.1, -0.3999999999999999 ], + [ 0.6, 0.181818181818182, 0.2727272727272729 ] ], "A_out": [ 10, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json index cda439154a32..a413d64a5eaa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 1, @@ -64,21 +52,9 @@ "strideJPIV": 2, "offsetJPIV": 0, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 1, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json index fc71cb4477f7..700bf4cc53aa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 4, - 7 - ], - [ - 2, - 5, - 8 - ], - [ - 3, - 6, - 10 - ] + [ 1, 4, 7 ], + [ 2, 5, 8 ], + [ 3, 6, 10 ] ], "A": [ 7, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 10, - 3, - 6 - ], - [ - 0.7, - -1.0999999999999996, - -0.1999999999999993 - ], - [ - 0.8, - 0.3636363636363641, - 0.2727272727272718 - ] + [ 10, 3, 6 ], + [ 0.7, -1.0999999999999996, -0.1999999999999993 ], + [ 0.8, 0.3636363636363641, 0.2727272727272718 ] ], "A_out": [ 6, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json index d2ea2326ff6d..cc8e782ac3b4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 0, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json index 539bfda870b8..14992c7e0817 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 2, - 3 - ], - [ - 4, - 5, - 6 - ], - [ - 7, - 8, - 10 - ] + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 10 ] ], "A": [ 7, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 10, - 7, - 8 - ], - [ - 0.3, - -1.1, - -0.3999999999999999 - ], - [ - 0.6, - 0.181818181818182, - 0.2727272727272729 - ] + [ 10, 7, 8 ], + [ 0.3, -1.1, -0.3999999999999999 ], + [ 0.6, 0.181818181818182, 0.2727272727272729 ] ], "A_out": [ 0.6, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json index 86f37e8020d5..6c35caeeb55e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 0, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json index 8f2ddb4f7e56..605186f75311 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 4, - 7 - ], - [ - 2, - 5, - 8 - ], - [ - 3, - 6, - 10 - ] + [ 1, 4, 7 ], + [ 2, 5, 8 ], + [ 3, 6, 10 ] ], "A": [ 10, @@ -49,21 +37,9 @@ "strideJPIV": -1, "offsetJPIV": 2, "A_out_mat": [ - [ - 10, - 3, - 6 - ], - [ - 0.7, - -1.0999999999999996, - -0.1999999999999993 - ], - [ - 0.8, - 0.3636363636363641, - 0.2727272727272718 - ] + [ 10, 3, 6 ], + [ 0.7, -1.0999999999999996, -0.1999999999999993 ], + [ 0.8, 0.3636363636363641, 0.2727272727272718 ] ], "A_out": [ 0.2727272727272718, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json index 9d6f479d1aea..37012338d3a5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 0, @@ -49,21 +37,9 @@ "strideJPIV": -1, "offsetJPIV": 2, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 2.220446049250313e-16, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json index 2af325229364..324ef08c03ad 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 2, - 3 - ], - [ - 4, - 5, - 6 - ], - [ - 7, - 8, - 10 - ] + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 10 ] ], "A": [ 10, @@ -49,21 +37,9 @@ "strideJPIV": -1, "offsetJPIV": 2, "A_out_mat": [ - [ - 10, - 7, - 8 - ], - [ - 0.3, - -1.1, - -0.3999999999999999 - ], - [ - 0.6, - 0.181818181818182, - 0.2727272727272729 - ] + [ 10, 7, 8 ], + [ 0.3, -1.1, -0.3999999999999999 ], + [ 0.6, 0.181818181818182, 0.2727272727272729 ] ], "A_out": [ 0.2727272727272729, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json index b0b5f270b05a..d31d8a8d68cd 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 0, @@ -49,21 +37,9 @@ "strideJPIV": -1, "offsetJPIV": 2, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 2.220446049250313e-16, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json index 765897d2bda5..34d01ff5ab3a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 4, - 7 - ], - [ - 2, - 5, - 8 - ], - [ - 3, - 6, - 10 - ] + [ 1, 4, 7 ], + [ 2, 5, 8 ], + [ 3, 6, 10 ] ], "A": [ 9999, @@ -52,21 +40,9 @@ "strideJPIV": 1, "offsetJPIV": 1, "A_out_mat": [ - [ - 10, - 3, - 6 - ], - [ - 0.7, - -1.0999999999999996, - -0.1999999999999993 - ], - [ - 0.8, - 0.3636363636363641, - 0.2727272727272718 - ] + [ 10, 3, 6 ], + [ 0.7, -1.0999999999999996, -0.1999999999999993 ], + [ 0.8, 0.3636363636363641, 0.2727272727272718 ] ], "A_out": [ 9999, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json index 1dd69c11118d..c5dc1cd66ce2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 9999, @@ -52,21 +40,9 @@ "strideJPIV": 1, "offsetJPIV": 1, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 9999, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json index 215e234f9618..4eabdb3a8301 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1, - 2, - 3 - ], - [ - 4, - 5, - 6 - ], - [ - 7, - 8, - 10 - ] + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 10 ] ], "A": [ 9999, @@ -52,21 +40,9 @@ "strideJPIV": 1, "offsetJPIV": 1, "A_out_mat": [ - [ - 10, - 7, - 8 - ], - [ - 0.3, - -1.1, - -0.3999999999999999 - ], - [ - 0.6, - 0.181818181818182, - 0.2727272727272729 - ] + [ 10, 7, 8 ], + [ 0.3, -1.1, -0.3999999999999999 ], + [ 0.6, 0.181818181818182, 0.2727272727272729 ] ], "A_out": [ 9999, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json index f48eb69be707..c2d0489db2c1 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 0 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 0 ] ], "A": [ 9999, @@ -52,21 +40,9 @@ "strideJPIV": 1, "offsetJPIV": 1, "A_out_mat": [ - [ - 1, - 0, - 0 - ], - [ - 0, - 1, - 0 - ], - [ - 0, - 0, - 2.220446049250313e-16 - ] + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 0, 0, 2.220446049250313e-16 ] ], "A_out": [ 9999, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json index 808671d82be8..94430029c332 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 0, "A_mat": [ - [ - 1.0, - 2.0, - 3.0 - ], - [ - 4.0, - 5.0, - 6.0 - ], - [ - 7.0, - 8.0, - 10.0 - ] + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ], + [ 7.0, 8.0, 10.0 ] ], "A": [ 1.0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 10.0, - 7.0, - 8.0 - ], - [ - 0.3, - -1.1000000000000001, - -0.3999999999999999 - ], - [ - 0.6, - 0.1818181818181820, - 0.2727272727272729 - ] + [ 10.0, 7.0, 8.0 ], + [ 0.3, -1.1000000000000001, -0.3999999999999999 ], + [ 0.6, 0.1818181818181820, 0.2727272727272729 ] ], "A_out": [ 10.0, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json index c36ebcb6a914..7a3a59c4c8ba 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1.0, - 0.0, - 0.0 - ], - [ - 0.0, - 1.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0 - ] + [ 1.0, 0.0, 0.0 ], + [ 0.0, 1.0, 0.0 ], + [ 0.0, 0.0, 0.0 ] ], "A": [ 1.0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 1.0, - 0.0, - 0.0 - ], - [ - 0.0, - 1.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0000000000000002220446049250313 - ] + [ 1.0, 0.0, 0.0 ], + [ 0.0, 1.0, 0.0 ], + [ 0.0, 0.0, 0.0000000000000002220446049250313 ] ], "A_out": [ 1.0, diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json index 1a0638d59a19..e6fa494ad224 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/sym_mat.json @@ -4,21 +4,9 @@ "LDA": 3, "info": 3, "A_mat": [ - [ - 1.0, - 2.0, - 3.0 - ], - [ - 2.0, - 4.0, - 6.0 - ], - [ - 3.0, - 6.0, - 9.0 - ] + [ 1.0, 2.0, 3.0 ], + [ 2.0, 4.0, 6.0 ], + [ 3.0, 6.0, 9.0 ] ], "A": [ 1.0, @@ -49,21 +37,9 @@ "strideJPIV": 1, "offsetJPIV": 0, "A_out_mat": [ - [ - 9.0, - 3.0, - 6.0 - ], - [ - 0.3333333333333333, - 0.000000000000001998401444325282, - 0.0 - ], - [ - 0.6666666666666666, - 0.0, - 0.000000000000001998401444325282 - ] + [ 9.0, 3.0, 6.0 ], + [ 0.3333333333333333, 0.000000000000001998401444325282, 0.0 ], + [ 0.6666666666666666, 0.0, 0.000000000000001998401444325282 ] ], "A_out": [ 9.0, From 253a601c5b1e37e92a8f55a59be85e1f21fe72f2 Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Wed, 25 Mar 2026 11:45:07 +0530 Subject: [PATCH 9/9] refactor: eliminate the row-major check for each element --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dgetc2/lib/base.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js index 7e435d9650b5..a7bf9348a918 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -114,31 +114,38 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV // Find max element in matrix A xmax = 0.0; + ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )` + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { dx0 = strideA2; dx1 = strideA1 - ( N*strideA2 ) + ( i*dx0 ); + + for ( i1 = i; i1 < N; i1++ ) { + for ( i0 = i; i0 < N; i0++ ) { + if ( abs( A[ ix1 ] ) >= xmax ) { + xmax = abs( A[ ix1 ] ); + ipv = i1; + jpv = i0; + } + ix1 += dx0; + } + ix1 += dx1; + } } else { // column-major dx0 = strideA1; dx1 = strideA2 - ( N*strideA1 ) + ( i*dx0 ); - } - - ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )` - for ( i1 = i; i1 < N; i1++ ) { - for ( i0 = i; i0 < N; i0++ ) { - if ( abs( A[ ix1 ] ) >= xmax ) { - xmax = abs( A[ ix1 ] ); - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - ipv = i1; - jpv = i0; - } else { // column-major + for ( i1 = i; i1 < N; i1++ ) { + for ( i0 = i; i0 < N; i0++ ) { + if ( abs( A[ ix1 ] ) >= xmax ) { + xmax = abs( A[ ix1 ] ); ipv = i0; jpv = i1; } + ix1 += dx0; } - ix1 += dx0; + ix1 += dx1; } - ix1 += dx1; } if ( i === 0 ) {