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
292 changes: 292 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dsptrs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
<!--

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

-->

# dsptrs

> Solve a system of linear equations `A * X = B` with a real symmetric matrix `A` stored in packed format using the factorization computed by `dsptrf`.

<section class="usage">

## Usage

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

#### dsptrs( order, uplo, N, nrhs, AP, IPIV, B, LDB )

Solves a system of linear equations `A * X = B` with a real symmetric matrix `A` stored in packed format using the factorization `A = U * D * U^T` or `A = L * D * L^T` computed by `dsptrf`.

<!-- eslint-disable max-len -->

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

/*
A = [
[ 0.0, 1.0, 2.0 ],
[ 1.0, 0.0, 3.0 ],
[ 2.0, 3.0, 0.0 ]
]
*/

// Factorization `A = L * D * L^T` of the lower triangle of `A` (column-major), as computed by `dsptrf`:
var AP = new Float64Array( [ 0.0, 2.0, 1.5, 0.0, 0.5, -3.0 ] );
var IPIV = new Int32Array( [ -3, -3, 3 ] );

var B = new Float64Array( [ 3.0, 4.0, 5.0 ] );

dsptrs( 'column-major', 'lower', 3, 1, AP, IPIV, B, 3 );
// B => <Float64Array>[ 1.0, 1.0, 1.0 ]
```

The function has the following parameters:

- **order**: storage layout. Must be either `'row-major'` or `'column-major'`.
- **uplo**: specifies whether the factorization of the upper or lower triangular part of the symmetric matrix `A` is supplied. Must be either `'upper'` or `'lower'`.
- **N**: order of the matrix `A`.
- **nrhs**: number of right-hand sides (i.e., number of columns of `B`).
- **AP**: factored matrix in packed format, as returned by `dsptrf`, stored as a [`Float64Array`][mdn-float64array]. Should have `N*(N+1)/2` indexed elements.
- **IPIV**: vector of pivot indices, as returned by `dsptrf`, stored as an [`Int32Array`][mdn-int32array]. Should have `N` indexed elements.
- **B**: input [`Float64Array`][mdn-float64array] containing the right-hand side matrix. 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`). Must be greater than or equal to `max(1,N)` when `order` is `'column-major'` and greater than or equal to `max(1,nrhs)` when `order` is `'row-major'`.

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, max-len -->

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

var AP = new Float64Array( [ 0.0, 2.0, 1.5, 0.0, 0.5, -3.0 ] );
var IPIV = new Int32Array( [ -3, -3, 3 ] );

// Initial array...
var B0 = new Float64Array( [ 0.0, 3.0, 4.0, 5.0 ] );

// Create an offset view...
var B = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dsptrs( 'column-major', 'lower', 3, 1, AP, IPIV, B, 3 );
// B0 => <Float64Array>[ 0.0, 1.0, 1.0, 1.0 ]
```

<!-- lint disable maximum-heading-length -->

#### dsptrs.ndarray( order, uplo, N, nrhs, AP, sap, oap, IPIV, si, oi, B, sb1, sb2, ob )

Solves a system of linear equations `A * X = B` with a real symmetric matrix `A` stored in packed format using the factorization `A = U * D * U^T` or `A = L * D * L^T` computed by `dsptrf` and alternative indexing semantics.

<!-- eslint-disable max-len -->

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

var AP = new Float64Array( [ 0.0, 2.0, 1.5, 0.0, 0.5, -3.0 ] );
var IPIV = new Int32Array( [ -3, -3, 3 ] );
var B = new Float64Array( [ 3.0, 4.0, 5.0 ] );

dsptrs.ndarray( 'column-major', 'lower', 3, 1, AP, 1, 0, IPIV, 1, 0, B, 1, 3, 0 );
// B => <Float64Array>[ 1.0, 1.0, 1.0 ]
```

The function has the following additional parameters:

- **sap**: stride length for `AP`.
- **oap**: starting index for `AP`.
- **si**: stride length for `IPIV`.
- **oi**: starting index for `IPIV`.
- **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,

<!-- eslint-disable max-len -->

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

var AP = new Float64Array( [ 0.0, 2.0, 1.5, 0.0, 0.5, -3.0 ] );
var IPIV = new Int32Array( [ -3, -3, 3 ] );
var B = new Float64Array( [ 0.0, 3.0, 4.0, 5.0 ] );

dsptrs.ndarray( 'column-major', 'lower', 3, 1, AP, 1, 0, IPIV, 1, 0, B, 1, 3, 1 );
// B => <Float64Array>[ 0.0, 1.0, 1.0, 1.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- Both functions mutate the input array `B`. The arrays `AP` and `IPIV` are not modified.
- `AP` and `IPIV` should be the outputs of `dsptrf` called with the same `order` and `uplo`. `IPIV` uses the same encoding as `dsptrf`: if `IPIV[k] > 0`, `D(k,k)` is a 1-by-1 diagonal block and row `k` was interchanged with row `IPIV[k]`; if `IPIV[k] < 0`, rows were interchanged with row `-IPIV[k]` as part of a 2-by-2 diagonal block. Row values are one-based, as in the reference LAPACK implementation.
- For a symmetric matrix, an upper triangle stored in row-major order is identical in memory to a lower triangle stored in column-major order (and vice versa). Accordingly, as in `dsptrf`, when `order` is `'row-major'`, the functions resolve `uplo` to the equivalent column-major factorization (i.e., `'row-major'` + `'upper'` is solved using `L*D*L^T` and `'row-major'` + `'lower'` is solved using `U*D*U^T`).
- For `dsptrs.ndarray()`, the storage layout of `B` is specified by the strides `sb1` and `sb2`, while `order` specifies the layout of the packed matrix `AP`.
- `dsptrs()` corresponds to the [LAPACK][lapack] routine [`dsptrs`][lapack-dsptrs].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint-disable max-len -->

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

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

/*
Symmetric matrix `A`:

A = [
[ 0.0, 1.0, 2.0 ],
[ 1.0, 0.0, 3.0 ],
[ 2.0, 3.0, 0.0 ]
]
*/

// Factorization `A = L * D * L^T` of the lower triangle of `A` (column-major), as computed by `dsptrf`:
var AP = new Float64Array( [ 0.0, 2.0, 1.5, 0.0, 0.5, -3.0 ] );
var IPIV = new Int32Array( [ -3, -3, 3 ] );

// Two right-hand sides, stored in column-major order:
var B = new Float64Array( [ 3.0, 4.0, 5.0, 6.0, 8.0, 10.0 ] );

// Solve `A * X = B`:
dsptrs( 'column-major', 'lower', 3, 2, AP, IPIV, B, 3 );

console.log( B );
// => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 ]
```

</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-dsptrs]: https://github.com/Reference-LAPACK/lapack/blob/master/SRC/dsptrs.f

[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