diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/README.md b/lib/node_modules/@stdlib/lapack/base/dgttrf/README.md new file mode 100644 index 000000000000..4cc24fe014bf --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/README.md @@ -0,0 +1,308 @@ + + +# dgttrf + +> Compute an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. + +
+ +## Usage + +```javascript +var dgttrf = require( '@stdlib/lapack/base/dgttrf' ); +``` + +#### dgttrf( N, DL, D, DU, DU2, IPIV ) + +Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var DL = new Float64Array( [ 1.0, 1.0 ] ); +var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +var DU = new Float64Array( [ 1.0, 1.0 ] ); +var DU2 = new Float64Array( 1 ); +var IPIV = new Int32Array( 3 ); + +dgttrf( 3, DL, D, DU, DU2, IPIV ); +// DL => [ 0.5, 0.4 ] +// D => [ 2, 2.5, 0.6 ] +// DU => [ 1, 1 ] +// DU2 => [ 0 ] +// IPIV => [ 0, 1, 2 ] +``` + +The function has the following parameters: + +- **N**: order of matrix `A`. +- **DL**: the sub diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. On exit, DL is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. +- **D**: the diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. On exit, D is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. +- **DU**: the super diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. On exit, DU is overwritten by the elements of the first super-diagonal of `U`. +- **DU2**: On exit, DU2 is overwritten by the elements of the second super-diagonal of `U` as a [`Float64Array`][mdn-float64array]. +- **IPIV**: vector of pivot indices as a [`Int32Array`][mdn-int32array]. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +// Initial arrays... +var DL0 = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var D0 = new Float64Array( [ 0.0, 2.0, 3.0, 1.0 ] ); +var DU0 = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var DU20 = new Float64Array( 2 ); +var IPIV0 = new Int32Array( 4 ); + +// Create offset views... +var DL = new Float64Array( DL0.buffer, DL0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var DU = new Float64Array( DU0.buffer, DU0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var DU2 = new Float64Array( DU20.buffer, DU20.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dgttrf( 3, DL, D, DU, DU2, IPIV ); +// DL0 => [ 0, 0.5, 0.4 ] +// D0 => [ 0, 2, 2.5, 0.6 ] +// DU0 => [ 0, 1, 1 ] +// DU20 => [ 0, 0 ] +// IPIV0 => [ 0, 0, 1, 2 ] +``` + + + +#### dgttrf.ndarray( N, DL, sdl, odl, D, sd, od, DU, sdu, odu, DU2, sdu2, odu2, IPIV, si, oi ) + +Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges and alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgttrf = require( '@stdlib/lapack/base/dgttrf' ); + +var DL = new Float64Array( [ 1.0, 1.0 ] ); +var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +var DU = new Float64Array( [ 1.0, 1.0 ] ); +var DU2 = new Float64Array( 1 ); +var IPIV = new Int32Array( 3 ); + +dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); +// DL => [ 0.5, 0.4 ] +// D => [ 2, 2.5, 0.6 ] +// DU => [ 1, 1 ] +// DU2 => [ 0 ] +// IPIV => [ 0, 1, 2 ] +``` + +The function has the following additional parameters: + +- **sdl**: stride length for `DL`. +- **odl**: starting index for `DL`. +- **sd**: stride length for `D`. +- **od**: starting index for `D`. +- **sdu**: stride length for `DU`. +- **odu**: starting index for `DU`. +- **sdu2**: stride length for `DU2`. +- **odu2**: starting index for `DU2`. +- **si**: stride length for `IPIV`. +- **oi**: starting index for `IPIV`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var DL = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var D = new Float64Array( [ 0.0, 2.0, 3.0, 1.0 ] ); +var DU = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var DU2 = new Float64Array( 2 ); +var IPIV = new Int32Array( 4 ); + +dgttrf.ndarray( 3, DL, 1, 1, D, 1, 1, DU, 1, 1, DU2, 1, 1, IPIV, 1, 1 ); +// DL => [ 0, 0.5, 0.4 ] +// D => [ 0, 2, 2.5, 0.6 ] +// DU => [ 0, 1, 1 ] +// DU2 => [ 0, 0 ] +// IPIV => [ 0, 0, 1, 2 ] +``` + +
+ + + +
+ +## Notes + +- Both functions mutate the input arrays `DL`, `D`, `DU`, `DU2` and `IPIV`. + +- Both functions return a status code indicating success or failure. A status code indicates the following conditions: + + - `0`: factorization was successful. + - `<0`: the k-th argument had an illegal value, where `-k` equals the status code value. + - `>0`: `U( k, k )` is exactly zero the factorization has been completed, but the factor `U` is exactly singular, and division by zero will occur if it is used to solve a system of equations, where `k` equals the status code value. + +- `dgttrf()` corresponds to the [LAPACK][LAPACK] routine [`dgttrf`][lapack-dgttrf]. + +
+ + + +
+ +## Examples + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dgttrf = require( '@stdlib/lapack/base/dgttrf' ); + +var N = 9; + +var DL = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +var DU = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + +var DU2 = new Float64Array( N-2 ); + +var IPIV = new Int32Array( N ); + +// Perform the `A = LU` factorization: +var info = dgttrf( N, DL, D, DU, DU2, IPIV ); + +console.log( DL ); +console.log( D ); +console.log( DU ); +console.log( DU2 ); +console.log( IPIV ); +console.log( info ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.js new file mode 100644 index 000000000000..8f234b67338c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.js @@ -0,0 +1,102 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var dgttrf = require( './../lib/dgttrf.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var IPIV = new Int32Array( len ); + var DU2 = new Float64Array( len-2 ); + var DL = uniform( len-1, 0.0, 100.0, options ); + var DU = uniform( len-1, 0.0, 100.0, options ); + var D = uniform( len, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dgttrf( len, DL, D, DU, DU2, IPIV ); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..ddee8c23c626 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.ndarray.js @@ -0,0 +1,102 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var dgttrf = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var IPIV = new Int32Array( len ); + var DU2 = new Float64Array( len-2 ); + var DL = uniform( len-1, 0.0, 100.0, options ); + var DU = uniform( len-1, 0.0, 100.0, options ); + var D = uniform( len, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dgttrf( len, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // eslint-disable-line max-len + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/repl.txt new file mode 100644 index 000000000000..beebf8bee896 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/repl.txt @@ -0,0 +1,194 @@ + +{{alias}}( N, DL, D, DU, DU2, IPIV ) + Computes an `LU` factorization of a real tridiagonal matrix `A` using + elimination with partial pivoting and row interchanges. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The function mutates `DL`, `D`, `DU`, `DU2` and `IPIV`. + + Parameters + ---------- + N: integer + Order of matrix `A`. + + DL: Float64Array + Sub diagonal elements of A. On exit, DL is overwritten by the + multipliers that define the matrix L from the LU factorization of A. + + D: Float64Array + Diagonal elements of A. On exit, D is overwritten by the diagonal + elements of the upper triangular matrix U from the LU factorization + of A. + + DU: Float64Array + Super diagonal elements of A. On exit, DU is overwritten by the + elements of the first super-diagonal of U. + + DU2: Float64Array + On exit, DU2 is overwritten by the elements of the second + super-diagonal of U. + + IPIV: Int32Array + Array of pivot indices. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + - if greater than zero, then U( k, k ) is exactly zero the factorization + has been completed, but the factor U is exactly singular, and division + by zero will occur if it is used to solve a system of equations, + where `k = StatusCode`. + + Examples + -------- + > var DL = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var D = new {{alias:@stdlib/array/float64}}( [ 2.0, 3.0, 1.0 ] ); + > var DU = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var DU2 = new {{alias:@stdlib/array/float64}}( 1 ); + > var IPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > {{alias}}( 3, DL, D, DU, DU2, IPIV ) + 0 + > DL + [ 0.5, 0.4 ] + > D + [ 2, 2.5, 0.6 ] + > DU + [ 1, 1 ] + > DU2 + [ 0 ] + > IPIV + [ 0, 1, 2 ] + + // Using typed array views: + > var DL0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); + > var D0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 2.0, 3.0, 1.0 ] ); + > var DU0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); + > var DU20 = new {{alias:@stdlib/array/float64}}( 2 ); + > var IPIV0 = new {{alias:@stdlib/array/int32}}( 4 ); + > DL = new Float64Array( DL0.buffer, DL0.BYTES_PER_ELEMENT*1 ); + > D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); + > DU = new Float64Array( DU0.buffer, DU0.BYTES_PER_ELEMENT*1 ); + > DU2 = new Float64Array( DU20.buffer, DU20.BYTES_PER_ELEMENT*1 ); + > IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 3, DL, D, DU, DU2, IPIV ) + 0 + > DL0 + [ 0, 0.5, 0.4 ] + > D0 + [ 0, 2, 2.5, 0.6 ] + > DU0 + [ 0, 1, 1 ] + > DU20 + [ 0, 0 ] + > IPIV0 + [ 0, 0, 1, 2 ] + + +{{alias}}.ndarray( N,DL,sdl,odl,D,sd,od,DU,sdu,odu,DU2,sdu2,odu2,IPIV,si,oi ) + Computes an `LU` factorization of a real tridiagonal matrix `A` using + elimination with partial pivoting and row interchanges and alternative + indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + The function mutates `DL`, `D`, `DU`, `DU2` and `IPIV`. + + Parameters + ---------- + N: integer + Order of matrix `A`. + + DL: Float64Array + Sub diagonal elements of A. On exit, DL is overwritten by the + multipliers that define the matrix L from the LU factorization of A. + + sdl: integer + Stride length for `DL`. + + odl: integer + Starting index for `DL`. + + D: Float64Array + Diagonal elements of A. On exit, D is overwritten by the diagonal + elements of the upper triangular matrix U from the LU factorization + of A. + + sd: integer + Stride length for `D`. + + od: integer + Starting index for `D`. + + DU: Float64Array + Super diagonal elements of A. On exit, DU is overwritten by the + elements of the first super-diagonal of U. + + sdu: integer + Stride length for `DU`. + + odu: integer + Starting index for `DU2`. + + DU2: Float64Array + On exit, DU2 is overwritten by the elements of the second + super-diagonal of U. + + sdu2: integer + Stride length for `DU2`. + + odu2: integer + Starting index for `DU2`. + + IPIV: Int32Array + Array of pivot indices. + + si: integer + Stride length for `IPIV`. + + oi: integer + Starting index for `IPIV`. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + - if greater than zero, then U( k, k ) is exactly zero the factorization + has been completed, but the factor U is exactly singular, and division + by zero will occur if it is used to solve a system of equations, + where `k = StatusCode`. + + Examples + -------- + > var DL = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var D = new {{alias:@stdlib/array/float64}}( [ 2.0, 3.0, 1.0 ] ); + > var DU = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var DU2 = new {{alias:@stdlib/array/float64}}( 1 ); + > var IPIV = new {{alias:@stdlib/array/int32}}( 3 ); + > {{alias}}.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ) + 0 + > DL + [ 0.5, 0.4 ] + > D + [ 2, 2.5, 0.6 ] + > DU + [ 1, 1 ] + > DU2 + [ 0 ] + > IPIV + [ 0, 1, 2 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/types/index.d.ts new file mode 100644 index 000000000000..31773a9e8fd9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/types/index.d.ts @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Status code. +* +* ## Notes +* +* The status code indicates the following conditions: +* +* - if equal to zero, then the factorization was successful. +* - if less than zero, then the k-th argument had an illegal value, where `k = -StatusCode`. +* - if greater than zero, then U( k, k ) is exactly zero the factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations, where `k = StatusCode`. +*/ +type StatusCode = number; + +/** +* Interface describing `dgttrf`. +*/ +interface Routine { + /** + * Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. + * + * ## Notes + * + * - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. + * - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. + * - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`. + * - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`. + * - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. + * + * @param N - order of matrix `A` + * @param DL - sub diagonal elements of `A` + * @param D - diagonal elements of `A` + * @param DU - super diagonal elements of `A` + * @param DU2 - vector to store the second super diagonal of `U` + * @param IPIV - vector of pivot indices + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var DL = new Float64Array( [ 1.0, 1.0 ] ); + * var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); + * var DU = new Float64Array( [ 1.0, 1.0 ] ); + * var DU2 = new Float64Array( 1 ); + * var IPIV = new Int32Array( 3 ); + * + * dgttrf( 3, DL, D, DU, DU2, IPIV ); + * // DL => [ 0.5, 0.4 ] + * // D => [ 2, 2.5, 0.6 ] + * // DU => [ 1, 1 ] + * // DU2 => [ 0 ] + * // IPIV => [ 0, 1, 2 ] + */ + ( N: number, DL: Float64Array, D: Float64Array, DU: Float64Array, DU2: Float64Array, IPIV: Int32Array ): StatusCode; + + /** + * Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges and alternative indexing semantics. + * + * ## Notes + * + * - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. + * - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. + * - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`. + * - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`. + * - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. + * + * @param N - order of matrix `A` + * @param DL - sub diagonal elements of `A` + * @param sdl - stride length for `DL` + * @param odl - starting index of `DL` + * @param D - diagonal elements of `A` + * @param sd - stride length for `D` + * @param od - starting index of `D` + * @param DU - super diagonal elements of `A` + * @param sdu - stride length for `DU` + * @param odu - starting index of `DU` + * @param DU2 - vector to store the second super diagonal of `U` + * @param sdu2 - stride length for `DU2` + * @param odu2 - starting index of `DU2` + * @param IPIV - vector of pivot indices + * @param si - stride length for `IPIV` + * @param oi - starting index of `IPIV` + * @returns status code + * + * @example + * var DL = new Float64Array( [ 1.0, 1.0 ] ); + * var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); + * var DU = new Float64Array( [ 1.0, 1.0 ] ); + * var DU2 = new Float64Array( 1 ); + * var IPIV = new Int32Array( 3 ); + * + * dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); + * // DL => [ 0.5, 0.4 ] + * // D => [ 2, 2.5, 0.6 ] + * // DU => [ 1, 1 ] + * // DU2 => [ 0 ] + * // IPIV => [ 0, 1, 2 ] + */ + ndarray( N: number, DL: Float64Array, sdl: number, odl: number, D: Float64Array, sd: number, od: number, DU: Float64Array, sdu: number, odu: number, DU2: Float64Array, sdu2: number, odu2: number, IPIV: Int32Array, si: number, oi: number ): StatusCode; +} + +/** +* LAPACK routine to compute an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. +* +* ## Notes +* +* - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. +* - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. +* - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`. +* - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`. +* - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. +* +* @param N - order of matrix `A` +* @param DL - sub diagonal elements of `A` +* @param D - diagonal elements of `A` +* @param DU - super diagonal elements of `A` +* @param DU2 - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U` +* @param IPIV - vector of pivot indices +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf( 3, DL, D, DU, DU2, IPIV ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +*/ +declare var dgttrf: Routine; + + +// EXPORTS // + +export = dgttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/types/test.ts new file mode 100644 index 000000000000..79e8b3456d02 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/docs/types/test.ts @@ -0,0 +1,485 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +import dgttrf = require( './index' ); + +// TESTS // + +// The function returns a number... +{ + const D = new Float64Array( 3 ); + const DL = new Float64Array( 2 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf( 3, DL, D, DU, DU2, IPIV ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const D = new Float64Array( 3 ); + const DL = new Float64Array( 2 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf( '5', DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( true, DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( false, DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( null, DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( undefined, DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( [], DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( {}, DL, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( ( x: number ): number => x, DL, D, DU, DU2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf( 3, '5', D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, 5, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, true, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, false, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, null, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, undefined, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, [], D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, {}, D, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, ( x: number ): number => x, D, DU, DU2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf( 3, DL, '5', DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, 5, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, true, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, false, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, null, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, undefined, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, [], DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, {}, DU, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, ( x: number ): number => x, DU, DU2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf( 3, DL, D, '5', DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, 5, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, true, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, false, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, null, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, undefined, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, [], DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, {}, DU2, IPIV ); // $ExpectError + dgttrf( 3, DL, D, ( x: number ): number => x, DU2, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const IPIV = new Int32Array( 3 ); + + dgttrf( 3, DL, D, DU, '5', IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, 5, IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, true, IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, false, IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, null, IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, undefined, IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, [], IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, {}, IPIV ); // $ExpectError + dgttrf( 3, DL, D, DU, ( x: number ): number => x, IPIV ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not an Int32Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + + dgttrf( 3, DL, D, DU, DU2, '5' ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, 5 ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, true ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, false ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, null ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, undefined ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, [] ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, {} ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf(); // $ExpectError + dgttrf( 3 ); // $ExpectError + dgttrf( 3, DL ); // $ExpectError + dgttrf( 3, DL, D ); // $ExpectError + dgttrf( 3, DL, D, DU ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2 ); // $ExpectError + dgttrf( 3, DL, D, DU, DU2, IPIV, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( '5', DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( true, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( false, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( null, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( undefined, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( [], DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( {}, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( ( x: number ): number => x, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, '5', 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, 5, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, true, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, false, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, null, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, undefined, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, [], 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, {}, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, ( x: number ): number => x, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, '5', 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, true, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, false, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, null, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, undefined, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, [], 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, {}, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, ( x: number ): number => x, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, '5', D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, true, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, false, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, null, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, undefined, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, [], D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, {}, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, ( x: number ): number => x, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, '5', 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, 5, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, true, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, false, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, null, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, undefined, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, [], 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, {}, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, ( x: number ): number => x, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, '5', 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, true, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, false, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, null, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, undefined, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, [], 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, {}, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, ( x: number ): number => x, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, '5', DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, true, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, false, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, null, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, undefined, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, [], DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, {}, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, ( x: number ): number => x, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, '5', 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, 5, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, true, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, false, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, null, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, undefined, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, [], 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, {}, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, ( x: number ): number => x, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, '5', 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, true, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, false, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, null, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, undefined, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, [], 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, {}, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, ( x: number ): number => x, 0, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, '5', DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, true, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, false, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, null, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, undefined, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, [], DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, {}, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, ( x: number ): number => x, DU2, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, '5', 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, 5, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, true, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, false, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, null, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, undefined, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, [], 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, {}, 1, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, ( x: number ): number => x, 1, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, '5', 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, true, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, false, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, null, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, undefined, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, [], 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, {}, 0, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, ( x: number ): number => x, 0, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, '5', IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, true, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, false, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, null, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, undefined, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, [], IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, {}, IPIV, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, ( x: number ): number => x, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not an Int32Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, '5', 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, 5, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, true, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, false, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, null, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, undefined, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, [], 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, {}, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifteenth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, '5', 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, true, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, false, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, null, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, undefined, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, [], 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, {}, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixteenth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, '5' ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, true ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, false ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, null ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, undefined ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, [] ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, {} ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const DU2 = new Float64Array( 1 ); + const IPIV = new Int32Array( 3 ); + + dgttrf.ndarray(); // $ExpectError + dgttrf.ndarray( 3 ); // $ExpectError + dgttrf.ndarray( 3, DL ); // $ExpectError + dgttrf.ndarray( 3, DL, 1 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1 ); // $ExpectError + dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/examples/index.js new file mode 100644 index 000000000000..1e076ffbd5a7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/examples/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dgttrf = require( './../lib' ); + +var N = 9; + +var DL = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +var DU = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + +var DU2 = new Float64Array( N-2 ); + +var IPIV = new Int32Array( N ); + +// Perform the `A = LU` factorization: +var info = dgttrf( N, DL, D, DU, DU2, IPIV ); + +console.log( DL ); +console.log( D ); +console.log( DU ); +console.log( DU2 ); +console.log( IPIV ); +console.log( info ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/base.js new file mode 100644 index 000000000000..fffdc9e2702f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/base.js @@ -0,0 +1,172 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var abs = require( '@stdlib/math/base/special/abs' ); + + +// MAIN // + +/** +* Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. +* +* ## Notes +* +* - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. +* - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. +* - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`. +* - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`. +* - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. +* +* @private +* @param {NonNegativeInteger} N - order of matrix A. +* @param {Float64Array} DL - sub diagonal elements of A. +* @param {integer} sdl - stride length for `DL` +* @param {NonNegativeInteger} odl - starting index of `DL` +* @param {Float64Array} D - diagonal elements of A. +* @param {integer} sd - stride length for `D` +* @param {NonNegativeInteger} od - starting index of `D` +* @param {Float64Array} DU - super diagonal elements of A. +* @param {integer} sdu - stride length for `DU` +* @param {NonNegativeInteger} odu - starting index of `DU` +* @param {Float64Array} DU2 - vector to store the second super diagonal of `U` +* @param {integer} sdu2 - stride length for `DU2` +* @param {NonNegativeInteger} odu2 - starting index of `DU2` +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} si - stride length for `IPIV` +* @param {NonNegativeInteger} oi - starting index of `IPIV` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ) +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +*/ +function dgttrf( N, DL, sdl, odl, D, sd, od, DU, sdu, odu, DU2, sdu2, odu2, IPIV, si, oi ) { // eslint-disable-line max-len, max-params + var fact; + var temp; + var idu2; + var idu; + var idl; + var dli; + var dui; + var id; + var ip; + var di; + var ii; + var i; + + // Quick return if possible + if ( N === 0 ) { + return 0; + } + + idl = odl; + id = od; + idu = odu; + idu2 = odu2; + ip = oi; + + // Initialise ith element of IPIV as i + for ( i = 0; i < N; i++ ) { + IPIV[ ip + (si*i) ] = i; + } + + // Initialise ith element of DU2 as 0 + for ( i = 0; i < N-2; i++ ) { + DU2[ idu + dui ] = 0; + } + + for ( i = 0; i < N-2; i++ ) { + di = sd * i; + dli = sdl * i; + ii = si * i; + dui = sdu * i; + + if ( abs( D[ id + di ] ) >= abs( DL[ idl + dli ] ) ) { // No row interchange required, eleminate ith element of DL + if ( D[ id ] !== 0.0 ) { + fact = DL[ idl + dli ] / D[ id + di ]; + DL[ idl + dli ] = fact; + D[ id + di + sd ] = D[ id + di + sd ] - ( fact*DU[ idu + dui ] ); // eslint-disable-line max-len + } + } else { // Interchange the ith and (i+1)th rows and eliminate ith element of DL + fact = D[ id + di ] / DL[ idl + dli ]; + D[ id + di ] = DL[ idl + dli ]; + DL[ idl + dli ] = fact; + temp = DU[ idu + dui ]; + DU[ idu + dui ] = D[ id + di + sd ]; + D[ id + di + sd ] = temp - ( fact * D[ id + di + sd ] ); + DU2[ idu2 + ( sdu2 * i ) ] = DU[ idu + dui + sdu ]; + DU[ idu + dui + sdu ] = -fact * DU[ idu + dui + sdu ]; + IPIV[ ip + ii ] = i + 1; + } + } + + if ( N > 1 ) { + i = N - 2; + di = sd * i; + dli = sdl * i; + ii = si * i; + dui = sdu * i; + + if ( abs( D[ id + di ] ) >= abs( DL[ idl + dli ] ) ) { + if ( D[ id + di ] !== 0 ) { + fact = DL[ idl + dli ] / D[ id + di ]; + DL[ idl + dli ] = fact; + D[ id + di + sd ] = D[ id + di + sd ] - (fact*DU[ idu + dui ]); + } + } else { + fact = D[ id + di ] / DL[ idl + dli ]; + D[ id + di ] = DL[ idl + dli ]; + DL[ idl + dli ] = fact; + temp = DU[ idu + dui ]; + DU[ idu + dui ] = D[ id + di + sd ]; + D[ id + di + sd ] = temp - ( fact * D[ id + di + sd ] ); + IPIV[ ip + ii ] = i + 1; + } + } + + // Check for a 0 on the diagonal of U + for ( i = 0; i < N; i++ ) { + if ( D[ sd * i ] === 0.0 ) { + return i; + } + } + + return 0; +} + + +// EXPORTS // + +module.exports = dgttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/dgttrf.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/dgttrf.js new file mode 100644 index 000000000000..482943f6be08 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/dgttrf.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. +* +* ## Notes +* +* - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. +* - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. +* - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`. +* - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`. +* - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. +* +* @param {NonNegativeInteger} N - order of matrix A +* @param {Float64Array} DL - sub diagonal elements of A. +* @param {Float64Array} D - diagonal elements of A. +* @param {Float64Array} DU - super diagonal elements of A. +* @param {Float64Array} DU2 - vector to store the second super diagonal of `U` +* @param {Int32Array} IPIV - vector of pivot indices +* @throws {RangeError} first argument must be a nonnegative integer +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf( 3, DL, D, DU, DU2, IPIV ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +*/ +function dgttrf( N, DL, D, DU, DU2, IPIV ) { + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + return base( N, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dgttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/index.js new file mode 100644 index 000000000000..e4f7211c056e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/index.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. +* +* @module @stdlib/lapack/base/dgttrf +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgttrf = require( '@stdlib/lapack/base/dgttrf' ); +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf( 3, DL, D, DU, DU2, IPIV ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgttrf = require( '@stdlib/lapack/base/dgttrf' ); +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +*/ + +// 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 dgttrf; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgttrf = main; +} else { + dgttrf = tmp; +} + + +// EXPORTS // + +module.exports = dgttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/main.js new file mode 100644 index 000000000000..ecbc1020047d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dgttrf = require( './dgttrf.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgttrf, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/ndarray.js new file mode 100644 index 000000000000..6c49def4d814 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/lib/ndarray.js @@ -0,0 +1,85 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges and alternative indexing semantics. +* +* ## Notes +* +* - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`. +* - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`. +* - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`. +* - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`. +* - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. +* +* @param {NonNegativeInteger} N - order of matrix A. +* @param {Float64Array} DL - sub diagonal elements of A. +* @param {integer} sdl - stride length for `DL` +* @param {NonNegativeInteger} odl - starting index of `DL` +* @param {Float64Array} D - diagonal elements of A. +* @param {integer} sd - stride length for `D` +* @param {NonNegativeInteger} od - starting index of `D` +* @param {Float64Array} DU - super diagonal elements of A. +* @param {integer} sdu - stride length for `DU` +* @param {NonNegativeInteger} odu - starting index of `DU` +* @param {Float64Array} DU2 - vector to store the second super diagonal of `U` +* @param {integer} sdu2 - stride length for `DU2` +* @param {NonNegativeInteger} odu2 - starting index of `DU2` +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} si - stride length for `IPIV` +* @param {NonNegativeInteger} oi - starting index of `IPIV` +* @throws {RangeError} first argument must be a nonnegative integer +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var DL = new Float64Array( [ 1.0, 1.0 ] ); +* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] ); +* var DU = new Float64Array( [ 1.0, 1.0 ] ); +* var DU2 = new Float64Array( 1 ); +* var IPIV = new Int32Array( 3 ); +* +* dgttrf( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); +* // DL => [ 0.5, 0.4 ] +* // D => [ 2, 2.5, 0.6 ] +* // DU => [ 1, 1 ] +* // DU2 => [ 0 ] +* // IPIV => [ 0, 1, 2 ] +*/ +function dgttrf( N, DL, sdl, odl, D, sd, od, DU, sdu, odu, DU2, sdu2, odu2, IPIV, si, oi ) { // eslint-disable-line max-len, max-params + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + return base( N, DL, sdl, odl, D, sd, od, DU, sdu, odu, DU2, sdu2, odu2, IPIV, si, oi ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/package.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/package.json new file mode 100644 index 000000000000..561a8b1b375c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dgttrf", + "version": "0.0.0", + "description": "Compute an `LU` factorization of a real tri diagonal matrix `A` using elimination with partial pivoting and row interchanges", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "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", + "dgttrf", + "cholesky", + "factorization", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/large_positive_stride_1.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/large_positive_stride_1.json new file mode 100644 index 000000000000..232bcd76030f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/large_positive_stride_1.json @@ -0,0 +1,30 @@ +{ + "N": 3, + + "DL": [ 1.0, 9999.0, 1.0, 9999.0 ], + "sdl": 2, + "odl": 0, + + "D": [ 2.0, 9999.0, 3.0, 9999.0, 1.0, 9999.0 ], + "sd": 2, + "od": 0, + + "DU": [ 1.0, 9999.0, 1.0, 9999.0 ], + "sdu": 2, + "odu": 0, + + "DU2": [ 0.0, 0.0 ], + "sdu2": 2, + "odu2": 0, + + "IPIV": [ 0, 0, 0, 0, 0, 0 ], + "si": 2, + "oi": 0, + + "expectedDL": [ 0.5, 9999.0, 0.4, 9999.0 ], + "expectedD": [ 2.0, 9999.0, 2.5, 9999.0, 0.6, 9999.0 ], + "expectedDU": [ 1.0, 9999.0, 1.0, 9999.0 ], + "expectedDU2": [ 0.0, 0.0 ], + "expectedIPIV": [ 0, 0, 1, 0, 2, 0 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/large_positive_stride_2.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/large_positive_stride_2.json new file mode 100644 index 000000000000..9218f31f9cb1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/large_positive_stride_2.json @@ -0,0 +1,30 @@ +{ + "N": 9, + + "DL": [ 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0 ], + "sdl": 2, + "odl": 0, + + "D": [ 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0 ], + "sd": 2, + "od": 0, + + "DU": [ 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0 ], + "sdu": 2, + "odu": 0, + + "DU2": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "sdu2": 2, + "odu2": 0, + + "IPIV": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + "si": 2, + "oi": 0, + + "expectedDL": [ 0.3333333333333333, 9999.0, 0.8181818181818182, 9999.0, 0.6969696969696969, 9999.0, 0.9082568807339449, 9999.0, 0.8493506493506494, 9999.0, -0.7991341991341993, 9999.0, 0.6251127548259066, 9999.0, -0.3327319742618318, 9999.0 ], + "expectedD": [ 3.0, 9999.0, 3.6666666666666665, 9999.0, 3.0, 9999.0, 3.3030303030303032, 9999.0, 3.5321100917431192, 9999.0, 3.0, 9999.0, 4.7991341991341994, 9999.0, 3.0, 9999.0, 4.3327319742618320, 9999.0 ], + "expectedDU": [ 1.0, 9999.0, -1.3333333333333333, 9999.0, 1.0, 9999.0, -2.7878787878787876, 9999.0, 4.0, 9999.0, 1.0, 9999.0, 3.1965367965367970, 9999.0, 1.0, 9999.0 ], + "expectedDU2": [ 4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0 ], + "expectedIPIV": [ 1, 0, 1, 0, 3, 0, 3, 0, 4, 0, 6, 0, 6, 0, 8, 0, 8, 0 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/mixed_strides.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/mixed_strides.json new file mode 100644 index 000000000000..514ee7f79df1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/mixed_strides.json @@ -0,0 +1,30 @@ +{ + "N": 3, + + "DL": [ 1.0, 1.0 ], + "sdl": -1, + "odl": 1, + + "D": [ 2.0, 3.0, 1.0 ], + "sd": 1, + "od": 0, + + "DU": [ 1.0, 1.0 ], + "sdu": -1, + "odu": 1, + + "DU2": [ 0.0 ], + "sdu2": -1, + "odu2": 0, + + "IPIV": [ 0, 0, 0 ], + "si": 1, + "oi": 0, + + "expectedDL": [ 0.4, 0.5 ], + "expectedD": [ 2.0, 2.5, 0.6 ], + "expectedDU": [ 1.0, 1.0 ], + "expectedDU2": [ 0.0 ], + "expectedIPIV": [ 0, 1, 2 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/negative_strides.json new file mode 100644 index 000000000000..9aec6a371b28 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/negative_strides.json @@ -0,0 +1,30 @@ +{ + "N": 3, + + "DL": [ 1.0, 1.0 ], + "sdl": -1, + "odl": 1, + + "D": [ 1.0, 3.0, 2.0 ], + "sd": -1, + "od": 2, + + "DU": [ 1.0, 1.0 ], + "sdu": -1, + "odu": 1, + + "DU2": [ 0.0 ], + "sdu2": -1, + "odu2": 0, + + "IPIV": [ 0, 0, 0 ], + "si": -1, + "oi": 2, + + "expectedDL": [ 0.4, 0.5 ], + "expectedD": [ 0.6, 2.5, 2.0 ], + "expectedDU": [ 1.0, 1.0 ], + "expectedDU2": [ 0.0 ], + "expectedIPIV": [ 2, 1, 0 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_no_offset_1.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_no_offset_1.json new file mode 100644 index 000000000000..b9cecc571bf7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_no_offset_1.json @@ -0,0 +1,30 @@ +{ + "N": 3, + + "DL": [ 1.0, 1.0 ], + "sdl": 1, + "odl": 0, + + "D": [ 2.0, 3.0, 1.0 ], + "sd": 1, + "od": 0, + + "DU": [ 1.0, 1.0 ], + "sdu": 1, + "odu": 0, + + "DU2": [ 0.0 ], + "sdu2": 1, + "odu2": 0, + + "IPIV": [ 0, 0, 0 ], + "si": 1, + "oi": 0, + + "expectedDL": [ 0.5, 0.4 ], + "expectedD": [ 2.0, 2.5, 0.6 ], + "expectedDU": [ 1.0, 1.0 ], + "expectedDU2": [ 0.0 ], + "expectedIPIV": [ 0, 1, 2 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_no_offset_2.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_no_offset_2.json new file mode 100644 index 000000000000..02c60436c391 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_no_offset_2.json @@ -0,0 +1,30 @@ +{ + "N": 9, + + "DL": [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ], + "sdl": 1, + "odl": 0, + + "D": [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], + "sd": 1, + "od": 0, + + "DU": [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ], + "sdu": 1, + "odu": 0, + + "DU2": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "sdu2": 1, + "odu2": 0, + + "IPIV": [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + "si": 1, + "oi": 0, + + "expectedDL": [ 0.3333333333333333, 0.8181818181818182, 0.6969696969696969, 0.9082568807339449, 0.8493506493506494, -0.7991341991341993, 0.6251127548259066, -0.3327319742618318 ], + "expectedD": [ 3.0, 3.6666666666666665, 3.0, 3.3030303030303032, 3.5321100917431192, 3.0, 4.7991341991341994, 3.0, 4.3327319742618320 ], + "expectedDU": [ 1.0, -1.3333333333333333, 1.0, -2.7878787878787876, 4.0, 1.0, 3.1965367965367970, 1.0 ], + "expectedDU2": [ 4.0, 0.0, 4.0, 0.0, 0.0, 4.0, 0.0 ], + "expectedIPIV": [ 1, 1, 3, 3, 4, 6, 6, 8, 8 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_offset_1.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_offset_1.json new file mode 100644 index 000000000000..eb124b7dd8ae --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_offset_1.json @@ -0,0 +1,30 @@ +{ + "N": 3, + + "DL": [ 0.0, 1.0, 1.0 ], + "sdl": 1, + "odl": 1, + + "D": [ 0.0, 2.0, 3.0, 1.0 ], + "sd": 1, + "od": 1, + + "DU": [ 0.0, 1.0, 1.0 ], + "sdu": 1, + "odu": 1, + + "DU2": [ 0.0, 0.0 ], + "sdu2": 1, + "odu2": 1, + + "IPIV": [ 0, 0, 0, 0 ], + "si": 1, + "oi": 1, + + "expectedDL": [ 0.0, 0.5, 0.4 ], + "expectedD": [ 0.0, 2.0, 2.5, 0.6 ], + "expectedDU": [ 0.0, 1.0, 1.0 ], + "expectedDU2": [ 0.0, 0.0 ], + "expectedIPIV": [ 0, 0, 1, 2 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_offset_2.json b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_offset_2.json new file mode 100644 index 000000000000..54b3e6e0de0f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/fixtures/positive_stride_offset_2.json @@ -0,0 +1,30 @@ +{ + "N": 9, + + "DL": [ 0.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ], + "sdl": 1, + "odl": 1, + + "D": [ 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], + "sd": 1, + "od": 1, + + "DU": [ 0.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ], + "sdu": 1, + "odu": 1, + + "DU2": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "sdu2": 1, + "odu2": 1, + + "IPIV": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + "si": 1, + "oi": 1, + + "expectedDL": [ 0.0, 0.3333333333333333, 0.8181818181818182, 0.6969696969696969, 0.9082568807339449, 0.8493506493506494, -0.7991341991341993, 0.6251127548259066, -0.3327319742618318 ], + "expectedD": [ 0.0, 3.0, 3.6666666666666665, 3.0, 3.3030303030303032, 3.5321100917431192, 3.0, 4.7991341991341994, 3.0, 4.3327319742618320 ], + "expectedDU": [ 0.0, 1.0, -1.3333333333333333, 1.0, -2.7878787878787876, 4.0, 1.0, 3.1965367965367970, 1.0 ], + "expectedDU2": [ 0.0, 4.0, 0.0, 4.0, 0.0, 0.0, 4.0, 0.0 ], + "expectedIPIV": [ 0, 1, 1, 3, 3, 4, 6, 6, 8, 8 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.dgttrf.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.dgttrf.js new file mode 100644 index 000000000000..2b178a03496c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.dgttrf.js @@ -0,0 +1,213 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgttrf = require( './../lib/dgttrf.js' ); + + +// FIXTURES // + +var POSITIVE_STRIDES_NO_OFFSET_1 = require( './fixtures/positive_stride_no_offset_1.json' ); // eslint-disable-line id-length +var POSITIVE_STRIDES_NO_OFFSET_2 = require( './fixtures/positive_stride_no_offset_2.json' ); // eslint-disable-line id-length + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgttrf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dgttrf.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is less than zero', function test( t ) { + var values; + var data; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var i; + + data = POSITIVE_STRIDES_NO_OFFSET_1; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgttrf( value, DL, D, DU, DU2, IPIV ); + }; + } +}); + +tape( 'the function performs the `LU` factorization of a real tri diagonal matrix `A` using elimination with partial pivoting and row interchanges', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = POSITIVE_STRIDES_NO_OFFSET_1; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, D, DU, DU2, IPIV ); + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + data = POSITIVE_STRIDES_NO_OFFSET_2; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, D, DU, DU2, IPIV ); + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a non zero status code when a diagonal element is equal to zero', function test( t ) { + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + N = 3; + + DL = new Float64Array( [ 0.0, 0.0 ] ); + D = new Float64Array( [ 1.0, 1.0, 0.0 ] ); + DU = new Float64Array( [ 2.0, 3.0 ] ); + DU2 = new Float64Array( 1 ); + IPIV = new Int32Array( 3 ); + + info = dgttrf( N, DL, D, DU, DU2, IPIV ); + t.strictEqual( info, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = POSITIVE_STRIDES_NO_OFFSET_1; + + N = 0; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.DL ); + expectedD = new Float64Array( data.D ); + expectedDU = new Float64Array( data.DU ); + expectedDU2 = new Float64Array( data.DU2 ); + expectedIPIV = new Int32Array( data.IPIV ); + + info = dgttrf( N, DL, D, DU, DU2, IPIV ); + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.js new file mode 100644 index 000000000000..5824cbe780af --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dgttrf = 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 dgttrf, '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 dgttrf.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 dgttrf = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgttrf, 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 dgttrf; + var main; + + main = require( './../lib/dgttrf.js' ); + + dgttrf = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgttrf, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.ndarray.js new file mode 100644 index 000000000000..ab17cb04237a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.ndarray.js @@ -0,0 +1,435 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgttrf = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var POSITIVE_STRIDES_NO_OFFSET_1 = require( './fixtures/positive_stride_no_offset_1.json' ); // eslint-disable-line id-length +var POSITIVE_STRIDES_NO_OFFSET_2 = require( './fixtures/positive_stride_no_offset_2.json' ); // eslint-disable-line id-length +var LARGE_POSITIVE_STRIDE_1 = require( './fixtures/large_positive_stride_1.json' ); +var LARGE_POSITIVE_STRIDE_2 = require( './fixtures/large_positive_stride_2.json' ); +var NEGATIVE_STRIDES = require( './fixtures/negative_strides.json' ); +var MIXED_STRIDES = require( './fixtures/mixed_strides.json' ); +var POSITIVE_STRIDES_OFFSET_1 = require( './fixtures/positive_stride_offset_1.json' ); +var POSITIVE_STRIDES_OFFSET_2 = require( './fixtures/positive_stride_offset_2.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgttrf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 16', function test( t ) { + t.strictEqual( dgttrf.length, 16, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is less than zero', function test( t ) { + var values; + var data; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var i; + + data = POSITIVE_STRIDES_NO_OFFSET_1; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgttrf( value, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function performs the `LU` factorization of a real tri diagonal matrix `A` using elimination with partial pivoting and row interchanges', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = POSITIVE_STRIDES_NO_OFFSET_1; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + data = POSITIVE_STRIDES_NO_OFFSET_2; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing positive strides', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = LARGE_POSITIVE_STRIDE_1; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + data = LARGE_POSITIVE_STRIDE_2; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing negative strides', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = NEGATIVE_STRIDES; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing mixed strides', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var info; + var data; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = MIXED_STRIDES; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing index offsets', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = POSITIVE_STRIDES_OFFSET_1; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + data = POSITIVE_STRIDES_OFFSET_2; + + N = data.N; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedDU2 = new Float64Array( data.expectedDU2 ); + expectedIPIV = new Int32Array( data.expectedIPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) { + var expectedIPIV; + var expectedDU2; + var expectedDU; + var expectedDL; + var expectedD; + var data; + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + data = POSITIVE_STRIDES_NO_OFFSET_1; + + N = 0; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + DU2 = new Float64Array( data.DU2 ); + IPIV = new Int32Array( data.IPIV ); + + expectedDL = new Float64Array( data.DL ); + expectedD = new Float64Array( data.D ); + expectedDU = new Float64Array( data.DU ); + expectedDU2 = new Float64Array( data.DU2 ); + expectedIPIV = new Int32Array( data.IPIV ); + + info = dgttrf( N, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, DU2, data.sdu2, data.odu2, IPIV, data.si, data.oi ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( IPIV, expectedIPIV, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DU2, expectedDU2, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a non zero status code when a diagonal element is equal to zero', function test( t ) { + var info; + var IPIV; + var DU2; + var DU; + var DL; + var D; + var N; + + N = 3; + + DL = new Float64Array( [ 0.0, 0.0 ] ); + D = new Float64Array( [ 1.0, 1.0, 0.0 ] ); + DU = new Float64Array( [ 2.0, 3.0 ] ); + DU2 = new Float64Array( 1 ); + IPIV = new Int32Array( 3 ); + + info = dgttrf( N, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); + t.strictEqual( info, 2, 'returns expected value' ); + + t.end(); +});