-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add lapack/base/dla-gbrpvgrw
#10262
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
prajjwalbajpai
wants to merge
5
commits into
stdlib-js:develop
Choose a base branch
from
prajjwalbajpai:dla_gbrpvgrw
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 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9e666ca
feat: add `lapack/base/dla_gbrpvgrw`
prajjwalbajpai 196b32b
fix: failing markdown examples
prajjwalbajpai e49863a
refactor: rename routine to follow standard
prajjwalbajpai 92532e2
refactor: improve notes in the description of the routine
prajjwalbajpai 60e750d
refactor: update fixtures for better readability
prajjwalbajpai 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
332 changes: 332 additions & 0 deletions
332
lib/node_modules/@stdlib/lapack/base/dla_gbrpvgrw/README.md
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,332 @@ | ||
| <!-- | ||
|
|
||
| @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. | ||
|
|
||
| --> | ||
|
|
||
| # dla_gbrpvgrw | ||
|
|
||
| > LAPACK routine to computes the reciprocal pivot growth factor norm(A)/norm(U) for a general banded matrix `A`. | ||
|
|
||
| <section class="intro"> | ||
|
|
||
| The `dla_gbrpvgrw` routine computes the reciprocal pivot growth factor for a general banded matrix `A`. The factorization has the form: | ||
|
|
||
| <!-- <equation class="equation" label="eq:rpg_factor" align="center" raw="RPGFactor = norm(A) / norm(U)" alt="Equation for calculating RPG Factor."> --> | ||
|
|
||
| ```math | ||
| \text{RPGFactor} = \frac{\text||A||}{\text||U||} | ||
| ``` | ||
|
|
||
| <!-- </equation> --> | ||
|
|
||
|
|
||
| </section> | ||
|
|
||
| <!-- /.intro --> | ||
|
|
||
|
|
||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
|
||
| <!-- eslint-disable camelcase max-len --> | ||
|
|
||
| ```javascript | ||
| var dla_gbrpvgrw = require( '@stdlib/lapack/base/dla_gbrpvgrw' ); | ||
| ``` | ||
|
|
||
| #### dla_gbrpvgrw( order, N, KL, KU, NCOLS, AB, LDAB, AFB, LDAFB ) | ||
|
|
||
| Computes the reciprocal pivot growth factor norm(A)/norm(U) for a general banded matrix `A`. | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var dla_gbrpvgrw = require( '@stdlib/lapack/base/dla_gbrpvgrw' ); | ||
|
|
||
| /* | ||
| A = [ | ||
| [ 1.0, 2.0, 0.0, 0.0 ], | ||
| [ 3.0, 4.0, 5.0, 0.0 ], | ||
| [ 0.0, 6.0, 7.0, 8.0 ], | ||
| [ 0.0, 0.0, 9.0,10.0 ] | ||
| ] | ||
| */ | ||
|
|
||
| var AB = new Float64Array( [ 0.0, 2.0, 5.0, 8.0, 1.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 0.0 ] ); | ||
| var AFB = new Float64Array( [ 0.0, 0.0, 5.0, 8.0, 0.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 1.8272, 0.3333, 0.1111, -0.2716, 0.0 ] ); | ||
|
|
||
| dla_gbrpvgrw( 'row-major', 4, 1, 1, 4, AB, 3, AFB, 4 ); | ||
| // 1.0 | ||
| ``` | ||
|
|
||
| The function has the following parameters: | ||
|
|
||
| - **order**: storage layout. | ||
| - **N**: number of columns in matrix `A`. | ||
| - **KL**: number of subdiagonals within the band of matrix `A`. | ||
| - **KU**: number of superdiagonals within the band of matrix `A`. | ||
| - **NCOLS**: number of columns in matrix `A`. | ||
| - **AB**: the matrix `A` in band storage, stored in linear memory as a [`Float64Array`][mdn-float64array]. | ||
| - **LDAB**: stride of the first dimension of `AB` (a.k.a., leading dimension of the matrix `AB`). | ||
| - **AFB**: the details of the LU factorization of the band matrix `A` stored in linear memory as a [`Float64Array`][mdn-float64array]. | ||
| - **LDAFB**: stride of the first dimension of `AFB` (a.k.a., leading dimension of the matrix `AFB`). | ||
|
|
||
| The function returns the reciprocal pivot growth factor. | ||
|
|
||
| Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. | ||
|
|
||
| <!-- eslint-disable stdlib/capitalized-comments --> | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var dla_gbrpvgrw = require( '@stdlib/lapack/base/dla_gbrpvgrw' ); | ||
|
|
||
| // Initial arrays... | ||
| var AB0 = new Float64Array( [ 0.0, 0.0, 2.0, 5.0, 8.0, 1.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 0.0 ] ); | ||
| var AFB0 = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 8.0, 0.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 1.8272, 0.3333, 0.1111, -0.2716, 0.0 ] ); | ||
|
|
||
| /* | ||
| A = [ | ||
| [ 1.0, 2.0, 0.0, 0.0 ], | ||
| [ 3.0, 4.0, 5.0, 0.0 ], | ||
| [ 0.0, 6.0, 7.0, 8.0 ], | ||
| [ 0.0, 0.0, 9.0,10.0 ] | ||
| ] | ||
| */ | ||
|
|
||
| // Create offset views... | ||
| var AB = new Float64Array( AB0.buffer, AB0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | ||
| var AFB = new Float64Array( AFB0.buffer, AFB0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | ||
|
|
||
| dla_gbrpvgrw( 'row-major', 4, 1, 1, 4, AB, 3, AFB, 4 ); | ||
| // 1.0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here and elsewhere. |
||
| ``` | ||
|
|
||
| <!-- lint disable maximum-heading-length --> | ||
|
|
||
| #### dla_gbrpvgrw.ndarray( N, KL, KU, NCOLS, AB, strideAB1, strideAB2, offsetAB, AFB, strideAFB1, strideAFB2, offsetAFB ) | ||
|
|
||
| Computes the reciprocal pivot growth factor norm(A)/norm(U) for a general banded matrix `A` using alternative indexing semantics. | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var dla_gbrpvgrw = require( '@stdlib/lapack/base/dla_gbrpvgrw' ); | ||
|
|
||
| /* | ||
| A = [ | ||
| [ 1.0, 2.0, 0.0, 0.0 ], | ||
| [ 3.0, 4.0, 5.0, 0.0 ], | ||
| [ 0.0, 6.0, 7.0, 8.0 ], | ||
| [ 0.0, 0.0, 9.0,10.0 ] | ||
| ] | ||
| */ | ||
|
|
||
| var AB = new Float64Array( [ 0.0, 2.0, 5.0, 8.0, 1.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 0.0 ] ); | ||
| var AFB = new Float64Array( [ 0.0, 0.0, 5.0, 8.0, 0.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 1.8272, 0.3333, 0.1111, -0.2716, 0.0 ] ); | ||
|
|
||
| dla_gbrpvgrw.ndarray( 4, 1, 1, 4, AB, 4, 1, 0, AFB, 4, 1, 0 ); | ||
| // 1.0 | ||
| ``` | ||
|
|
||
| The function has the following parameters: | ||
|
|
||
| - **N**: number of columns in matrix `A`. | ||
| - **KL**: number of subdiagonals within the band of matrix `A`. | ||
| - **KU**: number of superdiagonals within the band of matrix `A`. | ||
| - **NCOLS**: number of columns in matrix `A`. | ||
| - **AB**: the matrix `A` in band storage, stored in linear memory as a [`Float64Array`][mdn-float64array]. | ||
| - **strideAB1**: stride of the first dimension of `AB`. | ||
| - **strideAB2**: stride of the second dimension of `AB`. | ||
| - **offsetAB**: index offset for `AB`. | ||
| - **AFB**: the details of the LU factorization of the band matrix `A` stored in linear memory as a [`Float64Array`][mdn-float64array]. | ||
| - **strideAB1**: stride of the first dimension of `AFB`. | ||
| - **strideAB2**: stride of the second dimension of `AFB`. | ||
| - **offsetAB**: index offset for `AFB`. | ||
|
|
||
| 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. For example, | ||
|
|
||
| <!-- eslint-disable max-len --> | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var dla_gbrpvgrw = require( '@stdlib/lapack/base/dla_gbrpvgrw' ); | ||
|
|
||
| /* | ||
| A = [ | ||
| [ 1.0, 2.0, 0.0, 0.0 ], | ||
| [ 3.0, 4.0, 5.0, 0.0 ], | ||
| [ 0.0, 6.0, 7.0, 8.0 ], | ||
| [ 0.0, 0.0, 9.0,10.0 ] | ||
| ] | ||
| */ | ||
|
|
||
| var AB = new Float64Array( [ 0.0, 0.0, 2.0, 5.0, 8.0, 1.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 0.0 ] ); | ||
| var AFB = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 8.0, 0.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 1.8272, 0.3333, 0.1111, -0.2716, 0.0 ] ); | ||
|
|
||
| dla_gbrpvgrw.ndarray( 4, 1, 1, 4, AB, 4, 1, 1, AFB, 4, 1, 1 ); | ||
| // 1.0 | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="notes"> | ||
|
|
||
| ## Notes | ||
|
|
||
| - Matrix `AB` is the matrix A in band storage, in rows 1 to KL+KU+1. The j-th column of A is stored in the j-th column of the matrix `AB` as `AB(KU+1+i-j,j) = A(i,j)` for max(1,j-KU)<=i<=min(N,j+kl). | ||
| - Matrix `AFB` stores the details of the LU factorization of the band matrix A, as computed by `DGBTRF`. `U` is stored as an upper triangular band matrix with KL+KU superdiagonals in rows 1 to `KL`+`KU`+1, and the multipliers used during the factorization are stored in rows `KL`+`KU`+2 to 2*`KL`+`KU`+1. | ||
| - The leading dimension of `AB`, `LDAB` >= KL+KU+1. | ||
| - The leading dimension of `AFB`, `LDAFB` >= 2*KL+KU+1. | ||
| - `dla_gbrpvgrw()` corresponds to the [LAPACK][LAPACK] function [`dla_gbrpvgrw`][lapack-dla_gbrpvgrw]. | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.notes --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| <!-- eslint-disable max-len --> | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); | ||
| var dla_gbrpvgrw = require( '@stdlib/lapack/base/dla_gbrpvgrw' ); | ||
|
|
||
| var N = 4; | ||
| var KL = 1; | ||
| var KU = 1; | ||
| var NCOLS = 4; | ||
| var LDAB = 3; | ||
| var LDAFB = 4; | ||
|
|
||
| var AB = new Float64Array( [ 0.0, 2.0, 5.0, 8.0, 1.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 0.0 ] ); | ||
| var AFB = new Float64Array( [ 0.0, 0.0, 5.0, 8.0, 0.0, 4.0, 7.0, 10.0, 3.0, 6.0, 9.0, 1.8272, 0.3333, 0.1111, -0.2716, 0.0 ] ); | ||
|
|
||
| console.log( 'The matrix `AB` i.e, the matrix `A` in band storage, in rows 1 to KL+KU+1:' ); | ||
| console.log( ndarray2array( AB, [ LDAB, N ], [ N, 1 ], 0, 'row-major' ) ); | ||
|
|
||
| console.log( 'The matrix `AFB` containing the details of the LU factorization of the band matrix `A`, as computed by `DGBTRF`:' ); | ||
| console.log( ndarray2array( AFB, [ LDAFB, N ], [ N, 1 ], 0, 'row-major' ) ); | ||
|
|
||
| console.log( 'The reciprocal pivot growth factor norm(A)/norm(U) for `AB`:' ); | ||
| console.log( dla_gbrpvgrw( 'row-major', N, KL, KU, NCOLS, AB, LDAB, AFB, LDAFB ) ); | ||
| ``` | ||
|
|
||
| </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-dla_gbrpvgrw]: https://netlib.org/lapack/explore-html//d1/ddf/group__la__gbrpvgrw_ga8475794e57172d20803e770faa7d4543.html | ||
|
|
||
| [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 --> | ||
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.
This isn't how we do returns annotations.