Repository navigation
feat: add lapack/base/dlartgp
#9608
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:dlartgp
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2928651
feat: add `lapack/base/dlartgp`
prajjwalbajpai 2f37ede
Clarify LAPACK routine comment in index.js
prajjwalbajpai 09ab277
Fix positioning of negative r check if loop
prajjwalbajpai 3788a1d
fix: add testcases to `dlartgp` to improve coverage
prajjwalbajpai f84dfdc
Merge branch 'develop' into dlartgp
kgryte 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
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,220 @@ | ||
| <!-- | ||
|
|
||
| @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. | ||
|
|
||
| --> | ||
|
|
||
| # dlartgp | ||
|
|
||
| > Generates a plane rotation so that the diagonal is nonnegative. | ||
|
|
||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```javascript | ||
| var dlartgp = require( '@stdlib/lapack/base/dlartgp' ); | ||
| ``` | ||
|
|
||
| #### dlartgp( F, G, out ) | ||
|
|
||
| Generates a plane rotation so that the diagonal is nonnegative. | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
|
|
||
| var out = new Float64Array( 3 ); | ||
| dlartgp( 1.0, 2.0, out ); | ||
| // out => <Float64Array>[ ~0.447, ~0.894, ~2.236 ] | ||
| ``` | ||
|
|
||
| The function has the following parameters: | ||
|
|
||
| - **F**: the first component of vector to be rotated. | ||
| - **G**: the second component of vector to be rotated. | ||
| - **out**: output [`Float64Array`][mdn-float64array] output array containing the cosine and sine of the rotation and the non zero component of the rotated vector. | ||
|
|
||
| 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' ); | ||
|
|
||
| // Initial array: | ||
| var out0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); | ||
|
|
||
| // Create an offset view... | ||
| var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | ||
|
|
||
| dlartgp( 1.0, 2.0, out1 ); | ||
| // out0 => <Float64Array>[ 0.0, ~0.447, ~0.894, ~2.236 ] | ||
| ``` | ||
|
|
||
| #### dlartgp.ndarray( F, G, out, strideOut, offsetOut ) | ||
|
|
||
| Generates a plane rotation so that the diagonal is nonnegative using alternative indexing semantics. | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
|
|
||
| var out = new Float64Array( 3 ); | ||
| dlartgp.ndarray( 1.0, 2.0, out, 1, 0 ); | ||
| // out => <Float64Array>[ ~0.447, ~0.894, ~2.236 ] | ||
| ``` | ||
|
|
||
| The function has the following additional parameters: | ||
|
|
||
| - **strideOut**: stride length for `out`. | ||
| - **offsetOut**: starting index of `out` | ||
|
|
||
| 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, | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
|
|
||
| var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); | ||
| dlartgp.ndarray( 1.0, 2.0, out, -1, 3 ); | ||
| // out => <Float64Array>[ 0.0, ~2.236, ~0.894, ~0.447 ] | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="notes"> | ||
|
|
||
| ## Notes | ||
|
|
||
| - `dlartgp()` corresponds to the [LAPACK][lapack] routine [`dlartgp`][lapack-dlartgp]. | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.notes --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var dlartgp = require( '@stdlib/lapack/base/dlartgp' ); | ||
|
|
||
| var out = new Float64Array( 3 ); | ||
| dlartgp( 1.0, 2.0, out ); | ||
| console.log( out ); | ||
| ``` | ||
|
|
||
| </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-dlartgp]: https://www.netlib.org/lapack/explore-html/d6/db2/group__lartgp_gaf4d25f845ad7e0a3c474b3ebe45e7223.html#gaf4d25f845ad7e0a3c474b3ebe45e7223 | ||
|
|
||
| [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 --> |
57 changes: 57 additions & 0 deletions
57
lib/node_modules/@stdlib/lapack/base/dlartgp/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,57 @@ | ||
| /** | ||
| * @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'; | ||
|
|
||
| // MODULES // | ||
|
|
||
| var bench = require( '@stdlib/bench' ); | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var randu = require( '@stdlib/random/base/randu' ); | ||
| var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
| var pkg = require( './../package.json' ).name; | ||
| var dlartgp = require( './../lib/dlartgp.js' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( pkg, function benchmark( b ) { | ||
| var out; | ||
| var A; | ||
| var B; | ||
| var i; | ||
|
|
||
| b.tic(); | ||
| A = ( randu() * 100.0 ) - 50.0; | ||
| B = ( randu() * 100.0 ) - 50.0; | ||
| out = new Float64Array( 3 ); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| out = dlartgp( A, B, out ); | ||
| A = out[ i%out.length ]; | ||
| B = out[ i%out.length ]; | ||
| if ( isnan( out[ i%out.length ] ) ) { | ||
| b.fail( 'should not return NaN' ); | ||
| } | ||
| } | ||
| b.toc(); | ||
| if ( isnan( out[ i%out.length ] ) ) { | ||
| b.fail( 'should not return NaN' ); | ||
| } | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); |
58 changes: 58 additions & 0 deletions
58
lib/node_modules/@stdlib/lapack/base/dlartgp/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,58 @@ | ||
| /** | ||
| * @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'; | ||
|
|
||
| // MODULES // | ||
|
|
||
| var bench = require( '@stdlib/bench' ); | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var randu = require( '@stdlib/random/base/randu' ); | ||
| var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
| var pkg = require( './../package.json' ).name; | ||
| var dlartgp = require( './../lib/ndarray.js' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( pkg+':ndarray', function benchmark( b ) { | ||
| var out; | ||
| var A; | ||
| var B; | ||
| var i; | ||
|
|
||
| A = ( randu() * 100.0 ) - 50.0; | ||
| B = ( randu() * 100.0 ) - 50.0; | ||
| out = new Float64Array( 3 ); | ||
|
|
||
| b.tic(); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| out = dlartgp( A, B, out, 1, 0 ); | ||
| A = out[ i%out.length ]; | ||
| B = out[ i%out.length ]; | ||
| if ( isnan( out[ i%out.length ] ) ) { | ||
| b.fail( 'should not return NaN' ); | ||
| } | ||
| } | ||
| b.toc(); | ||
| if ( isnan( out[ i%out.length ] ) ) { | ||
| b.fail( 'should not return NaN' ); | ||
| } | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); | ||
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.
@prajjwalbajpai Mind updating this to use
format? Cheers!