diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/README.md b/lib/node_modules/@stdlib/lapack/base/dgtsv/README.md new file mode 100644 index 000000000000..0ae4eb0ba66a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/README.md @@ -0,0 +1,330 @@ + + +# dgtsv + +> Solve a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. + +
+ +The `dgtsv` routine solves a real system of linear equations + + + +```math +A X = B +``` + + + +where `A` is an `N`-by-`N` tridiagonal matrix, by Gaussian elimination with partial pivoting. Here, `B` and the solution `X` are `N`-by-`NRHS` matrices. + +For a 5-by-5 tridiagonal matrix `A`, elements are stored in three arrays: + + + +```math +A = \left[ +\begin{array}{rrrrr} + d_1 & du_1 & 0 & 0 & 0 \\ + dl_1 & d_2 & du_2 & 0 & 0 \\ + 0 & dl_2 & d_3 & du_3 & 0 \\ + 0 & 0 & dl_3 & d_4 & du_4 \\ + 0 & 0 & 0 & dl_4 & d_5 + \end{array} +\right] +``` + + + +where: + +- `dl` contains the subdiagonal elements. +- `d` contains the diagonal elements. +- `du` contains the superdiagonal elements. + +
+ + + +
+ +## Usage + +```javascript +var dgtsv = require( '@stdlib/lapack/base/dgtsv' ); +``` + +#### dgtsv( order, N, NRHS, DL, D, DU, B, LDB ) + +Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. + +```javascript +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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); + +/* + A = [ + [ 2.0, 1.0, 0.0 ], + [ 1.0, 3.0, 1.0 ], + [ 0.0, 1.0, 1.0 ] + ] +*/ + +dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); +// B => [ 1.0, 2.0, 3.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout of `B`. +- **N**: number of rows/columns in `A`. +- **NRHS**: number of right-hand sides (i.e., the number of columns in `B`). +- **DL**: the first sub-diagonal of `A` as a [`Float64Array`][mdn-float64array]. Should have `N-1` indexed elements. `DL` is overwritten by the `(N-2)` elements of the second super-diagonal of the upper triangular matrix `U` from the `LU` factorization of `A`. +- **D**: the diagonal of `A` as a [`Float64Array`][mdn-float64array]. Should have `N` indexed elements. `D` is overwritten by the `N` diagonal elements of `U`. +- **DU**: the first super-diagonal of `A` as a [`Float64Array`][mdn-float64array]. Should have `N-1` indexed elements. `DU` is overwritten by the `(N-1)` elements of the first super-diagonal of `U`. +- **B**: input matrix `B` having `N` rows and `NRHS` columns as a [`Float64Array`][mdn-float64array]. On exit, `B` is overwritten by the solution matrix `X`. +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var 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 B0 = new Float64Array( [ 0.0, 4.0, 10.0, 5.0 ] ); + +// 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 B = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); +// B0 => [ 0.0, 1.0, 2.0, 3.0 ] +``` + + + +#### dgtsv.ndarray( N, NRHS, DL, sdl, odl, D, sd, od, DU, sdu, odu, B, sb1, sb2, ob ) + +Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting and alternative indexing semantics. + +```javascript +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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); + +dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); +// B => [ 1.0, 2.0, 3.0 ] +``` + +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`. +- **sb1**: stride of the first dimension of `B`. +- **sb2**: stride of the second dimension of `B`. +- **ob**: starting index for `B`. + +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 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 B = new Float64Array( [ 0.0, 4.0, 10.0, 5.0 ] ); + +dgtsv.ndarray( 3, 1, DL, 1, 1, D, 1, 1, DU, 1, 1, B, 1, 3, 1 ); +// B => [ 0.0, 1.0, 2.0, 3.0 ] +``` + +
+ + + +
+ +## Notes + +- Both functions mutate the input arrays `DL`, `D`, `DU`, and `B`. On exit, `B` is overwritten by the solution matrix `X`. + +- Both functions return a status code indicating success or failure. The status code indicates the following conditions: + + - `0`: the solution was successfully computed. + - `>0`: `U(k, k)` is exactly zero, where `k` equals the status code value. The factorization has been completed, but the factor `U` is exactly singular, and the solution could not be computed. + +- `dgtsv()` corresponds to the [LAPACK][LAPACK] routine [`dgtsv`][lapack-dgtsv]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dgtsv = require( '@stdlib/lapack/base/dgtsv' ); + +var N = 5; + +var DL = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var D = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0 ] ); +var DU = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var B = new Float64Array( [ 5.0, 6.0, 6.0, 6.0, 5.0 ] ); + +/* + A = [ + [ 4.0, 1.0, 0.0, 0.0, 0.0 ], + [ 1.0, 4.0, 1.0, 0.0, 0.0 ], + [ 0.0, 1.0, 4.0, 1.0, 0.0 ], + [ 0.0, 0.0, 1.0, 4.0, 1.0 ], + [ 0.0, 0.0, 0.0, 1.0, 4.0 ] + ] +*/ + +// Solve `A*X = B` for `X`: +var info = dgtsv( 'column-major', N, 1, DL, D, DU, B, N ); + +console.log( B ); +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/dgtsv/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/benchmark/benchmark.js new file mode 100644 index 000000000000..6e33f7eb287e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgtsv = require( './../lib/dgtsv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - order of the matrix `A` +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var DL = uniform( len-1, 0.0, 100.0, options ); + var DU = uniform( len-1, 0.0, 100.0, options ); + var D = uniform( len, 100.0, 200.0, options ); + var B = uniform( len, 0.0, 100.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dgtsv( 'column-major', len, 1, DL, D, DU, B, len ); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + } + b.toc(); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + 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( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..1cfb5a2507ae --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dgtsv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - order of the matrix `A` +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var DL = uniform( len-1, 0.0, 100.0, options ); + var DU = uniform( len-1, 0.0, 100.0, options ); + var D = uniform( len, 100.0, 200.0, options ); + var B = uniform( len, 0.0, 100.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dgtsv( len, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, len, 0 ); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + } + b.toc(); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + 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( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/repl.txt new file mode 100644 index 000000000000..5411491394eb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/repl.txt @@ -0,0 +1,143 @@ + +{{alias}}( order, N, NRHS, DL, D, DU, B, LDB ) + Solves a system of linear equations `A * X = B`, where `A` is an N-by-N + tridiagonal matrix, using Gaussian elimination with partial pivoting. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The function mutates `DL`, `D`, `DU`, and `B`. On exit, `B` is overwritten + by the solution matrix `X`. + + Parameters + ---------- + order: string + Storage layout of `B`. + + N: integer + Number of rows/columns in `A`. + + NRHS: integer + Number of right-hand sides (i.e., the number of columns in `B`). + + DL: Float64Array + The first sub-diagonal of `A`. Should have `N-1` indexed elements. + + D: Float64Array + The diagonal of `A`. Should have `N` indexed elements. + + DU: Float64Array + The first super-diagonal of `A`. Should have `N-1` indexed elements. + + B: Float64Array + Input matrix `B` having `N` rows and `NRHS` columns. + + LDB: integer + Stride of the first dimension of `B` (a.k.a., leading dimension of the + matrix `B`). + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the solution was successfully computed. + - if greater than zero, then `U(k, k)` is exactly zero, where `k` equals + the status code value. The factorization has been completed, but the + factor `U` is exactly singular, and the solution could not be computed. + + 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 B = new {{alias:@stdlib/array/float64}}( [ 4.0, 10.0, 5.0 ] ); + > {{alias}}( 'column-major', 3, 1, DL, D, DU, B, 3 ) + 0 + > B + [ 1.0, 2.0, 3.0 ] + + +{{alias}}.ndarray(N, NRHS, DL,sdl,odl, D,sd,od, DU,sdu,odu, B,sb1,sb2,ob) + Solves a system of linear equations `A * X = B`, where `A` is an N-by-N + tridiagonal matrix, using Gaussian elimination with partial pivoting 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`, and `B`. On exit, `B` is overwritten + by the solution matrix `X`. + + Parameters + ---------- + N: integer + Number of rows/columns in `A`. + + NRHS: integer + Number of right-hand sides (i.e., the number of columns in `B`). + + DL: Float64Array + The first sub-diagonal of `A`. Should have `N-1` indexed elements. + + sdl: integer + Stride length for `DL`. + + odl: integer + Starting index for `DL`. + + D: Float64Array + The diagonal of `A`. Should have `N` indexed elements. + + sd: integer + Stride length for `D`. + + od: integer + Starting index for `D`. + + DU: Float64Array + The first super-diagonal of `A`. Should have `N-1` indexed elements. + + sdu: integer + Stride length for `DU`. + + odu: integer + Starting index for `DU`. + + B: Float64Array + Input matrix `B` having `N` rows and `NRHS` columns. + + sb1: integer + Stride of the first dimension of `B`. + + sb2: integer + Stride of the second dimension of `B`. + + ob: integer + Starting index for `B`. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the solution was successfully computed. + - if greater than zero, then `U(k, k)` is exactly zero, where `k` equals + the status code value. The factorization has been completed, but the + factor `U` is exactly singular, and the solution could not be computed. + + 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 B = new {{alias:@stdlib/array/float64}}( [ 4.0, 10.0, 5.0 ] ); + > {{alias}}.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ) + 0 + > B + [ 1.0, 2.0, 3.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/types/index.d.ts new file mode 100644 index 000000000000..fb4614bcc575 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/types/index.d.ts @@ -0,0 +1,148 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Status code. +* +* ## Notes +* +* The status code indicates the following conditions: +* +* - if equal to zero, then the solution was successfully computed. +* - if greater than zero, then `U(k, k)` is exactly zero, where `k` equals the status code value. The factorization has been completed, but the factor `U` is exactly singular, and the solution could not be computed. +*/ +type StatusCode = number; + +/** +* Interface describing `dgtsv`. +*/ +interface Routine { + /** + * Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. + * + * @param order - storage layout of `B` + * @param N - number of rows/columns in `A` + * @param NRHS - number of right-hand sides (i.e., number of columns in `B`) + * @param DL - the first sub-diagonal of `A` + * @param D - the diagonal of `A` + * @param DU - the first super-diagonal of `A` + * @param B - input matrix + * @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) + * @returns 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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); + * + * dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); + * // B => [ 1.0, 2.0, 3.0 ] + */ + ( order: Layout, N: number, NRHS: number, DL: Float64Array, D: Float64Array, DU: Float64Array, B: Float64Array, LDB: number ): StatusCode; + + /** + * Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting and alternative indexing semantics. + * + * ## Notes + * + * - `DL` should have `N-1` indexed elements and is overwritten by the `(N-2)` elements of the second super-diagonal of the upper triangular matrix `U` from the `LU` factorization of `A`. + * - `D` should have `N` indexed elements and is overwritten by the `N` diagonal elements of `U`. + * - `DU` should have `N-1` indexed elements and is overwritten by the `(N-1)` elements of the first super-diagonal of `U`. + * - `B` is an `N`-by-`NRHS` matrix and is overwritten by the solution matrix `X`. + * + * @param N - number of rows/columns in `A` + * @param NRHS - number of right-hand sides (i.e., number of columns in `B`) + * @param DL - the first sub-diagonal of `A` + * @param strideDL - stride length for `DL` + * @param offsetDL - starting index for `DL` + * @param D - the diagonal of `A` + * @param strideD - stride length for `D` + * @param offsetD - starting index for `D` + * @param DU - the first super-diagonal of `A` + * @param strideDU - stride length for `DU` + * @param offsetDU - starting index for `DU` + * @param B - input matrix + * @param strideB1 - stride of the first dimension of `B` + * @param strideB2 - stride of the second dimension of `B` + * @param offsetB - starting index for `B` + * @returns 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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); + * + * dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); + * // B => [ 1.0, 2.0, 3.0 ] + */ + ndarray( N: number, NRHS: number, DL: Float64Array, strideDL: number, offsetDL: number, D: Float64Array, strideD: number, offsetD: number, DU: Float64Array, strideDU: number, offsetDU: number, B: Float64Array, strideB1: number, strideB2: number, offsetB: number ): StatusCode; +} + +/** +* Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. +* +* @param order - storage layout of `B` +* @param N - number of rows/columns in `A` +* @param NRHS - number of right-hand sides (i.e., number of columns in `B`) +* @param DL - the first sub-diagonal of `A` +* @param D - the diagonal of `A` +* @param DU - the first super-diagonal of `A` +* @param B - input matrix +* @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @returns 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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); +* // B => [ 1.0, 2.0, 3.0 ] +* +* @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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); +* // B => [ 1.0, 2.0, 3.0 ] +*/ +declare var dgtsv: Routine; + + +// EXPORTS // + +export = dgtsv; diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/types/test.ts new file mode 100644 index 000000000000..e4a18c45da3d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/docs/types/test.ts @@ -0,0 +1,476 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dgtsv = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a valid order... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv( 5, 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( true, 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( false, 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( null, 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( void 0, 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( [], 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( {}, 3, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( ( x: number ): number => x, 3, 1, DL, D, DU, B, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv( 'column-major', '5', 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', true, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', false, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', null, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', void 0, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', [], 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', {}, 1, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', ( x: number ): number => x, 1, DL, D, DU, B, 3 ); // $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 B = new Float64Array( 3 ); + + dgtsv( 'column-major', 3, '5', DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, true, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, false, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, null, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, void 0, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, [], DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, {}, DL, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, ( x: number ): number => x, DL, D, DU, B, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv( 'column-major', 3, 1, '5', D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, 5, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, true, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, false, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, null, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, void 0, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, [], D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, {}, D, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, ( x: number ): number => x, D, DU, B, 3 ); // $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 B = new Float64Array( 3 ); + + dgtsv( 'column-major', 3, 1, DL, '5', DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, 5, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, true, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, false, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, null, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, void 0, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, [], DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, {}, DU, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, ( x: number ): number => x, DU, B, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const B = new Float64Array( 3 ); + + dgtsv( 'column-major', 3, 1, DL, D, '5', B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, 5, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, true, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, false, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, null, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, void 0, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, [], B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, {}, B, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, ( x: number ): number => x, B, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + + dgtsv( 'column-major', 3, 1, DL, D, DU, '5', 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, 5, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, true, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, false, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, null, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, void 0, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, [], 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, {}, 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, ( x: number ): number => x, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv( 'column-major', 3, 1, DL, D, DU, B, '5' ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, true ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, false ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, null ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, void 0 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, [] ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, {} ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, ( 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 B = new Float64Array( 3 ); + + dgtsv(); // $ExpectError + dgtsv( 'column-major' ); // $ExpectError + dgtsv( 'column-major', 3 ); // $ExpectError + dgtsv( 'column-major', 3, 1 ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B ); // $ExpectError + dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3, 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( '5', 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( true, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( false, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( null, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( void 0, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( [], 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( {}, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( ( x: number ): number => x, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, '5', DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, true, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, false, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, null, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, void 0, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, [], DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, {}, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, ( x: number ): number => x, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... +{ + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, '5', 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, 5, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, true, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, false, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, null, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, void 0, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, [], 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, {}, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, ( x: number ): number => x, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, '5', 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, true, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, false, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, null, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, void 0, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, [], 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, {}, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, ( x: number ): number => x, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, '5', D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, true, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, false, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, null, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, void 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, [], D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, {}, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, ( x: number ): number => x, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, '5', 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, 5, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, true, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, false, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, null, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, void 0, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, [], 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, {}, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, ( x: number ): number => x, 1, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, '5', 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, true, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, false, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, null, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, void 0, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, [], 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, {}, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, ( x: number ): number => x, 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, '5', DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, true, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, false, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, null, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, void 0, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, [], DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, {}, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, ( x: number ): number => x, DU, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, '5', 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, 5, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, true, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, false, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, null, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, void 0, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, [], 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, {}, 1, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, ( x: number ): number => x, 1, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, '5', 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, true, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, false, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, null, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, void 0, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, [], 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, {}, 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, ( x: number ): number => x, 0, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, '5', B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, true, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, false, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, null, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, void 0, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, [], B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, {}, B, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, ( x: number ): number => x, B, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a Float64Array... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, '5', 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, 5, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, true, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, false, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, null, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, void 0, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, [], 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, {}, 1, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, ( x: number ): number => x, 1, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, '5', 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, true, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, false, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, null, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, void 0, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, [], 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, {}, 3, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, ( x: number ): number => x, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourteenth argument which is not a number... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, '5', 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, true, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, false, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, null, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, void 0, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, [], 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, {}, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method 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 B = new Float64Array( 3 ); + + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, '5' ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, true ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, false ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, null ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, void 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, [] ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, {} ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const DL = new Float64Array( 2 ); + const D = new Float64Array( 3 ); + const DU = new Float64Array( 2 ); + const B = new Float64Array( 3 ); + + dgtsv.ndarray(); // $ExpectError + dgtsv.ndarray( 3 ); // $ExpectError + dgtsv.ndarray( 3, 1 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3 ); // $ExpectError + dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/examples/index.js new file mode 100644 index 000000000000..a945e1a9eecc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/examples/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dgtsv = require( './../lib' ); + +var N = 5; + +var DL = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var D = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0 ] ); +var DU = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var B = new Float64Array( [ 5.0, 6.0, 6.0, 6.0, 5.0 ] ); + +/* + A = [ + [ 4.0, 1.0, 0.0, 0.0, 0.0 ], + [ 1.0, 4.0, 1.0, 0.0, 0.0 ], + [ 0.0, 1.0, 4.0, 1.0, 0.0 ], + [ 0.0, 0.0, 1.0, 4.0, 1.0 ], + [ 0.0, 0.0, 0.0, 1.0, 4.0 ] + ] +*/ + +// Solve `A*X = B` for `X`: +var info = dgtsv( 'column-major', N, 1, DL, D, DU, B, N ); + +console.log( B ); +console.log( info ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/base.js new file mode 100644 index 000000000000..5398a53132a0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/base.js @@ -0,0 +1,215 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var abs = require( '@stdlib/math/base/special/abs' ); + + +// FUNCTIONS // + +/** +* Eliminates a row across all right-hand sides (i.e., `B[iy] -= fact * B[ix]`). +* +* @private +* @param {Float64Array} B - input matrix +* @param {integer} ix - index of the row to subtract +* @param {integer} iy - index of the row to update +* @param {integer} stride - stride between columns of `B` +* @param {NonNegativeInteger} NRHS - number of right-hand sides +* @param {number} fact - elimination multiplier +*/ +function eliminate( B, ix, iy, stride, NRHS, fact ) { + var j; + for ( j = 0; j < NRHS; j++ ) { + B[ iy ] -= fact * B[ ix ]; + ix += stride; + iy += stride; + } +} + +/** +* Interchanges two rows across all right-hand sides and eliminates the second row. +* +* @private +* @param {Float64Array} B - input matrix +* @param {integer} ix - index of the first row +* @param {integer} iy - index of the second row +* @param {integer} stride - stride between columns of `B` +* @param {NonNegativeInteger} NRHS - number of right-hand sides +* @param {number} fact - elimination multiplier +*/ +function interchange( B, ix, iy, stride, NRHS, fact ) { + var temp; + var j; + for ( j = 0; j < NRHS; j++ ) { + temp = B[ ix ]; + B[ ix ] = B[ iy ]; + B[ iy ] = temp - ( fact*B[ iy ] ); + ix += stride; + iy += stride; + } +} + + +// MAIN // + +/** +* Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. +* +* @private +* @param {NonNegativeInteger} N - number of rows/columns in `A` +* @param {NonNegativeInteger} NRHS - number of right-hand sides (i.e., number of columns in `B`) +* @param {Float64Array} DL - the first sub-diagonal of `A` +* @param {integer} strideDL - stride length for `DL` +* @param {NonNegativeInteger} offsetDL - starting index for `DL` +* @param {Float64Array} D - the diagonal of `A` +* @param {integer} strideD - stride length for `D` +* @param {NonNegativeInteger} offsetD - starting index for `D` +* @param {Float64Array} DU - the first super-diagonal of `A` +* @param {integer} strideDU - stride length for `DU` +* @param {NonNegativeInteger} offsetDU - starting index for `DU` +* @param {Float64Array} B - input matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); +* // B => [ 1.0, 2.0, 3.0 ] +*/ +function dgtsv( N, NRHS, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, offsetDU, B, strideB1, strideB2, offsetB ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point, max-len, max-params + var dun1; + var fact; + var temp; + var dn1; + var idl; + var idu; + var ib1; + var ib2; + var ibr; + var dn; + var id; + var ib; + var i; + var j; + + if ( N === 0 ) { + return 0; + } + idl = offsetDL; + id = offsetD; + idu = offsetDU; + ibr = offsetB; + + // Forward elimination over the first `N-2` rows... + for ( i = 0; i < N-2; i++ ) { + if ( abs( D[ id ] ) >= abs( DL[ idl ] ) ) { + // No row interchange required... + if ( D[ id ] === 0.0 ) { + return i + 1; + } + fact = DL[ idl ] / D[ id ]; + D[ id+strideD ] -= fact * DU[ idu ]; + eliminate( B, ibr, ibr+strideB1, strideB2, NRHS, fact ); + DL[ idl ] = 0.0; + } else { + // Interchange rows `i` and `i+1` and store the fill-in in `DL`... + fact = D[ id ] / DL[ idl ]; + D[ id ] = DL[ idl ]; + temp = D[ id+strideD ]; + D[ id+strideD ] = DU[ idu ] - ( fact*temp ); + DL[ idl ] = DU[ idu+strideDU ]; + DU[ idu+strideDU ] = -fact * DL[ idl ]; + DU[ idu ] = temp; + interchange( B, ibr, ibr+strideB1, strideB2, NRHS, fact ); + } + idl += strideDL; + id += strideD; + idu += strideDU; + ibr += strideB1; + } + // Perform the final elimination step for the last two rows... + if ( N > 1 ) { + if ( abs( D[ id ] ) >= abs( DL[ idl ] ) ) { + if ( D[ id ] === 0.0 ) { + return i + 1; + } + fact = DL[ idl ] / D[ id ]; + D[ id+strideD ] -= fact * DU[ idu ]; + eliminate( B, ibr, ibr+strideB1, strideB2, NRHS, fact ); + } else { + fact = D[ id ] / DL[ idl ]; + D[ id ] = DL[ idl ]; + temp = D[ id+strideD ]; + D[ id+strideD ] = DU[ idu ] - ( fact*temp ); + DU[ idu ] = temp; + interchange( B, ibr, ibr+strideB1, strideB2, NRHS, fact ); + } + } + // Check for a zero pivot in the last diagonal element of `U`... + dn = D[ offsetD+( (N-1)*strideD ) ]; + if ( dn === 0.0 ) { + return N; + } + // Back substitution with the upper triangular matrix `U`... + if ( N > 1 ) { + dn1 = D[ offsetD+( (N-2)*strideD ) ]; + dun1 = DU[ offsetDU+( (N-2)*strideDU ) ]; + } + for ( j = 0; j < NRHS; j++ ) { + ibr = offsetB + ( j*strideB2 ); + ib = ibr + ( (N-1)*strideB1 ); + B[ ib ] /= dn; + if ( N > 1 ) { + ib1 = ib - strideB1; + B[ ib1 ] = ( B[ ib1 ]-( dun1*B[ ib ] ) ) / dn1; + } + id = offsetD + ( (N-3)*strideD ); + idl = offsetDL + ( (N-3)*strideDL ); + idu = offsetDU + ( (N-3)*strideDU ); + ib = ibr + ( (N-3)*strideB1 ); + ib1 = ib + strideB1; + ib2 = ib + ( 2*strideB1 ); + for ( i = N-3; i >= 0; i-- ) { + B[ ib ] = ( B[ ib ]-( DU[ idu ]*B[ ib1 ] )-( DL[ idl ]*B[ ib2 ] ) ) / D[ id ]; // eslint-disable-line max-len + id -= strideD; + idl -= strideDL; + idu -= strideDU; + ib -= strideB1; + ib1 -= strideB1; + ib2 -= strideB1; + } + } + return 0; +} + + +// EXPORTS // + +module.exports = dgtsv; diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/dgtsv.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/dgtsv.js new file mode 100644 index 000000000000..3428872456f6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/dgtsv.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. +* +* @param {string} order - storage layout of `B` +* @param {NonNegativeInteger} N - number of rows/columns in `A` +* @param {NonNegativeInteger} NRHS - number of right-hand sides (i.e., number of columns in `B`) +* @param {Float64Array} DL - the first sub-diagonal of `A` +* @param {Float64Array} D - the diagonal of `A` +* @param {Float64Array} DU - the first super-diagonal of `A` +* @param {Float64Array} B - input matrix +* @param {integer} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} eighth argument must be greater than or equal to max(1,N) +* @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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); +* // B => [ 1.0, 2.0, 3.0 ] +*/ +function dgtsv( order, N, NRHS, DL, D, DU, B, LDB ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point + var sb1; + var sb2; + var s; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( NRHS < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', NRHS ) ); + } + if ( isColumnMajor( order ) ) { + s = N; + } else { + s = NRHS; + } + if ( LDB < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDB ) ); + } + if ( isColumnMajor( order ) ) { + sb1 = 1; + sb2 = LDB; + } else { // order === 'row-major' + sb1 = LDB; + sb2 = 1; + } + return base( N, NRHS, DL, 1, 0, D, 1, 0, DU, 1, 0, B, sb1, sb2, 0 ); +} + + +// EXPORTS // + +module.exports = dgtsv; diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/index.js new file mode 100644 index 000000000000..f3303e7057a3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/index.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to solve a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting. +* +* @module @stdlib/lapack/base/dgtsv +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dgtsv = require( '@stdlib/lapack/base/dgtsv' ); +* +* 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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv( 'column-major', 3, 1, DL, D, DU, B, 3 ); +* // B => [ 1.0, 2.0, 3.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dgtsv = require( '@stdlib/lapack/base/dgtsv' ); +* +* 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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv.ndarray( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); +* // B => [ 1.0, 2.0, 3.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dgtsv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgtsv = main; +} else { + dgtsv = tmp; +} + + +// EXPORTS // + +module.exports = dgtsv; + +// exports: { "ndarray": "dgtsv.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/main.js new file mode 100644 index 000000000000..da1c52c62921 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dgtsv = require( './dgtsv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgtsv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgtsv; diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/ndarray.js new file mode 100644 index 000000000000..da68225aea42 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/lib/ndarray.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Solves a system of linear equations `A * X = B`, where `A` is an `N`-by-`N` tridiagonal matrix, using Gaussian elimination with partial pivoting and alternative indexing semantics. +* +* @param {NonNegativeInteger} N - number of rows/columns in `A` +* @param {NonNegativeInteger} NRHS - number of right-hand sides (i.e., number of columns in `B`) +* @param {Float64Array} DL - the first sub-diagonal of `A` +* @param {integer} strideDL - stride length for `DL` +* @param {NonNegativeInteger} offsetDL - starting index for `DL` +* @param {Float64Array} D - the diagonal of `A` +* @param {integer} strideD - stride length for `D` +* @param {NonNegativeInteger} offsetD - starting index for `D` +* @param {Float64Array} DU - the first super-diagonal of `A` +* @param {integer} strideDU - stride length for `DU` +* @param {NonNegativeInteger} offsetDU - starting index for `DU` +* @param {Float64Array} B - input matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @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 B = new Float64Array( [ 4.0, 10.0, 5.0 ] ); +* +* dgtsv( 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, B, 1, 3, 0 ); +* // B => [ 1.0, 2.0, 3.0 ] +*/ +function dgtsv( N, NRHS, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, offsetDU, B, strideB1, strideB2, offsetB ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point, max-len, max-params + return base( N, NRHS, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, offsetDU, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgtsv; diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/package.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/package.json new file mode 100644 index 000000000000..53d1203ddb1b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/lapack/base/dgtsv", + "version": "0.0.0", + "description": "Solve a system of linear equations using an LU factorization of a tridiagonal matrix with partial pivoting", + "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", + "dgtsv", + "solve", + "linear", + "system", + "tridiagonal", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major.json new file mode 100644 index 000000000000..baad8f0f89b4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 1, + "LDB": 3, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4 ], + [ 10 ], + [ 5 ] + ], + "DL": [ 1, 1 ], + "sdl": 1, + "odl": 0, + "D": [ 2, 3, 1 ], + "sd": 1, + "od": 0, + "DU": [ 1, 1 ], + "sdu": 1, + "odu": 0, + "B": [ 4, 10, 5 ], + "sb1": 1, + "sb2": 3, + "ob": 0, + "expectedDL": [ 0, 1 ], + "expectedD": [ 2, 2.5, 0.6 ], + "expectedDU": [ 1, 1 ], + "expectedB": [ 1, 2, 3 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_multiple_rhs.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_multiple_rhs.json new file mode 100644 index 000000000000..85cc95f05c0e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_multiple_rhs.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + "N": 4, + "NRHS": 3, + "LDB": 4, + "A": [ + [ 4, 1, 0, 0 ], + [ 2, 5, 1, 0 ], + [ 0, 3, 6, 2 ], + [ 0, 0, 1, 7 ] + ], + "Bmat": [ + [ 1, 6, 0 ], + [ 2, 5, 1 ], + [ 3, 4, 2 ], + [ 4, 3, 3 ] + ], + "DL": [ 2, 3, 1 ], + "sdl": 1, + "odl": 0, + "D": [ 4, 5, 6, 7 ], + "sd": 1, + "od": 0, + "DU": [ 1, 1, 2 ], + "sdu": 1, + "odu": 0, + "B": [ 1, 2, 3, 4, 6, 5, 4, 3, 0, 1, 2, 3 ], + "sb1": 1, + "sb2": 4, + "ob": 0, + "expectedDL": [ 0, 0, 1 ], + "expectedD": [ 4, 4.5, 5.333333333333333, 6.625 ], + "expectedDU": [ 1, 1, 2 ], + "expectedB": [ 0.17610062893081763, 0.29559748427672955, 0.169811320754717, 0.5471698113207547, 1.4088050314465408, 0.36477987421383645, 0.35849056603773594, 0.37735849056603776, -0.050314465408805034, 0.20125786163522014, 0.09433962264150945, 0.41509433962264153 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_offset.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_offset.json new file mode 100644 index 000000000000..19390ee2faf0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_offset.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 1, + "LDB": 3, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4 ], + [ 10 ], + [ 5 ] + ], + "DL": [ 0, 0, 1, 1 ], + "sdl": 1, + "odl": 2, + "D": [ 0, 2, 3, 1 ], + "sd": 1, + "od": 1, + "DU": [ 0, 0, 0, 1, 1 ], + "sdu": 1, + "odu": 3, + "B": [ 0, 0, 4, 10, 5 ], + "sb1": 1, + "sb2": 3, + "ob": 2, + "expectedDL": [ 0, 0, 0, 1 ], + "expectedD": [ 0, 2, 2.5, 0.6 ], + "expectedDU": [ 0, 0, 0, 1, 1 ], + "expectedB": [ 0, 0, 1, 2, 3 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_pivoting.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_pivoting.json new file mode 100644 index 000000000000..4b89e9d30825 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/column_major_pivoting.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 2, + "LDB": 3, + "A": [ + [ 1, 3, 0 ], + [ 2, 1, 4 ], + [ 0, 2, 1 ] + ], + "Bmat": [ + [ 7, 1 ], + [ 8, 2 ], + [ 3, 3 ] + ], + "DL": [ 2, 2 ], + "sdl": 1, + "odl": 0, + "D": [ 1, 1, 1 ], + "sd": 1, + "od": 0, + "DU": [ 3, 4 ], + "sdu": 1, + "odu": 0, + "B": [ 7, 8, 3, 1, 2, 3 ], + "sb1": 1, + "sb2": 3, + "ob": 0, + "expectedDL": [ 4, 2 ], + "expectedD": [ 2, 2.5, 2.6 ], + "expectedDU": [ 1, -2 ], + "expectedB": [ 2.8461538461538463, 1.3846153846153846, 0.23076923076923062, -1.769230769230769, 0.923076923076923, 1.1538461538461537 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/large_strides.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/large_strides.json new file mode 100644 index 000000000000..d5220ca3da00 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/large_strides.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 2, + "LDB": 3, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4, 1 ], + [ 10, 2 ], + [ 5, 3 ] + ], + "DL": [ 1, 0, 1 ], + "sdl": 2, + "odl": 0, + "D": [ 2, 0, 0, 3, 0, 0, 1 ], + "sd": 3, + "od": 0, + "DU": [ 0, 1, 0, 1 ], + "sdu": 2, + "odu": 1, + "B": [ 4, 0, 10, 0, 5, 0, 0, 1, 0, 2, 0, 3 ], + "sb1": 2, + "sb2": 7, + "ob": 0, + "expectedDL": [ 0, 0, 1 ], + "expectedD": [ 2, 0, 0, 2.5, 0, 0, 0.6 ], + "expectedDU": [ 0, 1, 0, 1 ], + "expectedB": [ 1, 0, 2, 0, 3, 0, 0, 1, 0, -1, 0, 4 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/mixed_strides.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/mixed_strides.json new file mode 100644 index 000000000000..c0e84e25fc68 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/mixed_strides.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 2, + "LDB": 3, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4, 1 ], + [ 10, 2 ], + [ 5, 3 ] + ], + "DL": [ 0, 1, 0, 1 ], + "sdl": -2, + "odl": 3, + "D": [ 0, 2, 0, 3, 0, 1 ], + "sd": 2, + "od": 1, + "DU": [ 0, 1, 1 ], + "sdu": -1, + "odu": 2, + "B": [ 1, 0, 2, 0, 3, 0, 0, 4, 0, 10, 0, 5 ], + "sb1": 2, + "sb2": -7, + "ob": 7, + "expectedDL": [ 0, 1, 0, 0 ], + "expectedD": [ 0, 2, 0, 2.5, 0, 0.6 ], + "expectedDU": [ 0, 1, 1 ], + "expectedB": [ 1, 0, -1, 0, 4, 0, 0, 1, 0, 2, 0, 3 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/negative_strides.json new file mode 100644 index 000000000000..8a1b55cd9e53 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/negative_strides.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 2, + "LDB": 3, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4, 1 ], + [ 10, 2 ], + [ 5, 3 ] + ], + "DL": [ 1, 1 ], + "sdl": -1, + "odl": 1, + "D": [ 1, 3, 2 ], + "sd": -1, + "od": 2, + "DU": [ 1, 1 ], + "sdu": -1, + "odu": 1, + "B": [ 0, 0, 0, 3, 2, 1, 5, 10, 4 ], + "sb1": -1, + "sb2": -3, + "ob": 8, + "expectedDL": [ 1, 0 ], + "expectedD": [ 0.6, 2.5, 2 ], + "expectedDU": [ 1, 1 ], + "expectedB": [ 0, 0, 0, 4, -1, 1, 3, 2, 1 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/pivoting_last.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/pivoting_last.json new file mode 100644 index 000000000000..a944a8085a0d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/pivoting_last.json @@ -0,0 +1,32 @@ +{ + "order": "column-major", + "N": 2, + "NRHS": 1, + "LDB": 2, + "A": [ + [ 1, 2 ], + [ 3, 5 ] + ], + "Bmat": [ + [ 5 ], + [ 13 ] + ], + "DL": [ 3 ], + "sdl": 1, + "odl": 0, + "D": [ 1, 5 ], + "sd": 1, + "od": 0, + "DU": [ 2 ], + "sdu": 1, + "odu": 0, + "B": [ 5, 13 ], + "sb1": 1, + "sb2": 2, + "ob": 0, + "expectedDL": [ 3 ], + "expectedD": [ 3, 0.3333333333333335 ], + "expectedDU": [ 5 ], + "expectedB": [ 1, 2 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major.json new file mode 100644 index 000000000000..f0041a4d644e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major.json @@ -0,0 +1,34 @@ +{ + "order": "row-major", + "N": 3, + "NRHS": 1, + "LDB": 1, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4 ], + [ 10 ], + [ 5 ] + ], + "DL": [ 1, 1 ], + "sdl": 1, + "odl": 0, + "D": [ 2, 3, 1 ], + "sd": 1, + "od": 0, + "DU": [ 1, 1 ], + "sdu": 1, + "odu": 0, + "B": [ 4, 10, 5 ], + "sb1": 1, + "sb2": 1, + "ob": 0, + "expectedDL": [ 0, 1 ], + "expectedD": [ 2, 2.5, 0.6 ], + "expectedDU": [ 1, 1 ], + "expectedB": [ 1, 2, 3 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major_multiple_rhs.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major_multiple_rhs.json new file mode 100644 index 000000000000..e0f9913b9374 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major_multiple_rhs.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + "N": 4, + "NRHS": 3, + "LDB": 3, + "A": [ + [ 4, 1, 0, 0 ], + [ 2, 5, 1, 0 ], + [ 0, 3, 6, 2 ], + [ 0, 0, 1, 7 ] + ], + "Bmat": [ + [ 1, 6, 0 ], + [ 2, 5, 1 ], + [ 3, 4, 2 ], + [ 4, 3, 3 ] + ], + "DL": [ 2, 3, 1 ], + "sdl": 1, + "odl": 0, + "D": [ 4, 5, 6, 7 ], + "sd": 1, + "od": 0, + "DU": [ 1, 1, 2 ], + "sdu": 1, + "odu": 0, + "B": [ 1, 6, 0, 2, 5, 1, 3, 4, 2, 4, 3, 3 ], + "sb1": 3, + "sb2": 1, + "ob": 0, + "expectedDL": [ 0, 0, 1 ], + "expectedD": [ 4, 4.5, 5.333333333333333, 6.625 ], + "expectedDU": [ 1, 1, 2 ], + "expectedB": [ 0.17610062893081763, 1.4088050314465408, -0.050314465408805034, 0.29559748427672955, 0.36477987421383645, 0.20125786163522014, 0.169811320754717, 0.35849056603773594, 0.09433962264150945, 0.5471698113207547, 0.37735849056603776, 0.41509433962264153 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major_offset.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major_offset.json new file mode 100644 index 000000000000..8ce79bc902c5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/row_major_offset.json @@ -0,0 +1,34 @@ +{ + "order": "row-major", + "N": 3, + "NRHS": 1, + "LDB": 1, + "A": [ + [ 2, 1, 0 ], + [ 1, 3, 1 ], + [ 0, 1, 1 ] + ], + "Bmat": [ + [ 4 ], + [ 10 ], + [ 5 ] + ], + "DL": [ 0, 0, 1, 1 ], + "sdl": 1, + "odl": 2, + "D": [ 0, 2, 3, 1 ], + "sd": 1, + "od": 1, + "DU": [ 0, 0, 0, 1, 1 ], + "sdu": 1, + "odu": 3, + "B": [ 0, 0, 4, 10, 5 ], + "sb1": 1, + "sb2": 1, + "ob": 2, + "expectedDL": [ 0, 0, 0, 1 ], + "expectedD": [ 0, 2, 2.5, 0.6 ], + "expectedDU": [ 0, 0, 0, 1, 1 ], + "expectedB": [ 0, 0, 1, 2, 3 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/single_row.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/single_row.json new file mode 100644 index 000000000000..51f793671cd9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/single_row.json @@ -0,0 +1,30 @@ +{ + "order": "column-major", + "N": 1, + "NRHS": 1, + "LDB": 1, + "A": [ + [ 2 ] + ], + "Bmat": [ + [ 4 ] + ], + "DL": [], + "sdl": 1, + "odl": 0, + "D": [ 2 ], + "sd": 1, + "od": 0, + "DU": [], + "sdu": 1, + "odu": 0, + "B": [ 4 ], + "sb1": 1, + "sb2": 1, + "ob": 0, + "expectedDL": [], + "expectedD": [ 2 ], + "expectedDU": [], + "expectedB": [ 2 ], + "expectedInfo": 0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular.json new file mode 100644 index 000000000000..353bd49ce319 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular.json @@ -0,0 +1,34 @@ +{ + "order": "column-major", + "N": 3, + "NRHS": 1, + "LDB": 3, + "A": [ + [ 1, 2, 0 ], + [ 0, 1, 3 ], + [ 0, 0, 0 ] + ], + "Bmat": [ + [ 1 ], + [ 2 ], + [ 3 ] + ], + "DL": [ 0, 0 ], + "sdl": 1, + "odl": 0, + "D": [ 1, 1, 0 ], + "sd": 1, + "od": 0, + "DU": [ 2, 3 ], + "sdu": 1, + "odu": 0, + "B": [ 1, 2, 3 ], + "sb1": 1, + "sb2": 3, + "ob": 0, + "expectedDL": [ 0, 0 ], + "expectedD": [ 1, 1, 0 ], + "expectedDU": [ 2, 3 ], + "expectedB": [ 1, 2, 3 ], + "expectedInfo": 3 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular_last.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular_last.json new file mode 100644 index 000000000000..16301207d61c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular_last.json @@ -0,0 +1,32 @@ +{ + "order": "column-major", + "N": 2, + "NRHS": 1, + "LDB": 2, + "A": [ + [ 0, 2 ], + [ 0, 5 ] + ], + "Bmat": [ + [ 1 ], + [ 2 ] + ], + "DL": [ 0 ], + "sdl": 1, + "odl": 0, + "D": [ 0, 5 ], + "sd": 1, + "od": 0, + "DU": [ 2 ], + "sdu": 1, + "odu": 0, + "B": [ 1, 2 ], + "sb1": 1, + "sb2": 2, + "ob": 0, + "expectedDL": [ 0 ], + "expectedD": [ 0, 5 ], + "expectedDU": [ 2 ], + "expectedB": [ 1, 2 ], + "expectedInfo": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular_mid.json b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular_mid.json new file mode 100644 index 000000000000..a6aba0ccbf62 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/fixtures/singular_mid.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + "N": 4, + "NRHS": 1, + "LDB": 4, + "A": [ + [ 1, 2, 0, 0 ], + [ 0, 0, 3, 0 ], + [ 0, 0, 1, 4 ], + [ 0, 0, 0, 1 ] + ], + "Bmat": [ + [ 1 ], + [ 2 ], + [ 3 ], + [ 4 ] + ], + "DL": [ 0, 0, 0 ], + "sdl": 1, + "odl": 0, + "D": [ 1, 0, 1, 1 ], + "sd": 1, + "od": 0, + "DU": [ 2, 3, 4 ], + "sdu": 1, + "odu": 0, + "B": [ 1, 2, 3, 4 ], + "sb1": 1, + "sb2": 4, + "ob": 0, + "expectedDL": [ 0, 0, 0 ], + "expectedD": [ 1, 0, 1, 1 ], + "expectedDU": [ 2, 3, 4 ], + "expectedB": [ 1, 2, 3, 4 ], + "expectedInfo": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.dgtsv.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.dgtsv.js new file mode 100644 index 000000000000..84d72c49592a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.dgtsv.js @@ -0,0 +1,285 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dgtsv = require( './../lib/dgtsv.js' ); + + +// FIXTURES // + +var COLUMN_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COLUMN_MAJOR_MULTIPLE_RHS = require( './fixtures/column_major_multiple_rhs.json' ); +var ROW_MAJOR_MULTIPLE_RHS = require( './fixtures/row_major_multiple_rhs.json' ); +var COLUMN_MAJOR_PIVOTING = require( './fixtures/column_major_pivoting.json' ); +var PIVOTING_LAST = require( './fixtures/pivoting_last.json' ); +var SINGULAR = require( './fixtures/singular.json' ); +var SINGULAR_MID = require( './fixtures/singular_mid.json' ); +var SINGULAR_LAST = require( './fixtures/singular_last.json' ); +var SINGLE_ROW = require( './fixtures/single_row.json' ); + + +// FUNCTIONS // + +/** +* Runs the main interface against a fixture and asserts the expected output. +* +* @private +* @param {Object} t - test object +* @param {Object} data - fixture +*/ +function verify( t, data ) { + var expectedDL; + var expectedDU; + var expectedD; + var expectedB; + var info; + var DL; + var DU; + var D; + var B; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + B = new Float64Array( data.B ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedB = new Float64Array( data.expectedB ); + + info = dgtsv( data.order, data.N, data.NRHS, DL, D, DU, B, data.LDB ); + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( B, expectedB, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgtsv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dgtsv.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + '', + 1, + 3.14 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var data = COLUMN_MAJOR; + dgtsv( value, data.N, data.NRHS, new Float64Array( data.DL ), new Float64Array( data.D ), new Float64Array( data.DU ), new Float64Array( data.B ), data.LDB ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is less than zero', function test( t ) { + var values; + var i; + + 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() { + var data = COLUMN_MAJOR; + dgtsv( data.order, value, data.NRHS, new Float64Array( data.DL ), new Float64Array( data.D ), new Float64Array( data.DU ), new Float64Array( data.B ), data.LDB ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is less than zero', function test( t ) { + var values; + var i; + + 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() { + var data = COLUMN_MAJOR; + dgtsv( data.order, data.N, value, new Float64Array( data.DL ), new Float64Array( data.D ), new Float64Array( data.DU ), new Float64Array( data.B ), data.LDB ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument (column-major) which is less than max(1,N)', function test( t ) { + var values; + var i; + + values = [ + 2, + 1, + 0 + ]; + 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() { + dgtsv( 'column-major', 3, 1, new Float64Array( 2 ), new Float64Array( 3 ), new Float64Array( 2 ), new Float64Array( 3 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument (row-major) which is less than max(1,NRHS)', function test( t ) { + var values; + var i; + + values = [ + 1, + 0 + ]; + 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() { + dgtsv( 'row-major', 3, 2, new Float64Array( 2 ), new Float64Array( 3 ), new Float64Array( 2 ), new Float64Array( 6 ), value ); + }; + } +}); + +tape( 'the function solves a tridiagonal system of equations (column-major)', function test( t ) { + verify( t, COLUMN_MAJOR ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system of equations (row-major)', function test( t ) { + verify( t, ROW_MAJOR ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system with multiple right-hand sides (column-major)', function test( t ) { + verify( t, COLUMN_MAJOR_MULTIPLE_RHS ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system with multiple right-hand sides (row-major)', function test( t ) { + verify( t, ROW_MAJOR_MULTIPLE_RHS ); + t.end(); +}); + +tape( 'the function performs row interchanges when partial pivoting is required', function test( t ) { + verify( t, COLUMN_MAJOR_PIVOTING ); + t.end(); +}); + +tape( 'the function performs a row interchange in the final elimination step when required', function test( t ) { + verify( t, PIVOTING_LAST ); + t.end(); +}); + +tape( 'the function returns a non-zero status code when the last diagonal element of `U` is exactly zero', function test( t ) { + verify( t, SINGULAR ); + t.end(); +}); + +tape( 'the function returns a non-zero status code when an interior diagonal element of `U` is exactly zero', function test( t ) { + verify( t, SINGULAR_MID ); + t.end(); +}); + +tape( 'the function returns a non-zero status code when a zero pivot is encountered in the final elimination step', function test( t ) { + verify( t, SINGULAR_LAST ); + t.end(); +}); + +tape( 'the function solves a system having a single row/column (`N=1`)', function test( t ) { + verify( t, SINGLE_ROW ); + t.end(); +}); + +tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) { + var expectedDL; + var expectedDU; + var expectedD; + var expectedB; + var data; + var info; + var DL; + var DU; + var D; + var B; + + data = COLUMN_MAJOR; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + B = new Float64Array( data.B ); + + expectedDL = new Float64Array( data.DL ); + expectedD = new Float64Array( data.D ); + expectedDU = new Float64Array( data.DU ); + expectedB = new Float64Array( data.B ); + + info = dgtsv( data.order, 0, data.NRHS, DL, D, DU, B, data.LDB ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( B, expectedB, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.js new file mode 100644 index 000000000000..d571a64c8e20 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dgtsv = 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 dgtsv, '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 dgtsv.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 dgtsv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgtsv, 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 dgtsv; + var main; + + main = require( './../lib/dgtsv.js' ); + + dgtsv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgtsv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.ndarray.js new file mode 100644 index 000000000000..8468c58f32aa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgtsv/test/test.ndarray.js @@ -0,0 +1,206 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dgtsv = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var COLUMN_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COLUMN_MAJOR_MULTIPLE_RHS = require( './fixtures/column_major_multiple_rhs.json' ); +var ROW_MAJOR_MULTIPLE_RHS = require( './fixtures/row_major_multiple_rhs.json' ); +var COLUMN_MAJOR_PIVOTING = require( './fixtures/column_major_pivoting.json' ); +var PIVOTING_LAST = require( './fixtures/pivoting_last.json' ); +var COLUMN_MAJOR_OFFSET = require( './fixtures/column_major_offset.json' ); +var ROW_MAJOR_OFFSET = require( './fixtures/row_major_offset.json' ); +var LARGE_STRIDES = require( './fixtures/large_strides.json' ); +var NEGATIVE_STRIDES = require( './fixtures/negative_strides.json' ); +var MIXED_STRIDES = require( './fixtures/mixed_strides.json' ); +var SINGULAR = require( './fixtures/singular.json' ); +var SINGULAR_MID = require( './fixtures/singular_mid.json' ); +var SINGULAR_LAST = require( './fixtures/singular_last.json' ); +var SINGLE_ROW = require( './fixtures/single_row.json' ); + + +// FUNCTIONS // + +/** +* Runs the ndarray interface against a fixture and asserts the expected output. +* +* @private +* @param {Object} t - test object +* @param {Object} data - fixture +*/ +function verify( t, data ) { + var expectedDL; + var expectedDU; + var expectedD; + var expectedB; + var info; + var DL; + var DU; + var D; + var B; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + B = new Float64Array( data.B ); + + expectedDL = new Float64Array( data.expectedDL ); + expectedD = new Float64Array( data.expectedD ); + expectedDU = new Float64Array( data.expectedDU ); + expectedB = new Float64Array( data.expectedB ); + + info = dgtsv( data.N, data.NRHS, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, B, data.sb1, data.sb2, data.ob ); // eslint-disable-line max-len + t.strictEqual( info, data.expectedInfo, 'returns expected value' ); + t.deepEqual( B, expectedB, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgtsv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 15', function test( t ) { + t.strictEqual( dgtsv.length, 15, 'returns expected value' ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system of equations (column-major)', function test( t ) { + verify( t, COLUMN_MAJOR ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system of equations (row-major)', function test( t ) { + verify( t, ROW_MAJOR ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system with multiple right-hand sides (column-major)', function test( t ) { + verify( t, COLUMN_MAJOR_MULTIPLE_RHS ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system with multiple right-hand sides (row-major)', function test( t ) { + verify( t, ROW_MAJOR_MULTIPLE_RHS ); + t.end(); +}); + +tape( 'the function performs row interchanges when partial pivoting is required', function test( t ) { + verify( t, COLUMN_MAJOR_PIVOTING ); + t.end(); +}); + +tape( 'the function performs a row interchange in the final elimination step when required', function test( t ) { + verify( t, PIVOTING_LAST ); + t.end(); +}); + +tape( 'the function supports specifying index offsets (column-major)', function test( t ) { + verify( t, COLUMN_MAJOR_OFFSET ); + t.end(); +}); + +tape( 'the function supports specifying index offsets (row-major)', function test( t ) { + verify( t, ROW_MAJOR_OFFSET ); + t.end(); +}); + +tape( 'the function supports specifying positive strides', function test( t ) { + verify( t, LARGE_STRIDES ); + t.end(); +}); + +tape( 'the function supports specifying negative strides', function test( t ) { + verify( t, NEGATIVE_STRIDES ); + t.end(); +}); + +tape( 'the function supports specifying mixed strides', function test( t ) { + verify( t, MIXED_STRIDES ); + t.end(); +}); + +tape( 'the function returns a non-zero status code when the last diagonal element of `U` is exactly zero', function test( t ) { + verify( t, SINGULAR ); + t.end(); +}); + +tape( 'the function returns a non-zero status code when an interior diagonal element of `U` is exactly zero', function test( t ) { + verify( t, SINGULAR_MID ); + t.end(); +}); + +tape( 'the function returns a non-zero status code when a zero pivot is encountered in the final elimination step', function test( t ) { + verify( t, SINGULAR_LAST ); + t.end(); +}); + +tape( 'the function solves a system having a single row/column (`N=1`)', function test( t ) { + verify( t, SINGLE_ROW ); + t.end(); +}); + +tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) { + var expectedDL; + var expectedDU; + var expectedD; + var expectedB; + var data; + var info; + var DL; + var DU; + var D; + var B; + + data = COLUMN_MAJOR; + + DL = new Float64Array( data.DL ); + D = new Float64Array( data.D ); + DU = new Float64Array( data.DU ); + B = new Float64Array( data.B ); + + expectedDL = new Float64Array( data.DL ); + expectedD = new Float64Array( data.D ); + expectedDU = new Float64Array( data.DU ); + expectedB = new Float64Array( data.B ); + + info = dgtsv( 0, data.NRHS, DL, data.sdl, data.odl, D, data.sd, data.od, DU, data.sdu, data.odu, B, data.sb1, data.sb2, data.ob ); // eslint-disable-line max-len + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( B, expectedB, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( DU, expectedDU, 'returns expected value' ); + t.deepEqual( DL, expectedDL, 'returns expected value' ); + + t.end(); +});