From 9113c7196a95a0b5b43c9ef5fecabb7e19c28526 Mon Sep 17 00:00:00 2001 From: iampratik13 Date: Mon, 15 Jun 2026 15:44:19 +0530 Subject: [PATCH 1/4] feat: add lapack/base/dgetf2 --- .../@stdlib/lapack/base/dgetf2/README.md | 230 +++++++++++++++ .../lapack/base/dgetf2/benchmark/benchmark.js | 107 +++++++ .../dgetf2/benchmark/benchmark.ndarray.js | 107 +++++++ .../@stdlib/lapack/base/dgetf2/docs/repl.txt | 120 ++++++++ .../lapack/base/dgetf2/docs/types/index.d.ts | 115 ++++++++ .../lapack/base/dgetf2/docs/types/test.ts | 160 +++++++++++ .../lapack/base/dgetf2/examples/index.js | 49 ++++ .../@stdlib/lapack/base/dgetf2/lib/base.js | 136 +++++++++ .../@stdlib/lapack/base/dgetf2/lib/dgetf2.js | 80 ++++++ .../@stdlib/lapack/base/dgetf2/lib/index.js | 72 +++++ .../@stdlib/lapack/base/dgetf2/lib/main.js | 35 +++ .../@stdlib/lapack/base/dgetf2/lib/ndarray.js | 60 ++++ .../@stdlib/lapack/base/dgetf2/package.json | 72 +++++ .../fixtures/column_major_large_strides.json | 85 ++++++ .../fixtures/column_major_mixed_strides.json | 61 ++++ .../column_major_negative_strides.json | 61 ++++ .../test/fixtures/column_major_offsets.json | 65 +++++ .../test/fixtures/column_major_singular.json | 61 ++++ .../test/fixtures/column_major_square.json | 61 ++++ .../test/fixtures/column_major_tall.json | 83 ++++++ .../test/fixtures/column_major_wide.json | 79 +++++ .../fixtures/row_major_large_strides.json | 85 ++++++ .../fixtures/row_major_mixed_strides.json | 61 ++++ .../fixtures/row_major_negative_strides.json | 61 ++++ .../test/fixtures/row_major_offsets.json | 65 +++++ .../test/fixtures/row_major_singular.json | 61 ++++ .../test/fixtures/row_major_square.json | 61 ++++ .../dgetf2/test/fixtures/row_major_tall.json | 83 ++++++ .../dgetf2/test/fixtures/row_major_wide.json | 79 +++++ .../lapack/base/dgetf2/test/test.dgetf2.js | 269 ++++++++++++++++++ .../@stdlib/lapack/base/dgetf2/test/test.js | 82 ++++++ .../lapack/base/dgetf2/test/test.ndarray.js | 253 ++++++++++++++++ 32 files changed, 3059 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_large_strides.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_mixed_strides.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_negative_strides.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_offsets.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_singular.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_square.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_tall.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_wide.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_large_strides.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_mixed_strides.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_negative_strides.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_offsets.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_singular.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_square.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_tall.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_wide.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md new file mode 100644 index 000000000000..76bec91d272c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md @@ -0,0 +1,230 @@ + + +# dgetf2 + +> Compute the LU factorization of a general $M$-by-$N$ matrix $A$ using partial pivoting with row interchanges. + +
+ +The `dgetf2` routine computes an LU factorization of a general $M$-by-$N$ matrix $A$ using partial pivoting with row interchanges. The factorization has the form: + +```math +A = P L U +``` + +where $P$ is a permutation matrix, $L$ is lower unit triangular (with ones on the diagonal), and $U$ is upper triangular. + +
+ + + +
+ +## Usage + +```javascript +var dgetf2 = require( '@stdlib/lapack/base/dgetf2' ); +``` + +#### dgetf2( order, M, N, A, LDA, IPIV ) + +Computes an `LU` factorization of a general $M$-by-$N$ matrix $A$ using partial pivoting with row interchanges. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +var IPIV = new Int32Array( 2 ); + +var info = dgetf2( 'row-major', 2, 2, A, 2, IPIV ); +// returns 0 +``` + +The function has the following parameters: + +- **order**: storage layout (`'row-major'` or `'column-major'`). +- **M**: number of rows in matrix `A`. +- **N**: number of columns in matrix `A`. +- **A**: the input matrix $A$ as a [`Float64Array`][@stdlib/array/float64]. `A` is overwritten by the factors $L$ and $U$ from the factorization. +- **LDA**: stride of the first dimension of `A` (leading dimension of the matrix `A` if column-major, or stride between rows if row-major). +- **IPIV**: pivot indices as an [`Int32Array`][@stdlib/array/int32]. Pivot indices are 0-based. Should have at least $\min(M, N)$ elements. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +#### dgetf2.ndarray( M, N, A, sa1, sa2, oa, IPIV, si, oi ) + +Computes an `LU` factorization of a general $M$-by-$N$ matrix $A$ using partial pivoting with row interchanges and alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +var IPIV = new Int32Array( 2 ); + +var info = dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); +// returns 0 +``` + +The function has the following additional parameters: + +- **sa1**: row stride of `A`. +- **sa2**: column stride of `A`. +- **oa**: starting index of `A`. +- **si**: stride length for `IPIV`. +- **oi**: starting index of `IPIV`. + +
+ + + +
+ +## Notes + +- Both functions mutate the input arrays `A` and `IPIV`. + +- Both functions return a status code indicating success or failure. The status code indicates the following conditions: + + - `0`: factorization was successful. + - `>0`: $U(k, k)$ is exactly zero (where $k$ equals the status code value). The factorization has been completed, but the factor $U$ is exactly singular, and division by zero will occur if it is used to solve a system of equations. + +- `dgetf2()` corresponds to the [LAPACK][LAPACK] routine [`dgetf2`][lapack-dgetf2]. + +
+ + + +
+ +## Examples + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetf2 = require( '@stdlib/lapack/base/dgetf2' ); + +var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +var IPIV = new Int32Array( 2 ); + +var info = dgetf2( 'row-major', 2, 2, A, 2, IPIV ); +console.log( A ); +// => [ 4.0, 6.0, 0.5, -2.0 ] + +console.log( IPIV ); +// => [ 1, 1 ] + +console.log( info ); +// => 0 +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.js new file mode 100644 index 000000000000..c4c0e948afab --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgetf2 = require( './../lib/dgetf2.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var IPIV; + var A; + + opts = { + 'dtype': 'float64' + }; + + A = uniform( N*N, -10.0, 10.0, opts ); + IPIV = new Int32Array( N ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dgetf2( 'column-major', N, N, A, N, IPIV ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( format( '%s:order=column-major,size=%d', pkg, N*N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..89b6f83b57f5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/benchmark/benchmark.ndarray.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgetf2 = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var IPIV; + var A; + + opts = { + 'dtype': 'float64' + }; + + A = uniform( N*N, -10.0, 10.0, opts ); + IPIV = new Int32Array( N ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dgetf2( N, N, A, 1, N, 0, IPIV, 1, 0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( format( '%s:ndarray:order=column-major,size=%d', pkg, N*N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/repl.txt new file mode 100644 index 000000000000..2f6f6fa24860 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/repl.txt @@ -0,0 +1,120 @@ + +{{alias}}( order, M, N, A, LDA, IPIV ) + Computes the LU factorization of a general M-by-N matrix A using partial + pivoting with row interchanges. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The function mutates `A` and `IPIV`. + + Parameters + ---------- + order: string + Storage layout of `A`. Must be either 'row-major' or 'column-major'. + + M: integer + Number of rows in matrix `A`. + + N: integer + Number of columns in matrix `A`. + + A: Float64Array + Input matrix. Overwritten by the factors L and U from the + factorization. + + LDA: integer + Stride of the first dimension of `A` (leading dimension of the + matrix `A` if column-major, or stride between rows if row-major). + + IPIV: Int32Array + Vector of pivot indices. Pivot indices are 0-based. Should have at least + min(M, N) elements. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if greater than zero, then `U(k, k)` is exactly zero, where `k` equals + the status code value, indicating that the factor `U` is exactly + singular, and division by zero will occur if it is used to solve a + system of equations. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 2.0, 1.0, 4.0, 6.0 ] ); + > var IPIV = new {{alias:@stdlib/array/int32}}( [ 0, 0 ] ); + > {{alias}}( 'row-major', 2, 2, A, 2, IPIV ) + 0 + > A + [ 4.0, 6.0, 0.5, -2.0 ] + > IPIV + [ 1, 1 ] + + +{{alias}}.ndarray( M, N, A, sa1, sa2, oa, IPIV, si, oi ) + Computes the LU factorization of a general M-by-N matrix A using partial + pivoting with row interchanges and alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + The function mutates `A` and `IPIV`. + + Parameters + ---------- + M: integer + Number of rows in matrix `A`. + + N: integer + Number of columns in matrix `A`. + + A: Float64Array + Input matrix. Overwritten by the factors L and U from the + factorization. + + sa1: integer + Row stride of `A`. + + sa2: integer + Column stride of `A`. + + oa: integer + Starting index of `A`. + + IPIV: Int32Array + Vector of pivot indices. + + si: integer + Stride length for `IPIV`. + + oi: integer + Starting index of `IPIV`. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if greater than zero, then `U(k, k)` is exactly zero, where `k` equals + the status code value, indicating that the factor `U` is exactly + singular, and division by zero will occur if it is used to solve a + system of equations. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 2.0, 1.0, 4.0, 6.0 ] ); + > var IPIV = new {{alias:@stdlib/array/int32}}( [ 0, 0 ] ); + > {{alias}}.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ) + 0 + > A + [ 4.0, 6.0, 0.5, -2.0 ] + > IPIV + [ 1, 1 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/index.d.ts new file mode 100644 index 000000000000..b2c8afee7f1c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/index.d.ts @@ -0,0 +1,115 @@ +/* +* @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 `dgetf2`. +*/ +interface Routine { + /** + * Computes the LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges. + * + * @param order - storage layout of `A` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A` if column-major, or stride between rows if row-major) + * @param IPIV - vector of pivot indices + * @returns status code (0 if success, >0 if singular element index) + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + * var IPIV = new Int32Array( 2 ); + * + * var info = dgetf2( 'row-major', 2, 2, A, 2, IPIV ); + * // info => 0 + */ + ( order: Layout, M: number, N: number, A: Float64Array, LDA: number, IPIV: Int32Array ): number; + + /** + * Computes the LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges and alternative indexing semantics. + * + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param strideA1 - row stride of `A` + * @param strideA2 - column stride of `A` + * @param offsetA - starting index of `A` + * @param IPIV - vector of pivot indices + * @param strideIPIV - stride length for `IPIV` + * @param offsetIPIV - starting index of `IPIV` + * @returns status code (0 if success, >0 if singular element index) + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + * var IPIV = new Int32Array( 2 ); + * + * var info = dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); + * // info => 0 + */ + ndarray( M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): number; +} + +/** +* Computes the LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges. +* +* @param order - storage layout of `A` +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A` if column-major, or stride between rows if row-major) +* @param IPIV - vector of pivot indices +* @returns status code (0 if success, >0 if singular element index) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2( 'row-major', 2, 2, A, 2, IPIV ); +* // info => 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); +* // info => 0 +*/ +declare var dgetf2: Routine; + + +// EXPORTS // + +export = dgetf2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/test.ts new file mode 100644 index 000000000000..4cc7e3c975f4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/docs/types/test.ts @@ -0,0 +1,160 @@ +/* +* @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 dgetf2 = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2( 'row-major', 2, 2, A, 2, IPIV ); // $ExpectType number + dgetf2( 'column-major', 2, 2, A, 2, IPIV ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2( 5, 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( true, 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( false, 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( null, 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( void 0, 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( [], 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( {}, 2, 2, A, 2, IPIV ); // $ExpectError + dgetf2( ( x: number ): number => x, 2, 2, A, 2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2( 'row-major', '5', 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', true, 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', false, 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', null, 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', void 0, 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', [], 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', {}, 2, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', ( x: number ): number => x, 2, A, 2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2( 'row-major', 2, '5', A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, true, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, false, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, null, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, void 0, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, [], A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, {}, A, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, ( x: number ): number => x, A, 2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 2 ); + + dgetf2( 'row-major', 2, 2, '5', 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, 5, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, true, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, false, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, null, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, void 0, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, [], 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, {}, 2, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, ( x: number ): number => x, 2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2( 'row-major', 2, 2, A, '5', IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, true, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, false, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, null, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, void 0, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, [], IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, {}, IPIV ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, ( x: number ): number => x, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not an Int32Array... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + + dgetf2( 'row-major', 2, 2, A, 2, '5' ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, 5 ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, true ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, false ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, null ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, void 0 ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, [] ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, {} ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2(); // $ExpectError + dgetf2( 'row-major' ); // $ExpectError + dgetf2( 'row-major', 2 ); // $ExpectError + dgetf2( 'row-major', 2, 2 ); // $ExpectError + dgetf2( 'row-major', 2, 2, A ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2 ); // $ExpectError + dgetf2( 'row-major', 2, 2, A, 2, IPIV, 10 ); // $ExpectError +} + +// Attached to the main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); + const IPIV = new Int32Array( 2 ); + + dgetf2.ndarray(); // $ExpectError + dgetf2.ndarray( 2 ); // $ExpectError + dgetf2.ndarray( 2, 2 ); // $ExpectError + dgetf2.ndarray( 2, 2, A ); // $ExpectError + dgetf2.ndarray( 2, 2, A, 2 ); // $ExpectError + dgetf2.ndarray( 2, 2, A, 2, 1 ); // $ExpectError + dgetf2.ndarray( 2, 2, A, 2, 1, 0 ); // $ExpectError + dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV ); // $ExpectError + dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1 ); // $ExpectError + dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/examples/index.js new file mode 100644 index 000000000000..9a9d9ab8c515 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/examples/index.js @@ -0,0 +1,49 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var dgetf2 = require( './../lib' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +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 ); + +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var info = dgetf2( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], IPIV ); +console.log( info ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); +console.log( IPIV ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js new file mode 100644 index 000000000000..dcdc2c0d6640 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js @@ -0,0 +1,136 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); + + +// MAIN // + +/** +* Computes an `LU` factorization of a general M-by-N matrix `A` using partial pivoting with row interchanges. +* +* @private +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - row stride of `A` +* @param {integer} strideA2 - column stride of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} strideIPIV - stride length for `IPIV` +* @param {NonNegativeInteger} offsetIPIV - starting index of `IPIV` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); +* // info => 0 +*/ +function dgetf2( M, N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len + var maxVal; + var minMN; + var info; + var temp; + var val; + var jp; + var ip; + var r; + var c; + var j; + var o; + + if ( M === 0 || N === 0 ) { + return 0; + } + + minMN = ( M < N ) ? M : N; + info = 0; + + for ( j = 0; j < minMN; j++ ) { + // Find pivot (maximum absolute value in column j from row j to M-1): + maxVal = -1.0; + jp = j; + for ( r = j; r < M; r++ ) { + val = abs( A[ offsetA + ( r * strideA1 ) + ( j * strideA2 ) ] ); + if ( val > maxVal ) { + maxVal = val; + jp = r; + } + } + + // Store pivot row index in IPIV (using custom indexing/offset/stride for IPIV): + ip = offsetIPIV + ( j * strideIPIV ); + IPIV[ ip ] = jp; + + // Check for singularity: + temp = A[ offsetA + ( jp * strideA1 ) + ( j * strideA2 ) ]; + if ( temp !== 0.0 ) { + // Swap row j and row jp if they are not the same row: + if ( jp !== j ) { + for ( c = 0; c < N; c++ ) { + o = c * strideA2; + val = A[ offsetA + ( j * strideA1 ) + o ]; + A[ offsetA + ( j * strideA1 ) + o ] = + A[ offsetA + ( jp * strideA1 ) + o ]; + A[ offsetA + ( jp * strideA1 ) + o ] = val; + } + } + + // Scale elements below the diagonal in column j: + if ( j < M - 1 ) { + // Divide A[r, j] by A[j, j] for r = j+1 to M-1 + temp = A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ]; + for ( r = j + 1; r < M; r++ ) { + A[ offsetA + ( r * strideA1 ) + ( j * strideA2 ) ] /= temp; + } + } + } else if ( info === 0 ) { + info = j + 1; // 1-based index + } + + // Update trailing submatrix (rows j+1 to M-1, columns j+1 to N-1): + if ( j < minMN - 1 ) { + for ( c = j + 1; c < N; c++ ) { + temp = A[ offsetA + ( j * strideA1 ) + ( c * strideA2 ) ]; + if ( temp !== 0.0 ) { + for ( r = j + 1; r < M; r++ ) { + A[ offsetA + ( r * strideA1 ) + ( c * strideA2 ) ] -= + A[ offsetA + ( r * strideA1 ) + ( j * strideA2 ) ] * + temp; + } + } + } + } + } + + return info; +} + + +// EXPORTS // + +module.exports = dgetf2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js new file mode 100644 index 000000000000..c6625f15060a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js @@ -0,0 +1,80 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes an `LU` factorization of a general M-by-N matrix `A` using partial pivoting with row interchanges. +* +* @param {string} order - storage layout of `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A` if column-major, or stride between rows if row-major) +* @param {Int32Array} IPIV - vector of pivot indices +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fifth argument must be greater than or equal to `max(1, N)` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetf2 = require( '@stdlib/lapack/base/dgetf2' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2( 'row-major', 2, 2, A, 2, IPIV ); +* // info => 0 +*/ +function dgetf2( order, M, N, A, LDA, IPIV ) { + 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. Fifth 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( M, N, A, sa1, sa2, 0, IPIV, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dgetf2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/index.js new file mode 100644 index 000000000000..84b16005bf42 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute the LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges. +* +* @module @stdlib/lapack/base/dgetf2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetf2 = require( '@stdlib/lapack/base/dgetf2' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2( 'row-major', 2, 2, A, 2, IPIV ); +* // info => 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetf2 = require( '@stdlib/lapack/base/dgetf2' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); +* // info => 0 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dgetf2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgetf2 = main; +} else { + dgetf2 = tmp; +} + + +// EXPORTS // + +module.exports = dgetf2; + +// exports: { "ndarray": "dgetf2.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/main.js new file mode 100644 index 000000000000..ef8ac1677e66 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/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 dgetf2 = require( './dgetf2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgetf2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgetf2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/ndarray.js new file mode 100644 index 000000000000..a45b31cc918b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/ndarray.js @@ -0,0 +1,60 @@ +/** +* @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 an `LU` factorization of a general M-by-N matrix `A` using partial pivoting with row interchanges and alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - row stride of `A` +* @param {integer} strideA2 - column stride of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} strideIPIV - stride length for `IPIV` +* @param {NonNegativeInteger} offsetIPIV - starting index of `IPIV` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetf2 = require( '@stdlib/lapack/base/dgetf2' ); +* +* var A = new Float64Array( [ 2.0, 1.0, 4.0, 6.0 ] ); +* var IPIV = new Int32Array( 2 ); +* +* var info = dgetf2.ndarray( 2, 2, A, 2, 1, 0, IPIV, 1, 0 ); +* // info => 0 +*/ +function dgetf2( M, N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len + return base( M, N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgetf2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/package.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/package.json new file mode 100644 index 000000000000..fb933a4e2053 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/dgetf2", + "version": "0.0.0", + "description": "Compute the LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.", + "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", + "browser": "./lib/main.js", + "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", + "dgetf2", + "lu", + "factorization", + "pivot", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_large_strides.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_large_strides.json new file mode 100644 index 000000000000..6f115112e999 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_large_strides.json @@ -0,0 +1,85 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A": [ + 1, + 9999, + 4, + 9999, + 7, + 9999, + 2, + 9999, + 5, + 9999, + 8, + 9999, + 3, + 9999, + 6, + 9999, + 10, + 9999 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "IPIV": [ + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "A_out": [ + 7, + 9999, + 0.14285714285714285, + 9999, + 0.5714285714285714, + 9999, + 8, + 9999, + 0.8571428571428572, + 9999, + 0.5000000000000002, + 9999, + 10, + 9999, + 1.5714285714285716, + 9999, + -0.49999999999999967, + 9999 + ], + "IPIV_out": [ + 2, + 9999, + 2, + 9999, + 2, + 9999 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_mixed_strides.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_mixed_strides.json new file mode 100644 index 000000000000..bdffa0493f1c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_mixed_strides.json @@ -0,0 +1,61 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A": [ + 3, + 6, + 10, + 2, + 5, + 8, + 1, + 4, + 7 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": -3, + "offsetA": 6, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 10, + 1.5714285714285716, + -0.49999999999999967, + 8, + 0.8571428571428572, + 0.5000000000000002, + 7, + 0.14285714285714285, + 0.5714285714285714 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_negative_strides.json new file mode 100644 index 000000000000..4f1ca4d55f7d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_negative_strides.json @@ -0,0 +1,61 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A": [ + 10, + 6, + 3, + 8, + 5, + 2, + 7, + 4, + 1 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": -1, + "strideA2": -3, + "offsetA": 8, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "A_out": [ + -0.49999999999999967, + 1.5714285714285716, + 10, + 0.5000000000000002, + 0.8571428571428572, + 8, + 0.5714285714285714, + 0.14285714285714285, + 7 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_offsets.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_offsets.json new file mode 100644 index 000000000000..8d86b8ea7c62 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_offsets.json @@ -0,0 +1,65 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A": [ + 9999, + 1, + 4, + 7, + 2, + 5, + 8, + 3, + 6, + 10 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "IPIV": [ + 9999, + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "A_out": [ + 9999, + 7, + 0.14285714285714285, + 0.5714285714285714, + 8, + 0.8571428571428572, + 0.5000000000000002, + 10, + 1.5714285714285716, + -0.49999999999999967 + ], + "IPIV_out": [ + 9999, + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_singular.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_singular.json new file mode 100644 index 000000000000..5e8896b986de --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_singular.json @@ -0,0 +1,61 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A": [ + 1, + 2, + 3, + 2, + 4, + 6, + 3, + 7, + 10 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 2, + 4, + 7 + ], + [ + 3, + 6, + 10 + ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 3, + 0.6666666666666666, + 0.3333333333333333, + 6, + 0, + 0, + 10, + 0.3333333333333339, + -0.33333333333333304 + ], + "IPIV_out": [ + 2, + 1, + 2 + ], + "info_out": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_square.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_square.json new file mode 100644 index 000000000000..042c318accd1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_square.json @@ -0,0 +1,61 @@ +{ + "order": "column-major", + "M": 3, + "N": 3, + "A": [ + 1, + 4, + 7, + 2, + 5, + 8, + 3, + 6, + 10 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 7, + 0.14285714285714285, + 0.5714285714285714, + 8, + 0.8571428571428572, + 0.5000000000000002, + 10, + 1.5714285714285716, + -0.49999999999999967 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_tall.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_tall.json new file mode 100644 index 000000000000..05e17555cdb2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_tall.json @@ -0,0 +1,83 @@ +{ + "order": "column-major", + "M": 5, + "N": 3, + "A": [ + 1, + -4, + 7, + 2, + -3, + 2, + 5, + -8, + 0, + 4, + 3, + -6, + 9, + -1, + 5 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + -4, + 5, + -6 + ], + [ + 7, + -8, + 9 + ], + [ + 2, + 0, + -1 + ], + [ + -3, + 4, + 5 + ] + ], + "LDA": 5, + "strideA1": 1, + "strideA2": 5, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 7, + 0.14285714285714285, + -0.42857142857142855, + 0.2857142857142857, + -0.5714285714285714, + -8, + 3.142857142857143, + 0.18181818181818188, + 0.7272727272727273, + 0.13636363636363644, + 9, + 1.7142857142857144, + 8.545454545454547, + -0.5638297872340425, + -0.12765957446808515 + ], + "IPIV_out": [ + 2, + 2, + 4 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_wide.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_wide.json new file mode 100644 index 000000000000..46827a01a6a5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/column_major_wide.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "M": 3, + "N": 5, + "A": [ + 2, + 1, + 3, + 4, + 3, + 1, + 6, + 5, + 2, + 8, + 7, + 0, + 10, + 9, + -1 + ], + "A_mat": [ + [ + 2, + 4, + 6, + 8, + 10 + ], + [ + 1, + 3, + 5, + 7, + 9 + ], + [ + 3, + 1, + 2, + 0, + -1 + ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 3, + 0.6666666666666666, + 0.3333333333333333, + 1, + 3.3333333333333335, + 0.7999999999999999, + 2, + 4.666666666666667, + 0.5999999999999996, + 0, + 8, + 0.6000000000000005, + -1, + 10.666666666666666, + 0.8000000000000025 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_large_strides.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_large_strides.json new file mode 100644 index 000000000000..5d4c846eb939 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_large_strides.json @@ -0,0 +1,85 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 10, + 9999 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "IPIV": [ + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "A_out": [ + 7, + 9999, + 8, + 9999, + 10, + 9999, + 0.14285714285714285, + 9999, + 0.8571428571428572, + 9999, + 1.5714285714285716, + 9999, + 0.5714285714285714, + 9999, + 0.5000000000000002, + 9999, + -0.49999999999999967, + 9999 + ], + "IPIV_out": [ + 2, + 9999, + 2, + 9999, + 2, + 9999 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_mixed_strides.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_mixed_strides.json new file mode 100644 index 000000000000..36da95e93771 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_mixed_strides.json @@ -0,0 +1,61 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A": [ + 7, + 8, + 10, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": -3, + "strideA2": 1, + "offsetA": 6, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 0.5714285714285714, + 0.5000000000000002, + -0.49999999999999967, + 0.14285714285714285, + 0.8571428571428572, + 1.5714285714285716, + 7, + 8, + 10 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_negative_strides.json new file mode 100644 index 000000000000..4baec84f9cb7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_negative_strides.json @@ -0,0 +1,61 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A": [ + 10, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": -3, + "strideA2": -1, + "offsetA": 8, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "A_out": [ + -0.49999999999999967, + 0.5000000000000002, + 0.5714285714285714, + 1.5714285714285716, + 0.8571428571428572, + 0.14285714285714285, + 10, + 8, + 7 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_offsets.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_offsets.json new file mode 100644 index 000000000000..322b9adfc928 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_offsets.json @@ -0,0 +1,65 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 10 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "IPIV": [ + 9999, + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "A_out": [ + 9999, + 7, + 8, + 10, + 0.14285714285714285, + 0.8571428571428572, + 1.5714285714285716, + 0.5714285714285714, + 0.5000000000000002, + -0.49999999999999967 + ], + "IPIV_out": [ + 9999, + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_singular.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_singular.json new file mode 100644 index 000000000000..0e9291c837a7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_singular.json @@ -0,0 +1,61 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A": [ + 1, + 2, + 3, + 2, + 4, + 7, + 3, + 6, + 10 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 2, + 4, + 7 + ], + [ + 3, + 6, + 10 + ] + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 3, + 6, + 10, + 0.6666666666666666, + 0, + 0.3333333333333339, + 0.3333333333333333, + 0, + -0.33333333333333304 + ], + "IPIV_out": [ + 2, + 1, + 2 + ], + "info_out": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_square.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_square.json new file mode 100644 index 000000000000..ddba65619871 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_square.json @@ -0,0 +1,61 @@ +{ + "order": "row-major", + "M": 3, + "N": 3, + "A": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 10 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 7, + 8, + 10, + 0.14285714285714285, + 0.8571428571428572, + 1.5714285714285716, + 0.5714285714285714, + 0.5000000000000002, + -0.49999999999999967 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_tall.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_tall.json new file mode 100644 index 000000000000..bc2d00c6bf81 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_tall.json @@ -0,0 +1,83 @@ +{ + "order": "row-major", + "M": 5, + "N": 3, + "A": [ + 1, + 2, + 3, + -4, + 5, + -6, + 7, + -8, + 9, + 2, + 0, + -1, + -3, + 4, + 5 + ], + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + -4, + 5, + -6 + ], + [ + 7, + -8, + 9 + ], + [ + 2, + 0, + -1 + ], + [ + -3, + 4, + 5 + ] + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 7, + -8, + 9, + 0.14285714285714285, + 3.142857142857143, + 1.7142857142857144, + -0.42857142857142855, + 0.18181818181818188, + 8.545454545454547, + 0.2857142857142857, + 0.7272727272727273, + -0.5638297872340425, + -0.5714285714285714, + 0.13636363636363644, + -0.12765957446808515 + ], + "IPIV_out": [ + 2, + 2, + 4 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_wide.json b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_wide.json new file mode 100644 index 000000000000..fc4feef67fbb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/fixtures/row_major_wide.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "M": 3, + "N": 5, + "A": [ + 2, + 4, + 6, + 8, + 10, + 1, + 3, + 5, + 7, + 9, + 3, + 1, + 2, + 0, + -1 + ], + "A_mat": [ + [ + 2, + 4, + 6, + 8, + 10 + ], + [ + 1, + 3, + 5, + 7, + 9 + ], + [ + 3, + 1, + 2, + 0, + -1 + ] + ], + "LDA": 5, + "strideA1": 5, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 0, + 0, + 0 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "A_out": [ + 3, + 1, + 2, + 0, + -1, + 0.6666666666666666, + 3.3333333333333335, + 4.666666666666667, + 8, + 10.666666666666666, + 0.3333333333333333, + 0.7999999999999999, + 0.5999999999999996, + 0.6000000000000005, + 0.8000000000000025 + ], + "IPIV_out": [ + 2, + 2, + 2 + ], + "info_out": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js new file mode 100644 index 000000000000..f51186d35a36 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js @@ -0,0 +1,269 @@ +/** +* @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 dgetf2 = require( './../lib/dgetf2.js' ); + + +// FIXTURES // + +var SINGULAR_COLUMN_MAJOR = require( './fixtures/column_major_singular.json' ); +var SQUARE_COLUMN_MAJOR = require( './fixtures/column_major_square.json' ); +var SINGULAR_ROW_MAJOR = require( './fixtures/row_major_singular.json' ); +var TALL_COLUMN_MAJOR = require( './fixtures/column_major_tall.json' ); +var WIDE_COLUMN_MAJOR = require( './fixtures/column_major_wide.json' ); +var SQUARE_ROW_MAJOR = require( './fixtures/row_major_square.json' ); +var TALL_ROW_MAJOR = require( './fixtures/row_major_tall.json' ); +var WIDE_ROW_MAJOR = require( './fixtures/row_major_wide.json' ); + + +// FUNCTIONS // + +/** +* Tests whether elements in two float arrays are approximately equal. +* +* @private +* @param {Object} t - test object +* @param {Float64Array} actual - actual array +* @param {Array} expected - expected array +* @param {string} msg - message +*/ +function isApprox( t, actual, expected, msg ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, msg + ' length' ); + for ( i = 0; i < actual.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], msg + ' index ' + i ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = 100.0 * EPS * abs( expected[ i ] ); + if ( tol === 0.0 ) { + tol = 100.0 * EPS; + } + t.ok( delta <= tol, msg + ' index ' + i + '. Expected: ' + expected[ i ] + '. Actual: ' + actual[ i ] + '. Delta: ' + delta + '. Tol: ' + tol + '.' ); + } + } +} + +/** +* Tests whether elements in two integer arrays are exactly equal. +* +* @private +* @param {Object} t - test object +* @param {Int32Array} actual - actual array +* @param {Array} expected - expected array +* @param {string} msg - message +*/ +function checkIPIV( t, actual, expected, msg ) { + var i; + + t.strictEqual( actual.length, expected.length, msg + ' length' ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( actual[ i ], expected[ i ], msg + ' index ' + i ); + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetf2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dgetf2.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var IPIV; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + IPIV = new Int32Array( 2 ); + + 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() { + dgetf2( value, 2, 2, A, 2, IPIV ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid LDA (row-major)', function test( t ) { + var IPIV = new Int32Array( 2 ); + var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + t.throws( badValue, RangeError, 'throws a range error' ); + t.end(); + + function badValue() { + // M = 2, N = 3, row-major requires LDA >= max(1, N) = 3 + dgetf2( 'row-major', 2, 3, A, 2, IPIV ); + } +}); + +tape( 'the function returns 0 when M or N is 0', function test( t ) { + var IPIV = new Int32Array( 0 ); + var info; + var A = new Float64Array( 0 ); + + info = dgetf2( 'row-major', 0, 2, A, 2, IPIV ); + t.strictEqual( info, 0, 'returns 0' ); + + info = dgetf2( 'row-major', 2, 0, A, 1, IPIV ); + t.strictEqual( info, 0, 'returns 0' ); + + info = dgetf2( 'column-major', 0, 2, A, 1, IPIV ); + t.strictEqual( info, 0, 'returns 0' ); + + info = dgetf2( 'column-major', 2, 0, A, 2, IPIV ); + t.strictEqual( info, 0, 'returns 0' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization of a square matrix (row-major)', function test( t ) { + var data = SQUARE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function computes the LU factorization of a square matrix (column-major)', function test( t ) { + var data = SQUARE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function computes the LU factorization of a tall matrix (row-major)', function test( t ) { + var data = TALL_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function computes the LU factorization of a tall matrix (column-major)', function test( t ) { + var data = TALL_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function computes the LU factorization of a wide matrix (row-major)', function test( t ) { + var data = WIDE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function computes the LU factorization of a wide matrix (column-major)', function test( t ) { + var data = WIDE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function detects singularity of a matrix (row-major)', function test( t ) { + var data = SINGULAR_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function detects singularity of a matrix (column-major)', function test( t ) { + var data = SINGULAR_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV.length ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js new file mode 100644 index 000000000000..b7a30cea920e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/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 IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var proxyquire = require( 'proxyquire' ); +var dgetf2 = require( './../lib' ); +var tape = require( 'tape' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetf2, '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 dgetf2.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 dgetf2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgetf2, 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 dgetf2; + var main; + + main = require( './../lib/dgetf2.js' ); + + dgetf2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgetf2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js new file mode 100644 index 000000000000..535483d9609e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js @@ -0,0 +1,253 @@ +/** +* @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'; + +/* eslint-disable max-len, id-length */ + +// 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 dgetf2 = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var NEGATIVE_STRIDES_SQUARE_COLUMN_MAJOR = require( './fixtures/column_major_negative_strides.json' ); +var NEGATIVE_STRIDES_SQUARE_ROW_MAJOR = require( './fixtures/row_major_negative_strides.json' ); +var LARGE_STRIDES_SQUARE_COLUMN_MAJOR = require( './fixtures/column_major_large_strides.json' ); +var MIXED_STRIDES_SQUARE_COLUMN_MAJOR = require( './fixtures/column_major_mixed_strides.json' ); +var LARGE_STRIDES_SQUARE_ROW_MAJOR = require( './fixtures/row_major_large_strides.json' ); +var MIXED_STRIDES_SQUARE_ROW_MAJOR = require( './fixtures/row_major_mixed_strides.json' ); +var OFFSET_SQUARE_COLUMN_MAJOR = require( './fixtures/column_major_offsets.json' ); +var OFFSET_SQUARE_ROW_MAJOR = require( './fixtures/row_major_offsets.json' ); +var SQUARE_COLUMN_MAJOR = require( './fixtures/column_major_square.json' ); +var SQUARE_ROW_MAJOR = require( './fixtures/row_major_square.json' ); + + +// FUNCTIONS // + +/** +* Tests whether elements in two float arrays are approximately equal. +* +* @private +* @param {Object} t - test object +* @param {Float64Array} actual - actual array +* @param {Array} expected - expected array +* @param {string} msg - message +*/ +function isApprox( t, actual, expected, msg ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, msg + ' length' ); + for ( i = 0; i < actual.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], msg + ' index ' + i ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = 100.0 * EPS * abs( expected[ i ] ); + if ( tol === 0.0 ) { + tol = 100.0 * EPS; + } + t.ok( delta <= tol, msg + ' index ' + i + '. Expected: ' + expected[ i ] + '. Actual: ' + actual[ i ] + '. Delta: ' + delta + '. Tol: ' + tol + '.' ); + } + } +} + +/** +* Tests whether elements in two integer arrays are exactly equal. +* +* @private +* @param {Object} t - test object +* @param {Int32Array} actual - actual array +* @param {Array} expected - expected array +* @param {string} msg - message +*/ +function checkIPIV( t, actual, expected, msg ) { + var i; + + t.strictEqual( actual.length, expected.length, msg + ' length' ); + for ( i = 0; i < actual.length; i++ ) { + t.strictEqual( actual[ i ], expected[ i ], msg + ' index ' + i ); + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetf2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dgetf2.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns 0 when M or N is 0', function test( t ) { + var IPIV = new Int32Array( 0 ); + var info; + var A = new Float64Array( 0 ); + + info = dgetf2( 0, 2, A, 1, 1, 0, IPIV, 1, 0 ); + t.strictEqual( info, 0, 'returns 0' ); + + info = dgetf2( 2, 0, A, 1, 1, 0, IPIV, 1, 0 ); + t.strictEqual( info, 0, 'returns 0' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization (row-major)', function test( t ) { + var data = SQUARE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function computes the LU factorization (column-major)', function test( t ) { + var data = SQUARE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports offsets (row-major)', function test( t ) { + var data = OFFSET_SQUARE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports offsets (column-major)', function test( t ) { + var data = OFFSET_SQUARE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports negative strides (row-major)', function test( t ) { + var data = NEGATIVE_STRIDES_SQUARE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports negative strides (column-major)', function test( t ) { + var data = NEGATIVE_STRIDES_SQUARE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports mixed strides (row-major)', function test( t ) { + var data = MIXED_STRIDES_SQUARE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports mixed strides (column-major)', function test( t ) { + var data = MIXED_STRIDES_SQUARE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports large strides (row-major)', function test( t ) { + var data = LARGE_STRIDES_SQUARE_ROW_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + +tape( 'the function supports large strides (column-major)', function test( t ) { + var data = LARGE_STRIDES_SQUARE_COLUMN_MAJOR; + var IPIV = new Int32Array( data.IPIV ); + var info; + var A = new Float64Array( data.A ); + + info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( info, data.info_out, 'returns expected info' ); + isApprox( t, A, data.A_out, 'returns expected matrix' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.end(); +}); + From bc237dd4489fd7b086e9720e5b856d3f483fee1c Mon Sep 17 00:00:00 2001 From: iampratik13 Date: Mon, 15 Jun 2026 15:53:47 +0530 Subject: [PATCH 2/4] fix: lint error --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js index b7a30cea920e..68cf85899bb8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.js @@ -20,10 +20,10 @@ // MODULES // -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); var dgetf2 = require( './../lib' ); -var tape = require( 'tape' ); // VARIABLES // From 92d38c7b4fcfc1ae0bbafb061d86a480da95fa7e Mon Sep 17 00:00:00 2001 From: iampratik13 Date: Mon, 15 Jun 2026 16:11:33 +0530 Subject: [PATCH 3/4] fix: lint error --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js index 535483d9609e..4fa721eef2e3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js @@ -250,4 +250,3 @@ tape( 'the function supports large strides (column-major)', function test( t ) { checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); t.end(); }); - From f981bb25ec790d12e5478727a0a6320b90a93bd9 Mon Sep 17 00:00:00 2001 From: iampratik13 Date: Fri, 19 Jun 2026 00:48:05 +0530 Subject: [PATCH 4/4] chore: suggested changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - 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/dgetf2/README.md | 35 +++++++- .../@stdlib/lapack/base/dgetf2/lib/base.js | 45 ++++++---- .../@stdlib/lapack/base/dgetf2/lib/dgetf2.js | 7 +- .../lapack/base/dgetf2/test/test.dgetf2.js | 63 +++++++------- .../lapack/base/dgetf2/test/test.ndarray.js | 86 ++++++++----------- 5 files changed, 135 insertions(+), 101 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md index 76bec91d272c..2fac9dd5fced 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/README.md @@ -70,6 +70,24 @@ The function has the following parameters: 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' ); + +// Initial arrays: +var A0 = new Float64Array( [ 0.0, 2.0, 1.0, 4.0, 6.0 ] ); +var IPIV0 = new Int32Array( [ 0, 0, 0 ] ); + +// Create offset views: +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var IPIV1 = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var info = dgetf2( 'row-major', 2, 2, A1, 2, IPIV1 ); +// returns 0 +``` + #### dgetf2.ndarray( M, N, A, sa1, sa2, oa, IPIV, si, oi ) Computes an `LU` factorization of a general $M$-by-$N$ matrix $A$ using partial pivoting with row interchanges and alternative indexing semantics. @@ -93,6 +111,21 @@ The function has the following additional parameters: - **si**: stride length for `IPIV`. - **oi**: starting index of `IPIV`. +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 A = new Float64Array( [ 0.0, 2.0, 1.0, 4.0, 6.0 ] ); +var IPIV = new Int32Array( 3 ); + +var info = dgetf2.ndarray( 2, 2, A, 2, 1, 1, IPIV, 1, 1 ); +// returns 0 +``` + @@ -106,7 +139,7 @@ The function has the following additional parameters: - Both functions return a status code indicating success or failure. The status code indicates the following conditions: - `0`: factorization was successful. - - `>0`: $U(k, k)$ is exactly zero (where $k$ equals the status code value). The factorization has been completed, but the factor $U$ is exactly singular, and division by zero will occur if it is used to solve a system of equations. + - `>0`: $U(k, k)$ is exactly zero (where $k$ equals the status code value minus one when using zero-based indexing). The factorization has been completed, but the factor $U$ is exactly singular, and division by zero will occur if it is used to solve a system of equations. - `dgetf2()` corresponds to the [LAPACK][LAPACK] routine [`dgetf2`][lapack-dgetf2]. diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js index dcdc2c0d6640..7ff55f5bf226 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/base.js @@ -58,10 +58,12 @@ function dgetf2( M, N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetI var val; var jp; var ip; + var ia; + var ij; + var ic; var r; var c; var j; - var o; if ( M === 0 || N === 0 ) { return 0; @@ -71,45 +73,52 @@ function dgetf2( M, N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetI info = 0; for ( j = 0; j < minMN; j++ ) { + ij = offsetA + ( j * strideA1 ) + ( j * strideA2 ); + // Find pivot (maximum absolute value in column j from row j to M-1): maxVal = -1.0; jp = j; + ia = ij; for ( r = j; r < M; r++ ) { - val = abs( A[ offsetA + ( r * strideA1 ) + ( j * strideA2 ) ] ); + val = abs( A[ ia ] ); if ( val > maxVal ) { maxVal = val; jp = r; } + ia += strideA1; } - // Store pivot row index in IPIV (using custom indexing/offset/stride for IPIV): + // Store pivot row index in IPIV: ip = offsetIPIV + ( j * strideIPIV ); IPIV[ ip ] = jp; // Check for singularity: - temp = A[ offsetA + ( jp * strideA1 ) + ( j * strideA2 ) ]; - if ( temp !== 0.0 ) { + if ( A[ offsetA + ( jp * strideA1 ) + ( j * strideA2 ) ] !== 0.0 ) { // Swap row j and row jp if they are not the same row: if ( jp !== j ) { + ia = offsetA + ( j * strideA1 ); + ic = offsetA + ( jp * strideA1 ); for ( c = 0; c < N; c++ ) { - o = c * strideA2; - val = A[ offsetA + ( j * strideA1 ) + o ]; - A[ offsetA + ( j * strideA1 ) + o ] = - A[ offsetA + ( jp * strideA1 ) + o ]; - A[ offsetA + ( jp * strideA1 ) + o ] = val; + val = A[ ia ]; + A[ ia ] = A[ ic ]; + A[ ic ] = val; + ia += strideA2; + ic += strideA2; } } // Scale elements below the diagonal in column j: if ( j < M - 1 ) { - // Divide A[r, j] by A[j, j] for r = j+1 to M-1 - temp = A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ]; + temp = A[ ij ]; + ia = ij + strideA1; for ( r = j + 1; r < M; r++ ) { - A[ offsetA + ( r * strideA1 ) + ( j * strideA2 ) ] /= temp; + A[ ia ] /= temp; + ia += strideA1; } } } else if ( info === 0 ) { - info = j + 1; // 1-based index + // Status code is 1-based: a value of k means U(k-1,k-1) is zero in 0-based indexing... + info = j + 1; } // Update trailing submatrix (rows j+1 to M-1, columns j+1 to N-1): @@ -117,10 +126,12 @@ function dgetf2( M, N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetI for ( c = j + 1; c < N; c++ ) { temp = A[ offsetA + ( j * strideA1 ) + ( c * strideA2 ) ]; if ( temp !== 0.0 ) { + ia = offsetA + ( ( j + 1 ) * strideA1 ) + ( c * strideA2 ); + ic = offsetA + ( ( j + 1 ) * strideA1 ) + ( j * strideA2 ); for ( r = j + 1; r < M; r++ ) { - A[ offsetA + ( r * strideA1 ) + ( c * strideA2 ) ] -= - A[ offsetA + ( r * strideA1 ) + ( j * strideA2 ) ] * - temp; + A[ ia ] -= A[ ic ] * temp; + ia += strideA1; + ic += strideA1; } } } diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js index c6625f15060a..a940f58f59bf 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/lib/dgetf2.js @@ -21,7 +21,6 @@ // MODULES // var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); -var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var max = require( '@stdlib/math/base/special/max' ); var format = require( '@stdlib/string/format' ); @@ -61,13 +60,13 @@ function dgetf2( order, M, N, A, LDA, IPIV ) { 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. Fifth 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' + if ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } sa1 = LDA; sa2 = 1; } diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js index f51186d35a36..b4bd2975f193 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.dgetf2.js @@ -132,8 +132,11 @@ tape( 'the function throws an error if provided an invalid first argument', func }); tape( 'the function throws an error if provided an invalid LDA (row-major)', function test( t ) { - var IPIV = new Int32Array( 2 ); - var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + var IPIV; + var A; + + IPIV = new Int32Array( 2 ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); t.throws( badValue, RangeError, 'throws a range error' ); t.end(); @@ -150,16 +153,16 @@ tape( 'the function returns 0 when M or N is 0', function test( t ) { var A = new Float64Array( 0 ); info = dgetf2( 'row-major', 0, 2, A, 2, IPIV ); - t.strictEqual( info, 0, 'returns 0' ); + t.strictEqual( info, 0, 'returns expected value' ); info = dgetf2( 'row-major', 2, 0, A, 1, IPIV ); - t.strictEqual( info, 0, 'returns 0' ); + t.strictEqual( info, 0, 'returns expected value' ); info = dgetf2( 'column-major', 0, 2, A, 1, IPIV ); - t.strictEqual( info, 0, 'returns 0' ); + t.strictEqual( info, 0, 'returns expected value' ); info = dgetf2( 'column-major', 2, 0, A, 2, IPIV ); - t.strictEqual( info, 0, 'returns 0' ); + t.strictEqual( info, 0, 'returns expected value' ); t.end(); }); @@ -171,9 +174,9 @@ tape( 'the function computes the LU factorization of a square matrix (row-major) var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -184,9 +187,9 @@ tape( 'the function computes the LU factorization of a square matrix (column-maj var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -197,9 +200,9 @@ tape( 'the function computes the LU factorization of a tall matrix (row-major)', var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -210,9 +213,9 @@ tape( 'the function computes the LU factorization of a tall matrix (column-major var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -223,9 +226,9 @@ tape( 'the function computes the LU factorization of a wide matrix (row-major)', var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -236,9 +239,9 @@ tape( 'the function computes the LU factorization of a wide matrix (column-major var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -249,9 +252,9 @@ tape( 'the function detects singularity of a matrix (row-major)', function test( var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -262,8 +265,8 @@ tape( 'the function detects singularity of a matrix (column-major)', function te var A = new Float64Array( data.A ); info = dgetf2( data.order, data.M, data.N, A, data.LDA, IPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js index 4fa721eef2e3..fba1d8aca9aa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dgetf2/test/test.ndarray.js @@ -25,8 +25,7 @@ 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var dgetf2 = require( './../lib/ndarray.js' ); @@ -56,22 +55,11 @@ var SQUARE_ROW_MAJOR = require( './fixtures/row_major_square.json' ); * @param {string} msg - message */ function isApprox( t, actual, expected, msg ) { - var delta; - var tol; var i; - t.strictEqual( actual.length, expected.length, msg + ' length' ); + t.strictEqual( actual.length, expected.length, msg ); for ( i = 0; i < actual.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], msg + ' index ' + i ); - } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = 100.0 * EPS * abs( expected[ i ] ); - if ( tol === 0.0 ) { - tol = 100.0 * EPS; - } - t.ok( delta <= tol, msg + ' index ' + i + '. Expected: ' + expected[ i ] + '. Actual: ' + actual[ i ] + '. Delta: ' + delta + '. Tol: ' + tol + '.' ); - } + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], 100.0 ), true, msg ); } } @@ -87,9 +75,9 @@ function isApprox( t, actual, expected, msg ) { function checkIPIV( t, actual, expected, msg ) { var i; - t.strictEqual( actual.length, expected.length, msg + ' length' ); + t.strictEqual( actual.length, expected.length, msg ); for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( actual[ i ], expected[ i ], msg + ' index ' + i ); + t.strictEqual( actual[ i ], expected[ i ], msg ); } } @@ -113,10 +101,10 @@ tape( 'the function returns 0 when M or N is 0', function test( t ) { var A = new Float64Array( 0 ); info = dgetf2( 0, 2, A, 1, 1, 0, IPIV, 1, 0 ); - t.strictEqual( info, 0, 'returns 0' ); + t.strictEqual( info, 0, 'returns expected value' ); info = dgetf2( 2, 0, A, 1, 1, 0, IPIV, 1, 0 ); - t.strictEqual( info, 0, 'returns 0' ); + t.strictEqual( info, 0, 'returns expected value' ); t.end(); }); @@ -128,9 +116,9 @@ tape( 'the function computes the LU factorization (row-major)', function test( t var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -141,9 +129,9 @@ tape( 'the function computes the LU factorization (column-major)', function test var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -154,9 +142,9 @@ tape( 'the function supports offsets (row-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -167,9 +155,9 @@ tape( 'the function supports offsets (column-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -180,9 +168,9 @@ tape( 'the function supports negative strides (row-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -193,9 +181,9 @@ tape( 'the function supports negative strides (column-major)', function test( t var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -206,9 +194,9 @@ tape( 'the function supports mixed strides (row-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -219,9 +207,9 @@ tape( 'the function supports mixed strides (column-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -232,9 +220,9 @@ tape( 'the function supports large strides (row-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); }); @@ -245,8 +233,8 @@ tape( 'the function supports large strides (column-major)', function test( t ) { var A = new Float64Array( data.A ); info = dgetf2( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV ); - t.strictEqual( info, data.info_out, 'returns expected info' ); - isApprox( t, A, data.A_out, 'returns expected matrix' ); - checkIPIV( t, IPIV, data.IPIV_out, 'returns expected pivot vector' ); + t.strictEqual( info, data.info_out, 'returns expected value' ); + isApprox( t, A, data.A_out, 'returns expected value' ); + checkIPIV( t, IPIV, data.IPIV_out, 'returns expected value' ); t.end(); });