diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md new file mode 100644 index 000000000000..6c8b42c209b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/README.md @@ -0,0 +1,406 @@ + + +# dgetc2 + +> LAPACK routine to compute the LU factorization with complete pivoting of the general N-by-N matrix `A`. + +
+ +The `dgetc2` routine computes an LU factorization of with complete pivoting a real N-by-N matrix `A`. The factorization has the form: + + + +```math +A = P L U Q +``` + + + +where `P` and `Q` are permutation matrices, `L` is lower triangular with unit diagonal elements and `U` is upper triangular. + +For a 5-by-5 matrix `A`, elements are stored in three arrays: + + + +```math +A = \left[ +\begin{array}{rrrrr} + a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} \\ + a_{2,1} & a_{2,2} & a_{2,3} & a_{2,4} & a_{2,5} \\ + a_{3,1} & a_{3,2} & a_{3,3} & a_{3,4} & a_{3,5} \\ + a_{4,1} & a_{4,2} & a_{4,3} & a_{4,4} & a_{4,5} \\ + a_{5,1} & a_{5,2} & a_{5,3} & a_{5,4} & a_{5,5} + \end{array} +\right] +``` + + + +After factorization, the elements of `L` and `U` are used to update `A`, where: + +- The unit diagonal elements of `L` are not stored. +- If $U_{kk}$ appears to be less than `SMIN`, $U_{kk}$ is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + +The resulting `L` and `U` matrices have the following structure: + + + +```math +L = \left[ +\begin{array}{rrrrr} + 0 & 0 & 0 & 0 & 0 \\ + l_{2,1} & 0 & 0 & 0 & 0 \\ + l_{3,1} & l_{3,2} & 0 & 0 & 0 \\ + l_{4,1} & l_{4,2} & l_{4,3} & 0 & 0 \\ + l_{5,1} & l_{5,2} & l_{5,3} & l_{5,4} & 0 + \end{array} +\right] +``` + + + + + +```math +U = \left[ + \begin{array}{rrrrr} + u_{1,1} & u_{1,2} & u_{1,3} & u_{1,4} & u_{1,5} \\ + 0 & u_{2,2} & u_{2,3} & u_{2,4} & u_{2,5} \\ + 0 & 0 & u_{3,3} & u_{3,4} & u_{3,5} \\ + 0 & 0 & 0 & u_{4,4} & u_{4,5} \\ + 0 & 0 & 0 & 0 & u_{5,5} + \end{array} +\right] +``` + + + +where the values of `L` and `U` are stored in A, as follows: + +```math +A_{out} = L + U +``` + +
+ + + + +
+ +## Usage + +```javascript +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +``` + +#### dgetc2( order, N, A, LDA, IPIV, JPIV ) + +Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV = new Int32Array( 3 ); +var JPIV = new Int32Array( 3 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +// A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV = [ 3, 3, 3 ] +// IPIV = [ 3, 3, 3 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **N**: number of columns in matrix `A`. +- **A**: input matrix (overwritten by `L` and `U`) stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-int32array]. +- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-int32array]. + +The function returns the status code `info`. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV0 = new Int32Array( 4 ); +var JPIV0 = new Int32Array( 4 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +// Create offset views... +var A = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var JPIV = new Int32Array( JPIV0.buffer, JPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +// A0 => [ 0, 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV0 = [ 0, 3, 3, 3 ] +// IPIV0 = [ 0, 3, 3, 3 ] +``` + + + +#### dgetc2.ndarray( N, A, sa1, sa2, oa, IPIV, si, oi, JPIV, sj, oj ) + +Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV = new Int32Array( 3 ); +var JPIV = new Int32Array( 3 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +// A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV = [ 3, 3, 3 ] +// IPIV = [ 3, 3, 3 ] +``` + +The function has the following parameters: + +- **N**: number of columns in matrix `A`. +- **A**: input matrix (overwritten by `L` and `U`) stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: index offset for `A`. +- **IPIV**: vector of pivot indices for rows as a [`Int32Array`][mdn-int32array]. +- **si**: stride length for `IPIV`. +- **oi**: index offset for `IPIV`. +- **JPIV**: vector of pivot indices for columns as a [`Int32Array`][mdn-int32array]. +- **sj**: stride length for `JPIV`. +- **oj**: index offset for `JPIV`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +// Initial arrays... +var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +var IPIV = new Int32Array( 4 ); +var JPIV = new Int32Array( 4 ); + +/* + A = [ + [ 1.0, 4.0, 7.0 ], + [ 2.0, 5.0, 8.0 ], + [ 3.0, 6.0, 10.0 ] + ] +*/ + +dgetc2.ndarray( 3, A, 1, 3, 1, IPIV, 1, 1, JPIV, 1, 1 ); +// A => [ 0, 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +// JPIV = [ 0, 3, 3, 3 ] +// IPIV = [ 0, 3, 3, 3 ] +``` + +
+ + + +
+ +## Notes + +- `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization `A = P*L*U*Q`, the unit diagonal elements of L are not stored. +- If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +- `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +- `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +- Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +- `dgetc2()` corresponds to the [LAPACK][LAPACK] function [`dgetc2`][lapack-dgetc2]. + +
+ + + +
+ +## Examples + + + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + +var N = 3; +var LDA = 3; + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + +console.log( 'The n-by-n matrix A to be factored:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); + +var IPIV = new Int32Array( N ); +var JPIV = new Int32Array( N ); + +// Perform the `A = LU` factorization: +var info = dgetc2( 'column-major', N, A, LDA, IPIV, JPIV ); + +console.log( 'The factors L and U from the factorization:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js new file mode 100644 index 000000000000..81008acfb3d3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.js @@ -0,0 +1,124 @@ +/** +* @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 dgetc2 = require( './../lib/dgetc2.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - matrix order (N-by-N) +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var IPIV; + var JPIV; + var opts; + var A; + + opts = { + 'dtype': 'float64' + }; + + // Random input matrix and auxiliary arrays: + A = uniform( N*N, -1.0, 1.0, opts ); + IPIV = new Int32Array( N ); + JPIV = new Int32Array( N ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dgetc2( order, N, A, N, IPIV, JPIV ); + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s:order=%s,size=%d', pkg, ord, (N*N) ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..8e1ffbdf79f0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/benchmark/benchmark.ndarray.js @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgetc2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - matrix order (N-by-N) +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var IPIV; + var JPIV; + var sa1; + var sa2; + var A; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { + sa1 = N; + sa2 = 1; + } + + A = uniform( N*N, -1.0, 1.0, { + 'dtype': 'float64' + }); + IPIV = new Int32Array( N ); + JPIV = new Int32Array( N ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dgetc2( N, A, sa1, sa2, 0, IPIV, 1, 0, JPIV, 1, 0 ); + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( A[ i%A.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s:ndarray:order=%s,size=%d', pkg, ord, (N*N) ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt new file mode 100644 index 000000000000..ec9a3e902306 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/repl.txt @@ -0,0 +1,115 @@ +{{alias}}( order, N, A, LDA, IPIV, JPIV ) + Computes the LU factorization with complete pivoting of the general + n-by-n matrix `A`. + + The function overwrites the input matrix A with the factors L and U + from the factorization A = P*L*U*Q; the unit diagonal elements of L + are not stored. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + N: integer + Number of columns in matrix A. + + A: Float64Array + Input matrix (overwritten with `L` and `U` on output). + + LDA: integer + Stride of the first dimension of A (a.k.a., leading dimension of the + matrix A) `LDA` >= max(1,N). + + IPIV: Int32Array + Vector of `N` pivot indices of rows. + + JPIV: Int32Array + Vector of `N` pivot indices of rows. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}([ 1,2,3,4,5,6,7,8,10 ]); + > var IPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > var JPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > {{alias}}( 'column-major', 3, A, 3, IPIV, JPIV ) + 0 + > A + [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + > IPIV + [ 3, 3, 3 ] + > JPIV + [ 3, 3, 3 ] + + +{{alias}}.ndarray( N, A, sa1, sa2, oa, IPIV, si, oi, JPIV, sj, oj ) + Computes the LU factorization with complete pivoting of the general + n-by-n matrix `A` using alternating indexing semantics. + + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of columns in matrix A. + + A: Float64Array + Input matrix (overwritten with `L` and `U` on output). + + sa1: integer + Stride of the first dimension of A. + + sa2: integer + Stride of the second dimension of A. + + oa: integer + Index offset for A. + + IPIV: Int32Array + Vector of `N` pivot indices of rows. + + si: integer + Stride length for IPIV. + + oi: integer + Index offset for IPIV. + + JPIV: Int32Array + Vector of `N` pivot indices of columns. + + sj: integer + Stride length for JPIV. + + oj: integer + Index offset for JPIV. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}([ 1,2,3,4,5,6,7,8,10 ]); + > var IPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > var JPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > {{alias}}.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ) + 0 + > A + [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + > IPIV + [ 3, 3, 3 ] + > JPIV + [ 3, 3, 3 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts new file mode 100644 index 000000000000..405be2bcd43b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/index.d.ts @@ -0,0 +1,157 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `dgetc2`. +*/ +interface Routine { + /** + * Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. + * + * ## Notes + * + * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q; the unit diagonal elements of L are not stored. + * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). + * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. + * + * @param order - storage layout + * @param N - number of columns in `A` + * @param A - input matrix (overwritten with `L` and `U` on output) + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) `LDA` >= max(1,N). + * @param IPIV - vector of `N` pivot indices of rows + * @param JPIV - vector of `N` pivot indices of columns + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + * var IPIV = new Int32Array( 3 ); + * var JPIV = new Int32Array( 3 ); + * + * dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); + * // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + * // JPIV = [ 3, 3, 3 ] + * // IPIV = [ 3, 3, 3 ] + */ + ( order: Layout, N: number, A: Float64Array, LDA: number, IPIV: Int32Array, JPIV: Int32Array ): number; + + /** + * Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternating indexing semantics. + * + * ## Notes + * + * - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. + * - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. + * - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). + * - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). + * - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. + * + * @param N - number of columns in `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - index offset for `A` + * @param IPIV - vector of pivot indices of rows + * @param strideIPIV - stride length for `IPIV` + * @param offsetIPIV - index offset for `IPIV` + * @param JPIV - vector of pivot indices of rows + * @param strideJPIV - stride length for `JPIV` + * @param offsetJPIV - index offset for `JPIV` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + * var IPIV = new Int32Array( 3 ); + * var JPIV = new Int32Array( 3 ); + * + * dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); + * // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] + * // JPIV = [ 3, 3, 3 ] + * // IPIV = [ 3, 3, 3 ] + */ + ndarray( N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number, JPIV: Int32Array, strideJPIV: number, offsetJPIV: number ): number; // eslint-disable-line max-len +} + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternating indexing semantics. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = P*L*U*Q; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @param order - storage layout +* @param N - number of columns in `A` +* @param A - input matrix (overwritten with `Q` on output) +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) `LDA` >= max(1,N). +* @param IPIV - vector of `N` pivot indices of rows +* @param JPIV - vector of `N` pivot indices of columns +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +declare var dgetc2: Routine; + + +// EXPORTS // + +export = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts new file mode 100644 index 000000000000..4ccfee59930a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/docs/types/test.ts @@ -0,0 +1,348 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dgetc2 = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 5, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( true, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( false, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( null, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( void 0, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( [], 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( {}, 3, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( ( x: number ): number => x, 3, A, 3, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', '3', A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', true, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', false, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', null, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', void 0, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', [], A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', {}, A, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', ( x: number ): number => x, A, 3, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, '5', 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, 5, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, true, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, false, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, null, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, void 0, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, [], 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, {}, 3, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, ( x: number ): number => x, 3, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, '3', IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, true, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, false, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, null, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, void 0, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, [], IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, {}, IPIV, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, ( x: number ): number => x, IPIV, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const JPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, 3, '5', JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, 5, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, true, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, false, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, null, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, void 0, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, [], JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, {}, JPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, ( x: number ): number => x, JPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided an sixth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + + dgetc2( 'column-major', 3, A, 3, IPIV, '5' ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, 5 ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, true ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, false ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, null ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, void 0 ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, [] ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, {} ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2(); // $ExpectError + dgetc2( 'column-major' ); // $ExpectError + dgetc2( 'column-major', 3 ); // $ExpectError + dgetc2( 'column-major', 3, A ); // $ExpectError + dgetc2( 'column-major', 3, A, 3 ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV ); // $ExpectError + dgetc2( 'column-major', 3, A, 3, IPIV, JPIV, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( '3', A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( true, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( false, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( null, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( void 0, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( [], A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( {}, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( ( x: number ): number => x, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, '5', 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, 5, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, true, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, false, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, null, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, void 0, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, [], 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, {}, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, ( x: number ): number => x, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, '1', 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, true, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, false, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, null, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, void 0, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, [], 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, {}, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, ( x: number ): number => x, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, '3', 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, true, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, false, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, null, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, void 0, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, [], 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, {}, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, ( x: number ): number => x, 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, '0', IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, true, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, false, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, null, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, void 0, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, [], IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, {}, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, ( x: number ): number => x, IPIV, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an sixth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, '5', 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, 5, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, true, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, false, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, null, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, void 0, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, [], 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, {}, 1, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, ( x: number ): number => x, 1, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, '1', 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, true, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, false, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, null, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, void 0, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, [], 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, {}, 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, ( x: number ): number => x, 0, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, '0', JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, true, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, false, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, null, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, void 0, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, [], JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, {}, JPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, ( x: number ): number => x, JPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an ninth argument which is not an Int32Array... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, '5', 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, 5, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, true, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, false, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, null, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, void 0, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, [], 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, {}, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, '1', 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, true, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, false, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, null, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, void 0, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, [], 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, {}, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eleventh argument which is not a number... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, '0' ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, true ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, false ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, null ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, void 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, [] ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, {} ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( 9 ); + const IPIV = new Int32Array( 3 ); + const JPIV = new Int32Array( 3 ); + + dgetc2.ndarray(); // $ExpectError + dgetc2.ndarray( 3 ); // $ExpectError + dgetc2.ndarray( 3, A ); // $ExpectError + dgetc2.ndarray( 3, A, 1 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1 ); // $ExpectError + dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js new file mode 100644 index 000000000000..aa2abe3dd986 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgetc2 = require( './../lib' ); + +var N = 3; +var LDA = 3; + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + +console.log( 'The n-by-n matrix A to be factored:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); + +var IPIV = new Int32Array( N ); +var JPIV = new Int32Array( N ); + +dgetc2( 'column-major', N, A, LDA, IPIV, JPIV ); + +console.log( 'The factors L and U from the factorization:' ); +console.log( ndarray2array( A, [ LDA, N ], [ 1, N ], 0, 'column-major' ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js new file mode 100644 index 000000000000..295d9569b78b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/base.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +var dswap = require( '@stdlib/blas/base/dswap' ); +var dger = require( '@stdlib/blas/base/dger' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var max = require( '@stdlib/math/base/special/max' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @private +* @param {PositiveInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @param {Int32Array} IPIV - vector of pivot indices for rows +* @param {integer} strideIPIV - stride length for `IPIV` +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @param {Int32Array} JPIV - vector of pivot indices for columns +* @param {integer} strideJPIV - stride length for `JPIV` +* @param {NonNegativeInteger} offsetJPIV - index offset for `JPIV` +* @returns {integer} - status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ) { // eslint-disable-line max-params, max-len + var smlnum; + var info; + var smin; + var xmax; + var eps; + var ipv; + var jpv; + var sA1; + var sA2; + var ip; + var jp; + var oA; + var i; + var j; + + sA1 = strideA1; + sA2 = strideA2; + oA = offsetA; + + info = 0; + + // Quick return if possible + if ( N === 0 ) { + return info; + } + + // Set constants to control overflow + eps = dlamch( 'P' ); + smlnum = dlamch( 'S' ) / eps; + + // Handle the case N=1 by itself + if ( N === 1 ) { + IPIV[ offsetIPIV ] = 1; + JPIV[ offsetJPIV ] = 1; + if ( abs( A[ oA ] )< smlnum ) { + info = 1; + A[ oA ] = smlnum; + } + return info; + } + + // Factorize A using complete pivoting. + // Set pivots less than SMIN to SMIN. + for ( i = 0; i < N - 1; i++ ) { + // Find max element in matrix A + xmax = 0.0; + if ( isRowMajor( [ sA1, sA2 ] ) ) { + for ( ip = i; ip < N; ip++ ) { + for ( jp = i; jp < N; jp++ ) { + if ( abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ) >= xmax ) { + xmax = abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ); + ipv = ip; + jpv = jp; + } + } + } + } else { // column-major + for ( jp = i; jp < N; jp++ ) { + for ( ip = i; ip < N; ip++ ) { + if ( abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ]) >= xmax ) { + xmax = abs( A[ oA + ( sA1*ip ) + ( sA2*jp ) ] ); + ipv = ip; + jpv = jp; + } + } + } + } + + if ( i === 0 ) { + smin = max( eps*xmax, smlnum ); + } + + // Swap rows + if ( ipv !== i ) { + dswap.ndarray( N, A, sA2, oA + ( sA1*ipv ), A, sA2, oA+( sA1*i ) ); + } + IPIV[ offsetIPIV + ( i*strideIPIV ) ] = ipv+1; + + // Swap columns + if ( jpv !== i ) { + dswap.ndarray( N, A, sA1, oA + ( sA2*jpv ), A, sA1, oA+( sA2*i ) ); + } + JPIV[ offsetJPIV + ( i*strideJPIV ) ] = jpv+1; + + // Check for singularity + for ( j = i+1; j < N; j++ ) { + A[ oA + ( j*sA1 ) + ( i*sA2 ) ] /= A[ oA + ( i*( sA1 + sA2 ) ) ]; + } + + dger.ndarray( N - i-1, N - i-1, -1, A, sA1, oA + ( ( i + 1 )*sA1 ) + ( i*sA2 ), A, sA2, oA + ( i*sA1 ) + ( ( i + 1 )*sA2 ), A, sA1, sA2, oA + ( ( i + 1 )*( sA1 + sA2 ) ) ); // eslint-disable-line max-len + } + + if ( abs( A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] ) < smin ) { + info = N; + A[ ( oA ) + ( ( N - 1 )*( sA1 + sA2 ) ) ] = smin; + } + + IPIV[ offsetIPIV + ( ( N - 1 )*strideIPIV ) ] = N; + JPIV[ offsetJPIV + ( ( N - 1 )*strideJPIV ) ] = N; + + return info; +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js new file mode 100644 index 000000000000..ebc066e44a1f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/dgetc2.js @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A`. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Int32Array} IPIV - vector of pivot indices for rows +* @param {Int32Array} JPIV - vector of pivot indices for columns +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,M) +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +function dgetc2( order, N, A, LDA, IPIV, JPIV ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( N, A, sa1, sa2, 0, IPIV, 1, 0, JPIV, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js new file mode 100644 index 000000000000..2fc3a9ba2f89 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/index.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute the LU factorization with complete pivoting of the general n-by-n matrix `A`. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization A = `P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @module @stdlib/lapack/base/dgetc2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 'column-major', 3, A, 3, IPIV, JPIV ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgetc2 = require( '@stdlib/lapack/base/dgetc2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2.ndarray( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dgetc2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgetc2 = main; +} else { + dgetc2 = tmp; +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/main.js new file mode 100644 index 000000000000..c11e9f28e28e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dgetc2 = require( './dgetc2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgetc2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js new file mode 100644 index 000000000000..3dcb61185689 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/lib/ndarray.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the LU factorization with complete pivoting of the general n-by-n matrix `A` using alternating indexing semantics. +* +* ## Notes +* +* - `A` should have dimension (LDA, N) and is overwritten with the factors L and U from the factorization `A = P*L*U*Q`; the unit diagonal elements of L are not stored. +* - If U(k, k) appears to be less than `SMIN`, U(k, k) is given the value of `SMIN`, i.e., giving a nonsingular perturbed system. +* - `IPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, row i of the matrix has been interchanged with row IPIV(i). +* - `JPIV` should have `N` elements and is overwritten with the pivot indices; for 1 <= i <= N, column i of the matrix has been interchanged with column JPIV(i). +* - Returns 0 on successful exit and if returns `k`, U(k, k) is likely to produce overflow if we try to solve for x in Ax = b. So U is perturbed to avoid the overflow. +* +* @param {PositiveInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @param {Int32Array} IPIV - the pivot indices for rows +* @param {integer} strideIPIV - stride length for `IPIV` +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @param {Int32Array} JPIV - the pivot indices for columns +* @param {integer} strideJPIV - stride length for `JPIV` +* @param {NonNegativeInteger} offsetJPIV - index offset for `JPIV` +* @returns {integer} - status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); +* var IPIV = new Int32Array( 3 ); +* var JPIV = new Int32Array( 3 ); +* +* dgetc2( 3, A, 1, 3, 0, IPIV, 1, 0, JPIV, 1, 0 ); +* // A => [ 10, 0.7, 0.8, 3, ~-1.1, ~0.36, 6, ~-0.2, ~0.27 ] +* // JPIV = [ 3, 3, 3 ] +* // IPIV = [ 3, 3, 3 ] +*/ +function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ) { // eslint-disable-line max-len, max-params + return base( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV, JPIV, strideJPIV, offsetJPIV ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgetc2; diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/package.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/package.json new file mode 100644 index 000000000000..b15e4ec3029c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/lapack/base/dgetc2", + "version": "0.0.0", + "description": "LAPACK routine to compute the LU factorization with complete pivoting of the general n-by-n matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "dgetc2", + "orthogonal", + "qr", + "decomposition", + "householder", + "reflectors", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json new file mode 100644 index 000000000000..d82deec5d31b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1.0, + 4.0, + 7.0 + ], + [ + 2.0, + 5.0, + 8.0 + ], + [ + 3.0, + 6.0, + 10.0 + ] + ], + "A": [ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 10.0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10.0, + 3.0, + 6.0 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 10.0, + 0.7, + 0.8, + 3.0, + -1.0999999999999996, + 0.3636363636363641, + 6.0, + -0.1999999999999993, + 0.2727272727272718 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json new file mode 100644 index 000000000000..cc4ee3637d46 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/column_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + "A": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] + ], + "A_out": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json new file mode 100644 index 000000000000..38a9ae69e57f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major.json @@ -0,0 +1,103 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 10, + 9999 + ], + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "IPIV": [ + 3, + 0, + 3, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 3, + 0, + 3, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 10, + 9999, + 0.7, + 9999, + 0.8, + 9999, + 3, + 9999, + -1.0999999999999996, + 9999, + 0.3636363636363641, + 9999, + 6, + 9999, + -0.1999999999999993, + 9999, + 0.2727272727272718, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json new file mode 100644 index 000000000000..562cc4590c98 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/column_major_i_gt_0.json @@ -0,0 +1,103 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "IPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 2.220446049250313e-16, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json new file mode 100644 index 000000000000..4fb71f9ba7eb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major.json @@ -0,0 +1,102 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 10, + 9999 + ], + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "IPIV": [ + 3, + 0, + 3, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 3,0, + 3, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 10, + 9999, + 7, + 9999, + 8, + 9999, + 0.3, + 9999, + -1.1, + 9999, + -0.3999999999999999, + 9999, + 0.6, + 9999, + 0.181818181818182, + 9999, + 0.2727272727272729, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json new file mode 100644 index 000000000000..861b5885cde1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/large_strides/row_major_i_gt_0.json @@ -0,0 +1,103 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999 + ], + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "IPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideIPIV": 2, + "offsetIPIV": 0, + "JPIV": [ + 2, + 0, + 2, + 0, + 3, + 0 + ], + "strideJPIV": 2, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 1, + 9999, + 0, + 9999, + 0, + 9999, + 0, + 9999, + 2.220446049250313e-16, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json new file mode 100644 index 000000000000..fc71cb4477f7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 7, + 8, + 10, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideA1": 1, + "strideA2": -3, + "offsetA": 6, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 6, + -0.1999999999999993, + 0.2727272727272718, + 3, + -1.0999999999999996, + 0.3636363636363641, + 10, + 0.7, + 0.8 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json new file mode 100644 index 000000000000..50e7687d77c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/column_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0 + ], + "strideA1": -3, + "strideA2": 1, + "offsetA": 6, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 0, + 0, + 2.220446049250313e-16, + 0, + 1, + 0, + 1, + 0, + 0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json new file mode 100644 index 000000000000..539bfda870b8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 7, + 8, + 10, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideA1": -3, + "strideA2": 1, + "offsetA": 6, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 0.6, + 0.181818181818182, + 0.2727272727272729, + 0.3, + -1.1, + -0.3999999999999999, + 10, + 7, + 8 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json new file mode 100644 index 000000000000..bd3c96d3a998 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/mixed_strides/row_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0 + ], + "strideA1": 1, + "strideA2": -3, + "offsetA": 6, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 0, + 0, + 2.220446049250313e-16, + 0, + 1, + 0, + 1, + 0, + 0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json new file mode 100644 index 000000000000..8f2ddb4f7e56 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 10, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideA1": -1, + "strideA2": -3, + "offsetA": 8, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 0.2727272727272718, + -0.1999999999999993, + 6, + 0.3636363636363641, + -1.0999999999999996, + 3, + 0.8, + 0.7, + 10 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json new file mode 100644 index 000000000000..281b75ce54cd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/column_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], + "strideA1": -3, + "strideA2": -1, + "offsetA": 8, + "IPIV": [ + 3, + 2, + 2 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 2, + 2 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 2.220446049250313e-16, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json new file mode 100644 index 000000000000..2af325229364 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 10, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideA1": -3, + "strideA2": -1, + "offsetA": 8, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 0.2727272727272729, + 0.181818181818182, + 0.6, + -0.3999999999999999, + -1.1, + 0.3, + 8, + 7, + 10 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json new file mode 100644 index 000000000000..74c02d84da04 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/negative_strides/row_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], + "strideA1": -1, + "strideA2": -3, + "offsetA": 8, + "IPIV": [ + 3, + 2, + 2 + ], + "strideIPIV": -1, + "offsetIPIV": 2, + "JPIV": [ + 3, + 2, + 2 + ], + "strideJPIV": -1, + "offsetJPIV": 2, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 2.220446049250313e-16, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json new file mode 100644 index 000000000000..765897d2bda5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major.json @@ -0,0 +1,83 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 4, + 7 + ], + [ + 2, + 5, + 8 + ], + [ + 3, + 6, + 10 + ] + ], + "A": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 10 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "IPIV": [ + 0, + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 10, + 3, + 6 + ], + [ + 0.7, + -1.0999999999999996, + -0.1999999999999993 + ], + [ + 0.8, + 0.3636363636363641, + 0.2727272727272718 + ] + ], + "A_out": [ + 9999, + 10, + 0.7, + 0.8, + 3, + -1.0999999999999996, + 0.3636363636363641, + 6, + -0.1999999999999993, + 0.2727272727272718 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json new file mode 100644 index 000000000000..9752bd383398 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/column_major_i_gt_0.json @@ -0,0 +1,83 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "IPIV": [ + 0, + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 2.220446049250313e-16 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json new file mode 100644 index 000000000000..215e234f9618 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major.json @@ -0,0 +1,83 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 10 + ] + ], + "A": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 10 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "IPIV": [ + 0, + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 10, + 7, + 8 + ], + [ + 0.3, + -1.1, + -0.3999999999999999 + ], + [ + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] + ], + "A_out": [ + 9999, + 10, + 7, + 8, + 0.3, + -1.1, + -0.3999999999999999, + 0.6, + 0.181818181818182, + 0.2727272727272729 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json new file mode 100644 index 000000000000..91aa4dd3c4e1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/offsets/row_major_i_gt_0.json @@ -0,0 +1,83 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 0 + ] + ], + "A": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "IPIV": [ + 0, + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 1, + "JPIV": [ + 0, + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 1, + "A_out_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0, + 1, + 0 + ], + [ + 0, + 0, + 2.220446049250313e-16 + ] + ], + "A_out": [ + 9999, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 2.220446049250313e-16 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json new file mode 100644 index 000000000000..808671d82be8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major.json @@ -0,0 +1,79 @@ +{ + "order": "row-major", + "N": 3, + "LDA": 3, + "info": 0, + "A_mat": [ + [ + 1.0, + 2.0, + 3.0 + ], + [ + 4.0, + 5.0, + 6.0 + ], + [ + 7.0, + 8.0, + 10.0 + ] + ], + "A": [ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 10.0 + ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "IPIV": [ + 3, + 3, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 3, + 3, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 10.0, + 7.0, + 8.0 + ], + [ + 0.3, + -1.1000000000000001, + -0.3999999999999999 + ], + [ + 0.6, + 0.1818181818181820, + 0.2727272727272729 + ] + ], + "A_out": [ + 10.0, + 7.0, + 8.0, + 0.3, + -1.1000000000000001, + -0.3999999999999999, + 0.6, + 0.1818181818181820, + 0.2727272727272729 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json new file mode 100644 index 000000000000..a7d88dc678bb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/fixtures/row_major_i_gt_0.json @@ -0,0 +1,79 @@ +{ + "order": "column-major", + "N": 3, + "LDA": 3, + "info": 3, + "A_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + "A": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "IPIV": [ + 2, + 2, + 3 + ], + "strideIPIV": 1, + "offsetIPIV": 0, + "JPIV": [ + 2, + 2, + 3 + ], + "strideJPIV": 1, + "offsetJPIV": 0, + "A_out_mat": [ + [ + 1.0, + 0.0, + 0.0 + ], + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] + ], + "A_out": [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0000000000000002220446049250313 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js new file mode 100644 index 000000000000..09911b9a3504 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.dgetc2.js @@ -0,0 +1,334 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dgetc2 = require( './../lib/dgetc2.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +/* eslint-disable vars-on-top */ +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); +var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); + +/* eslint-enable vars-on-top */ + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetc2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dgetc2.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var IPIV; + var JPIV; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgetc2( value, 3, A, 3, IPIV, JPIV ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var IPIV; + var JPIV; + var A; + var i; + + values = [ + 0, + 1, + 2 + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgetc2( 'row-major', 3, A, value, IPIV, JPIV ); + }; + } +}); + +tape( 'the function returns the input matrix unchanged if `N` <= 0', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var info; + var IPIV; + var JPIV; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0 ] ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = A; + expectedIPIV = IPIV; + expectedJPIV = JPIV; + + info = dgetc2( 'row-major', 0, A, 1, IPIV, JPIV ); + + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` when `N` is 1', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var info; + var IPIV; + var JPIV; + var A; + + A = new Float64Array( [ 1.0 ] ); + IPIV = new Int32Array( 1 ); + JPIV = new Int32Array( 1 ); + + expectedA = new Float64Array( [ 1.0 ] ); + expectedIPIV = new Int32Array( [ 1 ] ); + expectedJPIV = new Int32Array( [ 1 ] ); + + info = dgetc2( 'row-major', 1, A, 1, IPIV, JPIV ); + + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + A = new Float64Array( [ 1.0e-300 ] ); + + expectedA = new Float64Array( [ 1.0020841800044864e-292 ] ); + + info = dgetc2( 'column-major', 1, A, 1, IPIV, JPIV ); + + t.strictEqual( info, 1, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( 3 ); + JPIV = new Int32Array( 3 ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.order, data.N, A, data.LDA, IPIV, JPIV ); + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.js new file mode 100644 index 000000000000..67b3dc9aa081 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dgetc2 = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetc2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof dgetc2.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var dgetc2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgetc2, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var dgetc2; + var main; + + main = require( './../lib/dgetc2.js' ); + + dgetc2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgetc2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js new file mode 100644 index 000000000000..7ece58599999 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgetc2/test/test.ndarray.js @@ -0,0 +1,702 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dgetc2 = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +/* eslint-disable vars-on-top, id-length */ +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_I_GT_0 = require( './fixtures/column_major_i_gt_0.json' ); +var ROW_MAJOR_I_GT_0 = require( './fixtures/row_major_i_gt_0.json' ); +var LARGE_STRIDES_COL_MAJOR = require( './fixtures/large_strides/column_major.json' ); +var LARGE_STRIDES_ROW_MAJOR = require( './fixtures/large_strides/row_major.json' ); +var LARGE_STRIDES_COL_I_GT_0 = require( './fixtures/large_strides/column_major_i_gt_0.json' ); +var LARGE_STRIDES_ROW_I_GT_0 = require( './fixtures/large_strides/row_major_i_gt_0.json' ); +var NEGATIVE_STRIDES_COL_MAJOR = require( './fixtures/negative_strides/column_major.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR = require( './fixtures/negative_strides/row_major.json' ); +var NEGATIVE_STRIDES_COL_I_GT_0 = require( './fixtures/negative_strides/column_major_i_gt_0.json' ); +var NEGATIVE_STRIDES_ROW_I_GT_0 = require( './fixtures/negative_strides/row_major_i_gt_0.json' ); +var MIXED_STRIDES_COL_MAJOR = require( './fixtures/mixed_strides/column_major.json' ); +var MIXED_STRIDES_ROW_MAJOR = require( './fixtures/mixed_strides/row_major.json' ); +var MIXED_STRIDES_COL_I_GT_0 = require( './fixtures/mixed_strides/column_major_i_gt_0.json' ); +var MIXED_STRIDES_ROW_I_GT_0 = require( './fixtures/mixed_strides/row_major_i_gt_0.json' ); +var OFFSETS_COL_MAJOR = require( './fixtures/offsets/column_major.json' ); +var OFFSETS_ROW_MAJOR = require( './fixtures/offsets/row_major.json' ); +var OFFSETS_COL_I_GT_0 = require( './fixtures/offsets/column_major_i_gt_0.json' ); +var OFFSETS_ROW_I_GT_0 = require( './fixtures/offsets/row_major_i_gt_0.json' ); + +/* eslint-enable vars-on-top, id-length */ + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgetc2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dgetc2.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = COL_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = ROW_MAJOR_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, large strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = LARGE_STRIDES_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, negative strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = NEGATIVE_STRIDES_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, offsets)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = OFFSETS_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (column-major, INFO > 0, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_COL_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the LU factorization with complete pivoting of the general n-by-n matrix `A` (row-major, INFO > 0, mixed strides)', function test( t ) { + var expectedIPIV; + var expectedJPIV; + var expectedA; + var data; + var info; + var IPIV; + var JPIV; + var A; + + data = MIXED_STRIDES_ROW_I_GT_0; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV.length ); + JPIV = new Int32Array( data.JPIV.length ); + + expectedA = new Float64Array( data.A_out ); + expectedIPIV = new Int32Array( data.IPIV ); + expectedJPIV = new Int32Array( data.JPIV ); + + info = dgetc2( data.N, A, data.strideA1, data.strideA2, data.offsetA, IPIV, data.strideIPIV, data.offsetIPIV, JPIV, data.strideJPIV, data.offsetJPIV ); + + t.strictEqual( info, data.info, 'returns expected value' ); + isApprox( t, A, expectedA, 1.0 ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( JPIV, expectedJPIV, 'returns expected value' ); + + t.end(); +});