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
48 changes: 48 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dla-porpvgrw/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Copyright (c) 1992-2025 The University of Tennessee and The University
of Tennessee Research Foundation. All rights
reserved.
Copyright (c) 2000-2025 The University of California Berkeley. All
rights reserved.
Copyright (c) 2006-2025 The University of Colorado Denver. All rights
reserved.

$COPYRIGHT$

Additional copyrights may follow

$HEADER$

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer listed
in this license in the documentation and/or other materials
provided with the distribution.

- Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

The copyright holders provide no reassurances that the source code
provided does not infringe any patent, copyright, or any other
intellectual property rights of third parties. The copyright holders
disclaim any liability to any recipient for claims brought against
recipient by any third party for infringement of that parties
intellectual property rights.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
169 changes: 169 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dla-porpvgrw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<!--

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

-->


# dlaPorpvgrw

> Compute the reciprocal Cholesky pivot-growth factor.

The routine inspects the selected stored triangle of the leading `NCOLS`-by-`NCOLS` square prefix of an original matrix `A` and a supplied Cholesky factor `AF`. For each stored column, it computes maximum absolute entries of `A` and `AF`, then returns the minimum of their ratios and `1`. Columns with zero factor maxima are ignored. Both inputs are read-only; no factorization or symmetric completion is performed.

<section class="usage">

## Usage

```javascript
var dlaPorpvgrw = require( '@stdlib/lapack/base/dla-porpvgrw' );
```

#### dlaPorpvgrw( order, uplo, NCOLS, A, LDA, AF, LDAF, WORK )

Computes reciprocal pivot growth for finite entries in a supplied original matrix and triangular factor.

- `order`: `'row-major'` or `'column-major'` storage.
- `uplo`: `'upper'` or `'lower'` stored triangle.
- `NCOLS`: nonnegative safe integer specifying both dimensions of the inspected leading prefix.
- `A`: original `Float64Array` matrix storage.
- `LDA`: safe integer leading dimension of `A`, at least `NCOLS` for positive prefixes.
- `AF`: `Float64Array` containing the supplied upper or lower Cholesky factor, or a corresponding leading factor prefix.
- `LDAF`: independent safe integer leading dimension of `AF`, at least `NCOLS` for positive prefixes.
- `WORK`: `Float64Array` scratch storage containing at least `2*NCOLS` indexed entries.

For column-major storage, element `(i,j)` is at `i+j*LD`; for row-major storage it is at `i*LD+j`. Upper storage reads rows `0..j` of column `j`; lower storage reads rows `j..NCOLS-1`. The unused triangle, padding and trailing submatrix are never read. Upper and lower results need not coincide.

`WORK[0..NCOLS-1]` receives factor column maxima; `WORK[NCOLS..2*NCOLS-1]` receives original stored-column maxima. All maxima start at positive zero. Zero factor columns are ignored, even when their original maxima are nonzero; if all denominators are zero the result is `1`. A zero original maximum with a positive denominator yields `0`.

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

var A = new Float64Array( [ 0.25, 0.0, 0.0, 4.0 ] );
var AF = new Float64Array( [ 0.5, 0.0, 0.0, 2.0 ] );
var WORK = new Float64Array( 4 );

var v = dlaPorpvgrw( 'row-major', 'upper', 2, A, 2, AF, 2, WORK );
// returns 0.5

// WORK => <Float64Array>[ 0.5, 2.0, 0.25, 4.0 ]
```

Invalid layout or triangle selectors throw a `TypeError`. Invalid prefix sizes or active integer metadata throw a `RangeError`. After validating selectors and `NCOLS`, an empty prefix returns `1` without inspecting any input, scratch storage, leading dimension, stride or offset.

#### dlaPorpvgrw.ndarray( uplo, NCOLS, A, ... )

Uses independent element strides and offsets for both matrices and scratch storage. Matrix indices are `offsetA+i*strideA1+j*strideA2` and `offsetAF+i*strideAF1+j*strideAF2`. Logical scratch entry `k` is at `offsetWork+k*strideWork`.

For positive prefixes, all strides and offsets must be signed safe integers and `strideWork` must be nonzero. Negative and nonunit strides are supported; input read strides may also be zero. Only the exact `2*NCOLS` logical scratch entries are written.

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

var A = new Float64Array( [ 4.0, 0.0, 0.0, 0.25 ] );
var AF = new Float64Array( [ 2.0, 0.0, 0.0, 0.5 ] );
var WORK = new Float64Array( 8 );

var v = dlaPorpvgrw.ndarray( 'upper', 2, A, -2, -1, 3, AF, -2, -1, 3, WORK, -2, 6 );
// returns 0.5

// WORK => <Float64Array>[ 4.0, 0.0, 0.25, 0.0, 2.0, 0.0, 0.5, 0.0 ]
```

All referenced matrix and scratch indices must be in bounds. The two read-only inputs may alias each other. Written scratch entries must not overlap either provided input view. These are caller preconditions; exhaustive JavaScript bounds or overlap validation is not promised.

### Notes

- The supported reference-equivalence domain is finite selected entries in the original matrix and supplied Cholesky factor. Synthetic matrix/factor pairs are useful kernel checks but do not establish a successful factorization.
- The implementation scans columns in increasing order, updates maxima only when `abs(value) > maximum`, and updates the ratio only when `ratio < result`. These explicit comparisons define its own special-value behavior. Portable parity with every LAPACK NaN/Infinity observation is not claimed; unchanged reference Fortran produced different Inf/Inf results at different optimization levels.
- The optional native addon uses safe typed views and conservatively requires scalars, indexed arithmetic and scratch counts representable in signed 32-bit integers, including with its ILP64 build. Wider legitimate JavaScript metadata uses the JavaScript implementation. Native bounds checks use intrinsic typed-array metadata and respect typed-array byte offsets.
- The exact package signature and validation choices follow neighboring matrix/scratch conventions and are proposed by this contribution; an accepted routine tracking RFC does not itself adopt this API.
- The algorithm is adapted from [Reference LAPACK DLA_PORPVGRW][lapack-reference]. Its copyright and BSD redistribution terms are retained in `NOTICE`.

</section>

<!-- /.usage -->

<section class="examples">

## Examples

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var dlaPorpvgrw = require( '@stdlib/lapack/base/dla-porpvgrw' );

var A = new Float64Array( [ 0.25, 0.0, 0.0, 4.0 ] );
var AF = new Float64Array( [ 0.5, 0.0, 0.0, 2.0 ] );
var WORK = new Float64Array( 4 );

console.log( dlaPorpvgrw( 'column-major', 'lower', 2, A, 2, AF, 2, WORK ) );
// => 0.5
```

</section>

<!-- /.examples -->

* * *

## C APIs

```c
#include "stdlib/lapack/base/dla_porpvgrw.h"
```

#### c_dla_porpvgrw( layout, uplo, NCOLS, \*A, LDA, \*AF, LDAF, \*WORK )

Computes reciprocal pivot growth using `LAPACK_ROW_MAJOR` or `LAPACK_COL_MAJOR` storage and `LAPACK_UPPER_TRIANGLE` or `LAPACK_LOWER_TRIANGLE`. Inputs are `const double *`; workspace is `double *`. Dimensions, strides and offsets use `LAPACK_INT`.

```c
double API_SUFFIX(c_dla_porpvgrw)( const LAPACK_LAYOUT layout, const LAPACK_UPLO uplo, const LAPACK_INT NCOLS, const double *A, const LAPACK_INT LDA, const double *AF, const LAPACK_INT LDAF, double *WORK );
```

#### c_dla_porpvgrw_ndarray( uplo, NCOLS, \*A, ... )

Uses independent matrix element strides/offsets and nonzero strided scratch.

```c
double API_SUFFIX(c_dla_porpvgrw_ndarray)( const LAPACK_UPLO uplo, const LAPACK_INT NCOLS, const double *A, const LAPACK_INT sa1, const LAPACK_INT sa2, const LAPACK_INT oa, const double *AF, const LAPACK_INT sf1, const LAPACK_INT sf2, const LAPACK_INT of, double *WORK, const LAPACK_INT sw, const LAPACK_INT ow );
```

All indexed element arithmetic, products and scratch counts must fit the configured `LAPACK_INT`, and storage/alias preconditions apply. Invalid selector, negative prefix, oversized scratch count or active zero scratch stride returns NaN. Valid empty prefixes return `1` without accessing pointers or unused metadata. `LAPACK_ILP64` selects 64-bit indices; `CBLAS_API64` independently enables suffixed symbols through `API_SUFFIX`.

```c
#include "stdlib/lapack/base/dla_porpvgrw.h"
#include <stdio.h>

int main( void ) {
const double A[] = { 0.25, 0.0, 0.0, 4.0 };
const double AF[] = { 0.5, 0.0, 0.0, 2.0 };
double WORK[ 4 ];
double value;

value = API_SUFFIX(c_dla_porpvgrw)( LAPACK_ROW_MAJOR, LAPACK_UPPER_TRIANGLE, 2, A, 2, AF, 2, WORK );
printf( "%g\n", value );
return value != 0.5;
}
```

<section class="links">

[lapack-reference]: https://github.com/Reference-LAPACK/lapack/blob/74d4d63747bf1770bb60e1110c2075227baa324e/SRC/dla_porpvgrw.f

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @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';

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var routine = require( './../lib/main.js' );

/**
* Creates a diagonal positive-definite matrix benchmark.
*
* @private
* @param {integer} N - matrix order
* @param {string} uplo - stored triangle
* @returns {Function} benchmark function
*/
function createBenchmark( N, uplo ) {
var WORK = new Float64Array( 2*N );
var AF = new Float64Array( N*N );
var A = new Float64Array( N*N );
var i;

for ( i = 0; i < N; i++ ) {
A[i*(N+1)] = 0.25;
AF[i*(N+1)] = 0.5;
}
return benchmark;

/**
* Measures reciprocal pivot growth.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var value;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
value = routine( 'row-major', uplo, N, A, N, AF, N, WORK );
if ( value !== 0.5 ) {
b.fail( 'unexpected growth factor' );
}
}
b.toc();
b.pass( 'benchmark finished' );
b.end();
}
}

bench( format( '%s:N=4,uplo=upper', pkg ), createBenchmark( 4, 'upper' ) );
bench( format( '%s:N=4,uplo=lower', pkg ), createBenchmark( 4, 'lower' ) );
bench( format( '%s:N=32,uplo=upper', pkg ), createBenchmark( 32, 'upper' ) );
bench( format( '%s:N=32,uplo=lower', pkg ), createBenchmark( 32, 'lower' ) );
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* @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';

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var format = require( '@stdlib/string/format' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
var routine = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': routine instanceof Error
};

/**
* Creates a diagonal positive-definite matrix benchmark.
*
* @private
* @param {integer} N - matrix order
* @param {string} uplo - stored triangle
* @returns {Function} benchmark function
*/
function createBenchmark( N, uplo ) {
var WORK = new Float64Array( 2*N );
var AF = new Float64Array( N*N );
var A = new Float64Array( N*N );
var i;

for ( i = 0; i < N; i++ ) {
A[i*(N+1)] = 0.25;
AF[i*(N+1)] = 0.5;
}
return benchmark;

/**
* Measures reciprocal pivot growth.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var value;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
value = routine( 'row-major', uplo, N, A, N, AF, N, WORK );
if ( value !== 0.5 ) {
b.fail( 'unexpected growth factor' );
}
}
b.toc();
b.pass( 'benchmark finished' );
b.end();
}
}

bench( format( '%s:N=4,uplo=upper', pkg ), opts, createBenchmark( 4, 'upper' ) );
bench( format( '%s:N=4,uplo=lower', pkg ), opts, createBenchmark( 4, 'lower' ) );
bench( format( '%s:N=32,uplo=upper', pkg ), opts, createBenchmark( 32, 'upper' ) );
bench( format( '%s:N=32,uplo=lower', pkg ), opts, createBenchmark( 32, 'lower' ) );
Loading
Loading