Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
302 changes: 302 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dgtts2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
<!--

@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.

-->

<!-- lint disable max-len -->

# dgtts2

> Solve a system of linear equations with a tridiagonal matrix using the LU factorization computed by [dgttrf][lapack-dgttrf].

<section class="usage">

## Usage

```javascript
var dgtts2 = require( '@stdlib/lapack/base/dgtts2' );
```

#### dgtts2( order, itrans, N, nrhs, DL, D, DU, DU2, IPIV, B, LDB )

Solves a system of linear equations with a tri diagonal matrix using the LU factorization computed by [dgttrf][lapack-dgttrf].

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );

var DL = new Float64Array( [ 0.25, 0.26666667 ] );
var D = new Float64Array( [ 4.0, 3.75, 3.73333333 ] );
var DU = new Float64Array( [ 1.0, 0.73333333 ] );
var DU2 = new Float64Array( [ 0.0 ] );
var IPIV = new Int32Array( [ 0, 1, 2 ] );
var B = new Float64Array( [ 7.0, 8.0, 7.0 ] );

var out = dgtts2( 'column-major', 1, 3, 1, DL, D, DU, DU2, IPIV, B, 3 );
// out => <Float64Array>[ ~1.44, ~1.25, ~1.55 ]
```

The function has the following parameters:

- **order**: storage layout.
- **itrans**: specifies the form of the system of equations.
- **N**: order of the matrix `A`.
- **nrhs**: number of right-hand sides, i.e., the number of columns of the matrix `B`.
- **DL**: multipliers that define the matrix `L` as a [`Float64Array`][mdn-float64array].
- **D**: diagonal elements of the upper triangular matrix `U` as a [`Float64Array`][mdn-float64array].
- **DU**: elements of the first super-diagonal of `U` as a [`Float64Array`][mdn-float64array].
- **DU2**: elements of the second super-diagonal of `U` as a [`Float64Array`][mdn-float64array].
- **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array].
- **B**: right-hand side matrix B, overwritten by the solution matrix `X` as a [`Float64Array`][mdn-float64array].
- **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.

<!-- eslint-disable stdlib/capitalized-comments -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );

// Initial arrays...
var DL0 = new Float64Array( [ 0.0, 0.25, 0.26666667 ] );
var D0 = new Float64Array( [ 0.0, 4.0, 3.75, 3.73333333 ] );
var DU0 = new Float64Array( [ 0.0, 1.0, 0.73333333 ] );
var DU20 = new Float64Array( [ 0.0, 0.0 ] );
var IPIV0 = new Int32Array( [ 0, 0, 1, 2 ] );
var B0 = new Float64Array( [ 0.0, 7.0, 8.0, 7.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 DU2 = new Float64Array( DU20.buffer, DU20.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var B = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dgtts2( 'column-major', 1, 3, 1, DL, D, DU, DU2, IPIV, B, 3 );
// B0 => <Float64Array>[ 0.0, ~1.44, ~1.25, ~1.55 ]
```

#### dgtts2.ndarray( itrans, N, nrhs, DL, sdl, odl, D, sd, od, DU, sdu, odu, DU2, sdu2, odu2, IPIV, si, oi, B, sb1, sb2, ob )

Solves a system of linear equations with a tri diagonal matrix using the LU factorization computed by [dgttrf][lapack-dgttrf] and alternative indexing semantics.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );

var DL = new Float64Array( [ 0.25, 0.26666667 ] );
var D = new Float64Array( [ 4.0, 3.75, 3.73333333 ] );
var DU = new Float64Array( [ 1.0, 0.73333333 ] );
var DU2 = new Float64Array( [ 0.0 ] );
var IPIV = new Int32Array( [ 0, 1, 2 ] );
var B = new Float64Array( [ 7.0, 8.0, 7.0 ] );

var out = dgtts2.ndarray( 1, 3, 1, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0, B, 1, 1, 0 );
// out => <Float64Array>[ ~1.44, ~1.25, ~1.55 ]
```

The function has the following parameters:

- **itrans**: specifies the form of the system of equations.
- **N**: order of the matrix `A`.
- **nrhs**: number of right-hand sides, i.e., the number of columns of the matrix `B`.
- **DL**: multipliers that define the matrix `L` as a [`Float64Array`][mdn-float64array].
- **sdl**: stride length for `DL`.
- **odl**: starting index for `DL`.
- **D**: diagonal elements of the upper triangular matrix `U` as a [`Float64Array`][mdn-float64array].
- **sd**: stride length for `D`.
- **od**: starting index for `D`.
- **DU**: elements of the first super-diagonal of `U` as a [`Float64Array`][mdn-float64array].
- **sdu**: stride length for `DU`.
- **odu**: starting index for `DU`.
- **DU2**: elements of the second super-diagonal of `U` as a [`Float64Array`][mdn-float64array].
- **sdu2**: stride length for `DU2`.
- **odu2**: starting index for `DU2`.
- **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array].
- **si**: stride length for `IPIV`.
- **oi**: starting index for `IPIV`.
- **B**: right-hand side matrix B, overwritten by the solution matrix `X` as a [`Float64Array`][mdn-float64array].
- **sb1**: stride length for first dimension of `B`.
- **sb2**: stride length for 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 Int32Array = require( '@stdlib/array/int32' );

var DL = new Float64Array( [ 0.0, 0.25, 0.26666667 ] );
var D = new Float64Array( [ 0.0, 4.0, 3.75, 3.73333333 ] );
var DU = new Float64Array( [ 0.0, 1.0, 0.73333333 ] );
var DU2 = new Float64Array( [ 0.0, 0.0 ] );
var IPIV = new Int32Array( [ 0, 0, 1, 2 ] );
var B = new Float64Array( [ 0.0, 7.0, 8.0, 7.0 ] );

var out = dgtts2.ndarray( 1, 3, 1, DL, 1, 1, D, 1, 1, DU, 1, 1, DU2, 1, 1, IPIV, 1, 1, B, 1, 1, 1 );
// out => <Float64Array>[ 0.0, ~1.44, ~1.25, ~1.55 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dgtts2()` corresponds to the [LAPACK][lapack] routine [`dgtts2`][lapack-dgtts2].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );
var dgtts2 = require( '@stdlib/lapack/base/dgtts2' );

var shape = [ 3, 3 ];
var order = 'row-major';
var strides = shape2strides( shape, order );

var B = new Float64Array( [ 7.0, 8.0, 7.0, 2.0, 3.0, 4.0, 1.0, 1.5, 2.0 ] );
console.log( ndarray2array( B, shape, strides, 0, order ) );

var DL = new Float64Array( [ 0.25, 0.26666667 ] );
var D = new Float64Array( [ 4.0, 3.75, 3.73333333 ] );
var DU = new Float64Array( [ 1.0, 0.73333333 ] );
var DU2 = new Float64Array( [ 0.0 ] );
var IPIV = new Int32Array( [ 0, 1, 2 ] );

var X = dgtts2( 'row-major', 1, 3, 3, DL, D, DU, DU2, IPIV, B, 3 );
console.log( ndarray2array( X, shape, strides, 0, order ) );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
TODO
```

#### TODO

TODO.

```c
TODO
```

TODO

```c
TODO
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
TODO
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[lapack]: https://www.netlib.org/lapack/explore-html/

[lapack-dgtts2]: https://www.netlib.org/lapack/explore-html/d2/dea/group__gtts2_gae123fb2b13f2398457e4c47f5c7f7fcd.html#gae123fb2b13f2398457e4c47f5c7f7fcd

[lapack-dgttrf]: https://www.netlib.org/lapack/explore-html/d6/d46/group__gttrf_ga8d1e46216e6c861c89bd4328b8be52a1.html#ga8d1e46216e6c861c89bd4328b8be52a1

[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array

[mdn-int32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

</section>

<!-- /.links -->

Loading