-
-
Notifications
You must be signed in to change notification settings - Fork 844
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
aayush0325
wants to merge
29
commits into
stdlib-js:develop
Choose a base branch
from
aayush0325:lapack-dppequ
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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 b5618f1
feat: add exports
aayush0325 b7e80eb
feat: merge loops
aayush0325 9bb5c38
feat: add main export
aayush0325 fab8873
test: add initial tests
aayush0325 51ad33f
test: add initial ndarray tests
aayush0325 ccda72f
test: add initial ndarray tests
aayush0325 dc0dfd0
test: add tests
aayush0325 7ac07fd
test: add N=0 case
aayush0325 7ff79c8
test: add non positive diagonal element tests
aayush0325 9de21b0
test: add ndarray tests
aayush0325 2be7e95
Merge remote-tracking branch 'upstream/develop' into lapack-dppequ
stdlib-bot b2d8e26
test: add tests for negative strides
aayush0325 b896286
test: add tests
aayush0325 d978c69
test: add offset tests
aayush0325 9fd55a0
refactor: pointer arithmmetic
aayush0325 37b6731
refactor: pointer arithmetic
aayush0325 5b87ba7
docs: add description
aayush0325 a8ca2ba
refactor: use stdlib conventions
aayush0325 0e9907c
test: add test to check uplo
aayush0325 6ee35de
test: add tests for large strides
aayush0325 5cda5cf
test: add tests for mixed strides
aayush0325 d3d405e
bench: add benchmarks
aayush0325 78282b8
docs: add index.d.ts
aayush0325 d2b6b3f
test: add ts tests
aayush0325 69a3907
docs: add notes
aayush0325 45d15f0
docs: add README
aayush0325 8fa0925
docs: add repl.txt
aayush0325 08fe080
chore: cleanup
aayush0325 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). | ||
* | ||
* @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 | ||
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' | ||
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' | ||
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' | ||
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 | ||
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 | ||
out[ offsetOut + strideOut ] = amax; // amax | ||
info = 0; | ||
return info; | ||
} | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = dppequ; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.