Skip to content

feat: add lapack/base/dppequ #6598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8104aed
feat: add base algorithm
aayush0325 Apr 7, 2025
b5618f1
feat: add exports
aayush0325 Apr 7, 2025
b7e80eb
feat: merge loops
aayush0325 Apr 7, 2025
9bb5c38
feat: add main export
aayush0325 Apr 7, 2025
fab8873
test: add initial tests
aayush0325 Apr 16, 2025
51ad33f
test: add initial ndarray tests
aayush0325 Apr 16, 2025
ccda72f
test: add initial ndarray tests
aayush0325 Apr 16, 2025
dc0dfd0
test: add tests
aayush0325 Apr 18, 2025
7ac07fd
test: add N=0 case
aayush0325 Apr 18, 2025
7ff79c8
test: add non positive diagonal element tests
aayush0325 Apr 19, 2025
9de21b0
test: add ndarray tests
aayush0325 Apr 19, 2025
2be7e95
Merge remote-tracking branch 'upstream/develop' into lapack-dppequ
stdlib-bot May 26, 2025
b2d8e26
test: add tests for negative strides
aayush0325 Apr 26, 2025
b896286
test: add tests
aayush0325 Apr 26, 2025
d978c69
test: add offset tests
aayush0325 Apr 29, 2025
9fd55a0
refactor: pointer arithmmetic
aayush0325 May 26, 2025
37b6731
refactor: pointer arithmetic
aayush0325 May 26, 2025
5b87ba7
docs: add description
aayush0325 May 26, 2025
a8ca2ba
refactor: use stdlib conventions
aayush0325 May 27, 2025
0e9907c
test: add test to check uplo
aayush0325 May 27, 2025
6ee35de
test: add tests for large strides
aayush0325 May 27, 2025
5cda5cf
test: add tests for mixed strides
aayush0325 May 27, 2025
d3d405e
bench: add benchmarks
aayush0325 May 27, 2025
78282b8
docs: add index.d.ts
aayush0325 May 27, 2025
d2b6b3f
test: add ts tests
aayush0325 May 27, 2025
69a3907
docs: add notes
aayush0325 May 27, 2025
45d15f0
docs: add README
aayush0325 May 27, 2025
8fa0925
docs: add repl.txt
aayush0325 May 27, 2025
08fe080
chore: cleanup
aayush0325 May 27, 2025
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
280 changes: 280 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dppequ/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
<!--

@license Apache-2.0

Copyright (c) 2025 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.

-->

# dppequ

> LAPACK routine to compute the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm).

<section class="usage">

## Usage

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

#### dppequ( order, uplo, N, AP, S, out )

Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm).

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

var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] );
var S = new Float64Array( 3 );
var out = new Float64Array( 2 );

dppequ( 'row-major', 'lower', 3, AP, S, out );
// S => <Float64Array>[ 1.0, ~0.58, ~0.33 ]
// out => <Float64Array>[ ~0.33, 9.0 ]
```

The function has the following parameters:

- **order**: storage layout.
- **uplo**: specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ).
- **AP**: array containing the upper or lower triangle of `A` in packed form stored in linear memory as a [`Float64Array`][mdn-float64array], expects `N * ( N + 1 ) / 2` indexed elements
- **S**: array to store the scale factors of `A` in linear memory as a [`Float64Array`][mdn-float64array], expects `N` indexed elements.
- **out**: the first element of `out` represents `scond`, the second element of out represents `amax`. if `scond` >= 0.1 and `amax` is not close to overflow/underflow it isn't worth scaling the matrix by `S`, if `amax` is close to underflow/overflow the matrix shoud be scaled. expects a [`Float64Array`][mdn-float64array] with 2 indexed elements.

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 AP0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] );
var S0 = new Float64Array( 4 );
var out0 = new Float64Array( 3 );

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

dppequ( 'row-major', 'lower', 3, AP1, S1, out1 );
// S0 => <Float64Array>[ 0.0, 1.0, ~0.58, ~0.33 ]
// out => <Float64Array>[ ~0.33, 9.0 ]
```

#### dppequ.ndarray( order, uplo, N, AP, sap, oap, S, ss, os, out, so, oo )

Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm) using alternative indexing semantics.

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

var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] );
var S = new Float64Array( 3 );
var out = new Float64Array( 2 );

dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 );
// S => <Float64Array>[ 1.0, ~0.58, ~0.33 ]
// out => <Float64Array>[ ~0.33, 9.0 ]
```

The function has the following parameters:

- **order**: storage layout.
- **uplo**: specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ).
- **AP**: array containing the upper or lower triangle of `A` in packed form stored in linear memory as a [`Float64Array`][mdn-float64array], expects `N * ( N + 1 ) / 2` indexed elements.
- **sap**: index increment for `AP`.
- **oap**: starting index of `AP`.
- **S**: array to store the scale factors of `A` in linear memory as a [`Float64Array`][mdn-float64array], expects `N` indexed elements.
- **ss**: index increment for `S`.
- **os**: starting index of `S`.
- **out**: the first element of `out` represents `scond`, the second element of out represents `amax`. if `scond` >= 0.1 and `amax` is not close to overflow/underflow it isn't worth scaling the matrix by `S`, if `amax` is close to underflow/overflow the matrix shoud be scaled. expects a [`Float64Array`][mdn-float64array] with 2 indexed elements.
- **so**: index increment for `out`.
- **oo**: starting index of `out`.

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 AP = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] );
var S = new Float64Array( 4 );
var out = new Float64Array( 3 );

dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 1, S, 1, 1, out, 1, 1 );
// S => <Float64Array>[ 0.0, 1.0, ~0.58, ~0.33 ]
// out => <Float64Array>[ 0.0, ~0.33, 9.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dppequ()` corresponds to the [LAPACK][LAPACK] function [`dppequ`][lapack-dppequ].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

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

var i;
var j;

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

// Define a symmetric positive definite matrix:
var A = new Float64Array( [ 4.0, 1.0, 1.0, 1.0, 3.0, 0.0, 1.0, 0.0, 2.0 ] );
console.log( ndarray2array( A, shape, strides, offset, order ) );

// Convert the matrix to packed storage (upper triangle):
var buf = [];
for ( i = 0; i < shape[ 0 ]; i++ ) {
for ( j = i; j < shape[ 1 ]; j++ ) {
buf.push( A[ (i*strides[ 0 ]) + (j*strides[ 1 ]) + offset ] );
}
}
console.log( buf );

var AP = new Float64Array( buf );
var out = new Float64Array( 2 );
var S = new Float64Array( shape[ 0 ] );
var info = dppequ( order, uplo, shape[ 0 ], AP, S, out );

console.log( 'info:', info );
console.log( 'S:', S );
console.log( 'out:', out );
```

</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-dppequ]: https://www.netlib.org/lapack/explore-html/d4/d32/group__ppequ_gab707d51530c978eaae279e5728e4f54d.html#gab707d51530c978eaae279e5728e4f54d

[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