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
Changes from 1 commit
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
126 changes: 126 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 sqrt = require( '@stdlib/math/base/special/sqrt' );
var max = require( '@stdlib/math/base/special/max' );
var min = require( '@stdlib/math/base/special/min' );


// MAIN //

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

Check warning on line 31 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "scalings"
*
* @param {string} order - specifies whether `AP` is packed in row-major or column-major order
* @param {string} uplo - 'Upper' or 'Lower' triangle of `A` is stored
* @param {NonNegativeInteger} N - order of the matrix `A`
* @param {Float64Array} AP - array containing the upper or lower triangle of `A` in packed form
* @param {integer} strideAP - stride length for `AP`
* @param {integer} offsetAP - starting index for `AP`
* @param {Float64Array} S - array to store the scale factors of `A`
* @param {integer} strideS - stride length for `S`
* @param {integer} offsetS - starting index for `S`
* @param {Float64Array} out - array to store the output
* @param {integer} strideOut - stride length for `out`
* @param {integer} offsetOut - starting index for `out`
* @returns {integer} status code
*/
function dppequ( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, out, strideOut, offsetOut ) { // eslint-disable-line max-len, max-params
var info;
var smin;
var amax;
var jj;
var i;

if ( N === 0 ) {
out[ offsetOut ] = 1.0; // scond

Check warning on line 55 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "scond"
out[ offsetOut + strideOut ] = 0.0; // amax
return 0; // info
}

S[ offsetAP ] = AP[ offsetAP ];
smin = S[ offsetAP ];
amax = S[ offsetAP ];

if ( order === 'row-major' ) {
if ( uplo === 'U' ) { // uplo === 'U'
jj = 0;
for ( i = 1; i < N; i++ ) {
jj += N - i + 1;
S[ offsetS + (i * strideS) ] = AP[ offsetAP + (jj * strideAP) ];
smin = min( smin, S[ offsetS + (i * strideS) ] );
amax = max( amax, S[ offsetS + (i * strideS) ] );
}
} else { // uplo === 'L'

Check warning on line 73 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "uplo"
jj = 0;
for ( i = 1; i < N; i++ ) {
jj += i + 1;
S[ offsetS + (i * strideS) ] = AP[ offsetAP + (jj * strideAP) ];
smin = min( smin, S[ offsetS + (i * strideS) ] );
amax = max( amax, S[ offsetS + (i * strideS) ] );
}
}
} else { // order === 'col-major'
if ( uplo === 'U' ) { // uplo === 'U'

Check failure on line 83 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected if as the only statement in an else block
jj = 0;
for ( i = 1; i < N; i++ ) {
jj += i + 1;
S[ offsetS + (i * strideS) ] = AP[ offsetAP + (jj * strideAP) ];
smin = min( smin, S[ offsetS + (i * strideS) ] );
amax = max( amax, S[ offsetS + (i * strideS) ] );
}
} else { // uplo === 'L'

Check warning on line 91 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "uplo"
jj = 0;
for ( i = 1; i < N; i++ ) {
jj += N - i + 1;
S[ offsetS + (i * strideS) ] = AP[ offsetAP + (jj * strideAP) ];
smin = min( smin, S[ offsetS + (i * strideS) ] );
amax = max( amax, S[ offsetS + (i * strideS) ] );
}
}
}

if ( smin <= 0.0 ) {
for ( i = 0; i < N; i++ ) {
if ( S[ offsetS + (i * strideS) ] <= 0.0 ) {
out[ offsetOut ] = 0.0; // scond

Check warning on line 105 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "scond"
out[ offsetOut + strideOut ] = amax; // amax
info = i;
return info;
}
}
} else {
for ( i = 0; i < N; i++ ) {
S[ offsetS + (i * strideS) ] = 1.0 / sqrt( S[ offsetS + (i * strideS) ] ); // eslint-disable-line max-len
}
}

out[ offsetOut ] = sqrt( smin ) / sqrt( amax ); // scond

Check warning on line 117 in lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "scond"
out[ offsetOut + strideOut ] = amax; // amax
info = 0;
return info;
}


// EXPORTS //

module.exports = dppequ;
Loading