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

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

-->

# dgeequ

> Compute row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number.

<section class="usage">

## Usage

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

#### dgeequ( order, M, N, A, LDA, R, C )

Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number.

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

var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
var R = new Float64Array( 3 );
var C = new Float64Array( 3 );

var out = dgeequ( 'row-major', 3, 3, A, 3, R, C );
// returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ]
```

The function has the following parameters:

- **order**: storage layout (either `'row-major'` or `'column-major'`).
- **M**: number of rows of matrix `A`.
- **N**: number of columns of matrix `A`.
- **A**: the M-by-N matrix `A` as a [`Float64Array`][mdn-float64array].
- **LDA**: leading dimension of matrix `A`.
- **R**: output row scale factors as a [`Float64Array`][mdn-float64array].
- **C**: output column scale factors as a [`Float64Array`][mdn-float64array].

The function returns a `Collection` containing:

- **rowcnd**: ratio of the smallest `R[i]` to the largest `R[i]`.
- **colcnd**: ratio of the smallest `C[j]` to the largest `C[j]`.
- **amax**: absolute value of the largest matrix element.
- **info**: status code. If `0`, successful exit. If `> 0` and `<= M`, the `i`-th row is exactly zero (where `i` equals the status code); if `> M`, the `(i-M)`-th column is exactly zero. Note that the status code uses one-based indexing to match the LAPACK convention, so the corresponding zero-based JavaScript index is `info - 1`.

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

#### dgeequ.ndarray( M, N, A, sa1, sa2, oa, R, sr, or, C, sc, oc )

Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number using alternative indexing semantics.

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

var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
var R = new Float64Array( 3 );
var C = new Float64Array( 3 );

var out = dgeequ.ndarray( 3, 3, A, 3, 1, 0, R, 1, 0, C, 1, 0 );
// returns [ 0.3333333333333333, 0.7777777777777777, 9.0, 0 ]
```

The function has the following additional parameters:

- **sa1**: stride of the first dimension of `A`.
- **sa2**: stride of the second dimension of `A`.
- **oa**: starting index for `A`.
- **sr**: stride length for `R`.
- **or**: starting index for `R`.
- **sc**: stride length for `C`.
- **oc**: starting index for `C`.

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.

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- Both functions mutate the output arrays `R` and `C`.
- `dgeequ()` corresponds to the [LAPACK][LAPACK] routine [`dgeequ`][lapack-dgeequ].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

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

var A = new Float64Array( [ 1.0, 10.0, 100.0, 1000.0 ] );
var R = new Float64Array( 2 );
var C = new Float64Array( 2 );

var out = dgeequ( 'row-major', 2, 2, A, 2, R, C );
console.log( R );
// => <Float64Array>[ 0.1, 0.001 ]

console.log( C );
// => <Float64Array>[ 10.0, 1.0 ]

console.log( out );
// => [ 0.01, 0.1, 1000.0, 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-dgeequ]: https://netlib.org/lapack/explore-html/d5/d8a/group__geequ_ga7238812c5c26fc2fbe8bbbc22b6ee885.html#ga7238812c5c26fc2fbe8bbbc22b6ee885

[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 -->
121 changes: 121 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/**
* @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.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var floor = require( '@stdlib/math/base/special/floor' );
var format = require( '@stdlib/string/format' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dgeequ = require( './../lib/dgeequ.js' );


// VARIABLES //

var LAYOUTS = [
'row-major',
'column-major'
];


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {string} order - storage layout
* @param {PositiveInteger} N - number of elements along each dimension
* @returns {Function} benchmark function
*/
function createBenchmark( order, N ) {
var A;
var R;
var C;

A = uniform( N*N, -10.0, 10.0, {
'dtype': 'float64'
});
R = new Float64Array( N );
C = new Float64Array( N );

return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var out;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = dgeequ( order, N, N, A, N, R, C );
if ( isnan( out[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( out[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var min;
var max;
var ord;
var N;
var f;
var i;
var k;

min = 1; // 10^min
max = 6; // 10^max

for ( k = 0; k < LAYOUTS.length; k++ ) {
ord = LAYOUTS[ k ];
for ( i = min; i <= max; i++ ) {
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( ord, N );
bench( format( '%s::equidimensional:order=%s,size=%d', pkg, ord, N*N ), f );

Check warning on line 116 in lib/node_modules/@stdlib/lapack/base/dgeequ/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "equidimensional"
}
}
}

main();
Loading
Loading