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

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

-->

# dlasq1

> Compute the singular values of a real `N-by-N` bidiagonal matrix with diagonal `D` and off-diagonal `E`.

<section class="intro">

The `dlasq1` routine computes all singular values of a real N-by-N bidiagonal matrix:

```math
B = \left[\begin{array}{rrrrr}d_1 & e_1 & 0 & 0 & 0 \\0 & d_2 & e_2 & 0 & 0 \\0 & 0 & d_3 & e_3 & 0 \\0 & 0 & 0 & d_4 & e_4 \\0 & 0 & 0 & 0 & d_5\end{array}\right]
```

where:

- `d` contains the diagonal elements.
- `e` contains the off-diagonal elements (`e_N` is ignored on input).

The algorithm is based on the DQDS (Differential Quotient-Difference with Shift) method, which computes singular values to high relative accuracy. On normal exit, the diagonal array `D` is overwritten with the singular values in decreasing order.

</section>

<!-- /.intro -->

<section class="usage">

## Usage

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

#### dlasq1( N, D, E, WORK )

Computes the singular values of a real `N-by-N` bidiagonal matrix with diagonal `D` and off-diagonal `E`.

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

var D = new Float64Array( [ 100.0, 50.0, 25.0 ] );
var E = new Float64Array( [ 90.0, 40.0, 0.0 ] );
var WORK = new Float64Array( 12 );

var info = dlasq1( 3, D, E, WORK );
// D => <Float64Array>[ ~139.377, ~56.064, ~15.997 ]
// E => <Float64Array>[ 90.0, 40.0, 0.0 ]
// info => 0
```

The function has the following parameters:

- **N**: number of rows/columns in the matrix.
- **D**: the diagonal elements of the bidiagonal matrix as a [`Float64Array`][@stdlib/array/float64]. Should have `N` indexed elements. On normal exit, `D` is overwritten with the singular values in decreasing order.
- **E**: the off-diagonal elements of the bidiagonal matrix as a [`Float64Array`][@stdlib/array/float64]. Should have `N` indexed elements. On entry, elements `E(1:N-1)` contain the off-diagonal elements. On exit, `E` is overwritten.
- **WORK**: workspace array as a [`Float64Array`][@stdlib/array/float64]. Should have length at least `4*N`.

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 dlasq1 = require( '@stdlib/lapack/base/dlasq1' );

// Initial arrays...
var D0 = new Float64Array( [ 0.0, 100.0, 50.0, 25.0 ] );
var E0 = new Float64Array( [ 0.0, 90.0, 40.0, 0.0 ] );
var WORK0 = new Float64Array( 13 );

// Create offset views...
var D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var E = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var WORK = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

var info = dlasq1( 3, D, E, WORK );
// D0 => <Float64Array>[ 0.0, ~139.377, ~56.064, ~15.997 ]
// E0 => <Float64Array>[ 0.0, 90.0, 40.0, 0.0 ]
// info => 0
```

#### dlasq1.ndarray( N, D, sD, oD, E, sE, oE, WORK, sWORK, oWORK )

Computes the singular values of a real `N-by-N` bidiagonal matrix with diagonal `D` and off-diagonal `E` using alternative indexing semantics.

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

var D = new Float64Array( [ 100.0, 50.0, 25.0 ] );
var E = new Float64Array( [ 90.0, 40.0, 0.0 ] );
var WORK = new Float64Array( 12 );

var info = dlasq1.ndarray( 3, D, 1, 0, E, 1, 0, WORK, 1, 0 );
// D => <Float64Array>[ ~139.377, ~56.064, ~15.997 ]
// E => <Float64Array>[ 90.0, 40.0, 0.0 ]
// info => 0
```

The function has the following additional parameters:

- **sD**: stride length for `D`.
- **oD**: starting index for `D`.
- **sE**: stride length for `E`.
- **oE**: starting index for `E`.
- **sWORK**: stride length for `WORK`.
- **oWORK**: starting index for `WORK`.

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 dlasq1 = require( '@stdlib/lapack/base/dlasq1' );

var D = new Float64Array( [ 0.0, 100.0, 50.0, 25.0 ] );
var E = new Float64Array( [ 0.0, 90.0, 40.0, 0.0 ] );
var WORK = new Float64Array( 13 );

var info = dlasq1.ndarray( 3, D, 1, 1, E, 1, 1, WORK, 1, 1 );
// D => <Float64Array>[ 0.0, ~139.377, ~56.064, ~15.997 ]
// E => <Float64Array>[ 0.0, 90.0, 40.0, 0.0 ]
// info => 0
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- Both functions mutate the input arrays `D`, `E`, and `WORK`.

- Both functions return a status code indicating success or failure. The status code indicates the following conditions:

- `0`: successful exit.

- `< 0`: if `INFO = -i`, the `i`-th argument had an illegal value.

- `> 0`: the algorithm failed:
- `1`: a split was marked by a positive value in `E`.
- `2`: current block not diagonalized after `100*N` iterations (in inner while loop). On exit, `D` and `E` represent a matrix with the same singular values which the calling subroutine could use to finish the computation, or even feed back into `DLASQ1`.
- `3`: termination criterion of outer while loop not met (program created more than `N` unreduced blocks).

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

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

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

var N = 4;

/*
B = [
[ 5.0, 4.0, 0.0, 0.0 ],
[ 0.0, 2.0, 3.0, 0.0 ],
[ 0.0, 0.0, 6.0, 2.0 ],
[ 0.0, 0.0, 0.0, 1.0 ]
]
*/

var D = new Float64Array( [ 5.0, 2.0, 6.0, 1.0 ] );
var E = new Float64Array( [ 4.0, 3.0, 2.0, 0.0 ] );
var WORK = new Float64Array( 16 );

// Compute the singular values:
var info = dlasq1( N, D, E, WORK );

console.log( D );

console.log( info );
```

</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-dlasq1]: https://www.netlib.org/lapack/explore-html/d5/dce/group__lasq1_ga5a8c1474ef61ff7c59c17412ae456ca6.html

[@stdlib/array/float64]: https://stdlib.io/docs/api/latest/@stdlib/array/float64

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

</section>

<!-- /.links -->
Loading