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

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

-->

# dlaqsy

> Equilibrate a real symmetric matrix using the scaling factors in a vector.

<section class="intro">

Equilibration rescales the rows and columns of a matrix in order to improve its condition number. Given a real symmetric matrix `A` and a vector of scale factors `S`, this routine overwrites `A` with

<!-- <equation class="equation" label="eq:symmetric_equilibration" align="center" raw="A = \mathrm{diag}(S) \cdot A \cdot \mathrm{diag}(S)" alt="Equation for symmetric equilibration."> -->

```math
A = \mathrm{diag}(S) \cdot A \cdot \mathrm{diag}(S)
```

<!-- </equation> -->

such that each referenced element is updated according to

<!-- <equation class="equation" label="eq:symmetric_equilibration_element" align="center" raw="a_{ij} = s_i \cdot a_{ij} \cdot s_j" alt="Equation for updating a matrix element during symmetric equilibration."> -->

```math
a_{ij} = s_i \cdot a_{ij} \cdot s_j
```

<!-- </equation> -->

Equilibration is only performed when the ratio of the smallest scale factor to the largest scale factor is less than `0.1` or when the absolute value of the largest matrix entry is either too large or too small.

</section>

<!-- /.intro -->

<section class="usage">

## Usage

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

#### dlaqsy( order, uplo, N, A, LDA, S, scond, amax )

Equilibrates a real symmetric matrix `A` using the scaling factors in the vector `S`.

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

var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 5.0, 6.0, 3.0, 6.0, 9.0 ] );
var S = new Float64Array( [ 0.25, 2.0, 4.0 ] );

/*
A = [
[ 1.0, 2.0, 3.0 ],
[ 2.0, 5.0, 6.0 ],
[ 3.0, 6.0, 9.0 ]
]
*/

dlaqsy( 'row-major', 'upper', 3, A, 3, S, 0.0625, 9.0 );
// A => <Float64Array>[ 0.0625, 1.0, 3.0, 2.0, 20.0, 48.0, 3.0, 6.0, 144.0 ]
```

The function has the following parameters:

- **order**: storage layout.
- **uplo**: specifies whether to reference the upper or lower triangular part of the symmetric matrix `A`. Must be either `'upper'` or `'lower'`.
- **N**: order of the matrix `A`.
- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array].
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). Must be at least `max(1,N)`.
- **S**: vector of scale factors as a [`Float64Array`][mdn-float64array]. Should have `N` elements.
- **scond**: ratio of the smallest scale factor to the largest scale factor.
- **amax**: absolute value of the largest matrix entry.

The function returns a character flag indicating whether the matrix was equilibrated (`'Y'`) or not (`'N'`).

Only the triangular part of `A` specified by `uplo` is referenced and updated. If equilibration is not needed, `A` is left unchanged.

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

var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 5.0, 6.0, 3.0, 6.0, 9.0 ] );
var S = new Float64Array( [ 0.5, 1.0, 2.0 ] );

var equed = dlaqsy( 'row-major', 'upper', 3, A, 3, S, 0.25, 9.0 );
// returns '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' );

// Initial arrays...
var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 2.0, 5.0 ] );
var S0 = new Float64Array( [ 0.0, 0.25, 4.0 ] );

// Create offset views...
var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var S1 = new Float64Array( S0.buffer, S0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dlaqsy( 'row-major', 'upper', 2, A1, 2, S1, 0.0625, 5.0 );
// A0 => <Float64Array>[ 0.0, 0.0625, 2.0, 2.0, 80.0 ]
```

#### dlaqsy.ndarray( uplo, N, A, sa1, sa2, oa, S, ss, os, scond, amax )

Equilibrates a real symmetric matrix `A` using the scaling factors in the vector `S` and alternative indexing semantics.

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

var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 5.0, 6.0, 3.0, 6.0, 9.0 ] );
var S = new Float64Array( [ 0.25, 2.0, 4.0 ] );

dlaqsy.ndarray( 'upper', 3, A, 3, 1, 0, S, 1, 0, 0.0625, 9.0 );
// A => <Float64Array>[ 0.0625, 1.0, 3.0, 2.0, 20.0, 48.0, 3.0, 6.0, 144.0 ]
```

The function has the following parameters:

- **uplo**: specifies whether to reference the upper or lower triangular part of the symmetric matrix `A`. Must be either `'upper'` or `'lower'`.
- **N**: order of the matrix `A`.
- **A**: input matrix as a [`Float64Array`][mdn-float64array].
- **sa1**: stride of the first dimension of `A`.
- **sa2**: stride of the second dimension of `A`.
- **oa**: starting index for `A`.
- **S**: vector of scale factors as a [`Float64Array`][mdn-float64array].
- **ss**: stride length for `S`.
- **os**: starting index for `S`.
- **scond**: ratio of the smallest scale factor to the largest scale factor.
- **amax**: absolute value of the largest matrix entry.

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 A = new Float64Array( [ 0.0, 1.0, 2.0, 2.0, 5.0 ] );
var S = new Float64Array( [ 0.0, 4.0, 0.0, 0.25 ] );

dlaqsy.ndarray( 'upper', 2, A, 2, 1, 1, S, -2, 3, 0.0625, 5.0 );
// A => <Float64Array>[ 0.0, 0.0625, 2.0, 2.0, 80.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dlaqsy()` corresponds to the [LAPACK][lapack] function [`dlaqsy`][lapack-dlaqsy].
- Equilibration is performed when `scond < 0.1`, `amax < smallnum`, or `amax > bignum`, where `smallnum` is the ratio of the safe minimum to the machine precision and `bignum = 1/smallnum`.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

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

// Specify matrix meta data:
var shape = [ 3, 3 ];
var order = 'row-major';
var strides = shape2strides( shape, order );

// Create a symmetric matrix stored in linear memory:
var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 5.0, 6.0, 3.0, 6.0, 9.0 ] );
console.log( ndarray2array( A, shape, strides, 0, order ) );

// Define a vector of scale factors:
var S = new Float64Array( [ 0.25, 2.0, 4.0 ] );

// Equilibrate the upper triangular part of the matrix:
var equed = dlaqsy( order, 'upper', 3, A, strides[ 0 ], S, 0.0625, 9.0 );
console.log( equed );
console.log( ndarray2array( A, 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-dlaqsy]: https://www.netlib.org/lapack/explore-html/df/dca/group__laqhe_gaba164109f29d549e268fb25310701918.html

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

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

</section>

<!-- /.links -->
Loading
Loading