-
-
Notifications
You must be signed in to change notification settings - Fork 843
feat: add lapack/base/dlanv2
#7492
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
15
commits into
stdlib-js:develop
Choose a base branch
from
aayush0325:lapack-dlanv2
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.
+5,357
−0
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
90c0491
feat: add lapack/base/dlanv2
aayush0325 f072be6
docs: add missing jsdoc example
aayush0325 8fbcb55
feat: add main exports
aayush0325 2e13486
test: add tests
aayush0325 0ef0464
test: add z tests
aayush0325 222a922
test: add ndarray tests
aayush0325 f16759d
test: achieve 100% code coverage
aayush0325 03a8196
test: add ndarray tests
aayush0325 aabd565
test: add offset tests
aayush0325 ecaad2a
feat: add examples and benchmarks
aayush0325 d58f9f2
docs: add index.d.ts
aayush0325 273099d
docs: add ts files
aayush0325 47b35fd
docs: update description
aayush0325 ae65ee9
docs: add readme
aayush0325 cebf9eb
docs: add repl.txt
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
Large diffs are not rendered by default.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
lib/node_modules/@stdlib/lapack/base/dlanv2/benchmark/benchmark.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,77 @@ | ||
/** | ||
* @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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var pkg = require( './../package.json' ).name; | ||
var dlanv2 = require( './../lib/dlanv2.js' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var opts = { | ||
'dtype': 'float64' | ||
}; | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg, function benchmark( b ) { | ||
var RT1R; | ||
var RT1I; | ||
var RT2R; | ||
var RT2I; | ||
var CS; | ||
var SN; | ||
var A; | ||
var B; | ||
var C; | ||
var D; | ||
var i; | ||
|
||
A = discreteUniform( 1, -50, 50, opts ); | ||
B = discreteUniform( 1, -50, 50, opts ); | ||
C = discreteUniform( 1, -50, 50, opts ); | ||
D = discreteUniform( 1, -50, 50, opts ); | ||
RT1R = new Float64Array( 1 ); | ||
RT1I = new Float64Array( 1 ); | ||
RT2R = new Float64Array( 1 ); | ||
RT2I = new Float64Array( 1 ); | ||
CS = new Float64Array( 1 ); | ||
SN = new Float64Array( 1 ); | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
dlanv2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN ); | ||
if ( isnan( A[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( B[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
77 changes: 77 additions & 0 deletions
77
lib/node_modules/@stdlib/lapack/base/dlanv2/benchmark/benchmark.ndarray.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,77 @@ | ||
/** | ||
* @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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var pkg = require( './../package.json' ).name; | ||
var dlanv2 = require( './../lib/ndarray.js' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var opts = { | ||
'dtype': 'float64' | ||
}; | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg, function benchmark( b ) { | ||
var RT1R; | ||
var RT1I; | ||
var RT2R; | ||
var RT2I; | ||
var CS; | ||
var SN; | ||
var A; | ||
var B; | ||
var C; | ||
var D; | ||
var i; | ||
|
||
A = discreteUniform( 1, -50, 50, opts ); | ||
B = discreteUniform( 1, -50, 50, opts ); | ||
C = discreteUniform( 1, -50, 50, opts ); | ||
D = discreteUniform( 1, -50, 50, opts ); | ||
RT1R = new Float64Array( 1 ); | ||
RT1I = new Float64Array( 1 ); | ||
RT2R = new Float64Array( 1 ); | ||
RT2I = new Float64Array( 1 ); | ||
CS = new Float64Array( 1 ); | ||
SN = new Float64Array( 1 ); | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
dlanv2( A, 0, B, 0, C, 0, D, 0, RT1R, 0, RT1I, 0, RT2R, 0, RT2I, 0, CS, 0, SN, 0 ); // eslint-disable-line max-len | ||
if ( isnan( A[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( B[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
216 changes: 216 additions & 0 deletions
216
lib/node_modules/@stdlib/lapack/base/dlanv2/docs/repl.txt
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,216 @@ | ||
{{alias}}( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN ) | ||
Computes the real Schur factorization of a 2-by-2 real nonsymmetric | ||
matrix using an orthogonal similarity transformation. | ||
|
||
Given matrix: | ||
|
||
[ A B ] | ||
[ C D ] | ||
|
||
The routine computes an orthogonal rotation (cosine CS, sine SN) such | ||
that: | ||
|
||
Q^T * [ A B ] * Q = [ AA BB ] | ||
[ C D ] [ CC DD ] | ||
|
||
where Q is a 2x2 rotation matrix: | ||
|
||
Q = [ CS SN ] | ||
[ -SN CS ] | ||
|
||
and the result is either real upper triangular (real eigenvalues) or | ||
2x2 block diagonal (complex conjugate eigenvalues). | ||
|
||
Indexing is relative to the first index. To introduce an offset, use | ||
typed array views. | ||
|
||
Parameters | ||
---------- | ||
A: Float64Array | ||
Input element A(1,1). | ||
|
||
B: Float64Array | ||
Input element A(1,2). | ||
|
||
C: Float64Array | ||
Input element A(2,1). | ||
|
||
D: Float64Array | ||
Input element A(2,2). | ||
|
||
RT1R: Float64Array | ||
Output: real part of the first eigenvalue. | ||
|
||
RT1I: Float64Array | ||
Output: imaginary part of the first eigenvalue. | ||
|
||
RT2R: Float64Array | ||
Output: real part of the second eigenvalue. | ||
|
||
RT2I: Float64Array | ||
Output: imaginary part of the second eigenvalue. | ||
|
||
CS: Float64Array | ||
Output: cosine of the rotation. | ||
|
||
SN: Float64Array | ||
Output: sine of the rotation. | ||
|
||
Returns | ||
------- | ||
undefined | ||
|
||
Examples | ||
-------- | ||
> var Float64Array = require( '@stdlib/array/float64' ); | ||
> var dlanv2 = require( '@stdlib/lapack/base/dlanv2' ); | ||
|
||
> var A = new Float64Array( [ 4.0 ] ); | ||
> var B = new Float64Array( [ -5.0 ] ); | ||
> var C = new Float64Array( [ 2.0 ] ); | ||
> var D = new Float64Array( [ -3.0 ] ); | ||
> var RT1R = new Float64Array( 1 ); | ||
> var RT1I = new Float64Array( 1 ); | ||
> var RT2R = new Float64Array( 1 ); | ||
> var RT2I = new Float64Array( 1 ); | ||
> var CS = new Float64Array( 1 ); | ||
> var SN = new Float64Array( 1 ); | ||
|
||
> dlanv2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN ); | ||
|
||
> A | ||
<Float64Array>[ 2.0 ] | ||
> B | ||
<Float64Array>[ -7.0 ] | ||
> C | ||
<Float64Array>[ 0.0 ] | ||
> D | ||
<Float64Array>[ -1.0 ] | ||
> RT1R | ||
<Float64Array>[ 2.0 ] | ||
> RT1I | ||
<Float64Array>[ 0.0 ] | ||
> RT2R | ||
<Float64Array>[ -1.0 ] | ||
> RT2I | ||
<Float64Array>[ 0.0 ] | ||
> CS | ||
<Float64Array>[ ~0.93 ] | ||
> SN | ||
<Float64Array>[ ~0.34 ] | ||
|
||
{{alias}}.ndarray( A,oa,B,ob,C,oc,D,od,R1,or1,I1,oi1,R2,or2,I2,oi2,CS,ocs,SN,osn ) | ||
|
||
Computes the Schur factorization of a 2-by-2 real nonsymmetric matrix | ||
using alternative indexing semantics. | ||
|
||
Given matrix: | ||
|
||
[ A B ] | ||
[ C D ] | ||
|
||
The routine computes an orthogonal rotation (cosine CS, sine SN) such | ||
that: | ||
|
||
Q^T * [ A B ] * Q = [ AA BB ] | ||
[ C D ] [ CC DD ] | ||
|
||
where Q is a 2x2 rotation matrix: | ||
|
||
Q = [ CS SN ] | ||
[ -SN CS ] | ||
|
||
and the result is either real upper triangular (real eigenvalues) or | ||
2x2 block diagonal (complex conjugate eigenvalues). | ||
|
||
While typed array views mandate a view offset based on the underlying | ||
buffer, the offset parameters support indexing semantics based on starting | ||
indices. | ||
|
||
Parameters | ||
---------- | ||
A: Float64Array | ||
Input element A(1,1). | ||
|
||
oa: integer | ||
Starting index for `A`. | ||
|
||
B: Float64Array | ||
Input element A(1,2). | ||
|
||
ob: integer | ||
Starting index for `B`. | ||
|
||
C: Float64Array | ||
Input element A(2,1). | ||
|
||
oc: integer | ||
Starting index for `C`. | ||
|
||
D: Float64Array | ||
Input element A(2,2). | ||
|
||
od: integer | ||
Starting index for `D`. | ||
|
||
R1: Float64Array | ||
Output: real part of the first eigenvalue. | ||
|
||
or1: integer | ||
Starting index for `R1`. | ||
|
||
I1: Float64Array | ||
Output: imaginary part of the first eigenvalue. | ||
|
||
oi1: integer | ||
Starting index for `I1`. | ||
|
||
R2: Float64Array | ||
Output: real part of the second eigenvalue. | ||
|
||
or2: integer | ||
Starting index for `R2`. | ||
|
||
I2: Float64Array | ||
Output: imaginary part of the second eigenvalue. | ||
|
||
oi2: integer | ||
Starting index for `I2`. | ||
|
||
CS: Float64Array | ||
Output: cosine of the rotation. | ||
|
||
ocs: integer | ||
Starting index for `CS`. | ||
|
||
SN: Float64Array | ||
Output: sine of the rotation. | ||
|
||
osn: integer | ||
Starting index for `SN`. | ||
|
||
Examples | ||
-------- | ||
> var Float64Array = require( '@stdlib/array/float64' ); | ||
> var A = new Float64Array( [ 0.0, 4.0 ] ); | ||
> var B = new Float64Array( [ 0.0, -5.0 ] ); | ||
> var C = new Float64Array( [ 0.0, 2.0 ] ); | ||
> var D = new Float64Array( [ 0.0, -3.0 ] ); | ||
> var RT1R = new Float64Array( 2 ); | ||
> var RT1I = new Float64Array( 2 ); | ||
> var RT2R = new Float64Array( 2 ); | ||
> var RT2I = new Float64Array( 2 ); | ||
> var CS = new Float64Array( 2 ); | ||
> var SN = new Float64Array( 2 ); | ||
|
||
> dlanv2.ndarray( A, 1, B, 1, C, 1, D, 1, | ||
RT1R, 1, RT1I, 1, RT2R, 1, RT2I, 1, CS, 1, SN, 1 ); | ||
|
||
> A | ||
<Float64Array>[ 0.0, 2.0 ] | ||
> C | ||
<Float64Array>[ 0.0, 0.0 ] | ||
> RT1R | ||
<Float64Array>[ 0.0, 2.0 ] | ||
> RT2R | ||
<Float64Array>[ 0.0, -1.0 ] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need help with the heading here, failing at 80+ characters