-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add lapack/base/dlabad
#12264
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
iampratik13
wants to merge
3
commits into
stdlib-js:develop
Choose a base branch
from
iampratik13:lapack/dlabad
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
feat: add lapack/base/dlabad
#12264
Changes from all commits
Commits
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,216 @@ | ||
| <!-- | ||
|
|
||
| @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. | ||
|
|
||
| --> | ||
|
|
||
| # dlabad | ||
|
|
||
| > Adjust the underflow and overflow thresholds if the exponent range is very large. | ||
|
|
||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```javascript | ||
| var dlabad = require( '@stdlib/lapack/base/dlabad' ); | ||
| ``` | ||
|
|
||
| #### dlabad( SMALL, LARGE ) | ||
|
|
||
| Adjusts the underflow and overflow thresholds if the exponent range is very large. | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
|
|
||
| var SMALL = new Float64Array( [ 2.2250738585072014e-308 ] ); | ||
| var LARGE = new Float64Array( [ 1.7976931348623157e+308 ] ); | ||
|
|
||
| dlabad( SMALL, LARGE ); | ||
| // SMALL => <Float64Array>[ 2.2250738585072014e-308 ] | ||
| // LARGE => <Float64Array>[ 1.7976931348623157e+308 ] | ||
| ``` | ||
|
|
||
| The function has the following parameters: | ||
|
|
||
| - **SMALL**: [`Float64Array`][mdn-float64array] containing a single element equal to the underflow threshold. | ||
| - **LARGE**: [`Float64Array`][mdn-float64array] containing a single element equal to the overflow threshold. | ||
|
|
||
| #### dlabad.ndarray( SMALL, offsetSMALL, LARGE, offsetLARGE ) | ||
|
|
||
| Adjusts the underflow and overflow thresholds if the exponent range is very large using alternative indexing semantics. | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
|
|
||
| var SMALL = new Float64Array( [ 2.2250738585072014e-308 ] ); | ||
| var LARGE = new Float64Array( [ 1.7976931348623157e+308 ] ); | ||
|
|
||
| dlabad.ndarray( SMALL, 0, LARGE, 0 ); | ||
| // SMALL => <Float64Array>[ 2.2250738585072014e-308 ] | ||
| // LARGE => <Float64Array>[ 1.7976931348623157e+308 ] | ||
| ``` | ||
|
|
||
| The function has the following parameters: | ||
|
|
||
| - **SMALL**: [`Float64Array`][mdn-float64array] containing an element equal to the underflow threshold. | ||
| - **offsetSMALL**: index of the element in `SMALL`. | ||
| - **LARGE**: [`Float64Array`][mdn-float64array] containing an element equal to the overflow threshold. | ||
| - **offsetLARGE**: index of the element in `LARGE`. | ||
|
|
||
| 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 SMALL = new Float64Array( [ 0.0, 2.2250738585072014e-308, 0.0 ] ); | ||
| var LARGE = new Float64Array( [ 0.0, 0.0, 1.7976931348623157e+308 ] ); | ||
|
|
||
| dlabad.ndarray( SMALL, 1, LARGE, 2 ); | ||
| // SMALL => <Float64Array>[ 0.0, 2.2250738585072014e-308, 0.0 ] | ||
| // LARGE => <Float64Array>[ 0.0, 0.0, 1.7976931348623157e+308 ] | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="notes"> | ||
|
|
||
| ## Notes | ||
|
|
||
| - `dlabad()` corresponds to the [LAPACK][LAPACK] function [`dlabad`][lapack-dlabad]. | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.notes --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var dlabad = require( '@stdlib/lapack/base/dlabad' ); | ||
|
|
||
| var SMALL = new Float64Array( [ 2.2250738585072014e-308 ] ); | ||
| var LARGE = new Float64Array( [ 1.7976931348623157e+308 ] ); | ||
|
|
||
| dlabad( SMALL, LARGE ); | ||
| console.log( 'SMALL:', SMALL[ 0 ] ); | ||
| console.log( 'LARGE:', LARGE[ 0 ] ); | ||
| ``` | ||
|
|
||
| </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"> | ||
|
|
||
| [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | ||
|
|
||
| [lapack-dlabad]: https://www.netlib.org/lapack/explore-html/db/d91/group__labad_ga469557789831c29949bf455ca3b1dda5.html | ||
|
|
||
| [mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array | ||
|
|
||
| [lapack]: https://www.netlib.org/lapack/explore-html/ | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.links --> |
46 changes: 46 additions & 0 deletions
46
lib/node_modules/@stdlib/lapack/base/dlabad/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,46 @@ | ||
| /** | ||
| * @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 pkg = require( './../package.json' ).name; | ||
| var dlabad = require( './../lib' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( pkg, function benchmark( b ) { | ||
| var SMALL; | ||
| var LARGE; | ||
| var i; | ||
|
|
||
| SMALL = new Float64Array( [ 2.2250738585072014e-308 ] ); | ||
| LARGE = new Float64Array( [ 1.7976931348623157e+308 ] ); | ||
|
|
||
| b.tic(); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| dlabad( SMALL, LARGE ); | ||
| } | ||
| b.toc(); | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); |
47 changes: 47 additions & 0 deletions
47
lib/node_modules/@stdlib/lapack/base/dlabad/benchmark/benchmark.ndarray.js
|
Contributor
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. /**
* @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 uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var FLOAT64_MAX = require( '@stdlib/constants/float64/max' );
var FLOAT64_SMALLEST_NORMAL = require( '@stdlib/constants/float64/smallest-normal' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var dlabad = require( './../lib/ndarray.js' );
// VARIABLES //
var options = {
'dtype': 'float64'
};
// MAIN //
bench( format( '%s:ndarray', pkg ), function benchmark( b ) {
var SMALL;
var LARGE;
var N;
var i;
var j;
var k;
N = 100;
SMALL = uniform( N, FLOAT64_SMALLEST_NORMAL, 1.0e-200, options );
LARGE = uniform( N, 1.0e+200, FLOAT64_MAX, options );
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % N;
k = ( i+1 ) % N;
dlabad( SMALL, j, LARGE, k );
if ( isnan( SMALL[ j ] ) || isnan( LARGE[ k ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( SMALL[ j ] ) || isnan( LARGE[ k ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});Similar version. |
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,47 @@ | ||
| /** | ||
| * @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 format = require( '@stdlib/string/format' ); | ||
| var pkg = require( './../package.json' ).name; | ||
| var dlabad = require( './../lib' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( format( '%s:ndarray', pkg ), function benchmark( b ) { | ||
| var SMALL; | ||
| var LARGE; | ||
| var i; | ||
|
|
||
| SMALL = new Float64Array( [ 2.2250738585072014e-308 ] ); | ||
| LARGE = new Float64Array( [ 1.7976931348623157e+308 ] ); | ||
|
|
||
| b.tic(); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| dlabad.ndarray( SMALL, 0, LARGE, 0 ); | ||
| } | ||
| b.toc(); | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); |
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,61 @@ | ||
|
|
||
| {{alias}}( SMALL, LARGE ) | ||
| Adjust the underflow and overflow thresholds if the exponent range is | ||
| very large. | ||
|
|
||
| Indexing is relative to the first index. To introduce an offset, use typed | ||
| array views. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| SMALL: Float64Array | ||
| Array containing a single element equal to the underflow threshold. | ||
|
|
||
| LARGE: Float64Array | ||
| Array containing a single element equal to the overflow threshold. | ||
|
|
||
| Examples | ||
| -------- | ||
| > var SMALL = new {{alias:@stdlib/array/float64}}( [ 2.2250738585072014e-308 ] ); | ||
| > var LARGE = new {{alias:@stdlib/array/float64}}( [ 1.7976931348623157e+308 ] ); | ||
| > {{alias}}( SMALL, LARGE ); | ||
| > SMALL | ||
| <Float64Array>[ 2.2250738585072014e-308 ] | ||
| > LARGE | ||
| <Float64Array>[ 1.7976931348623157e+308 ] | ||
|
|
||
|
|
||
| {{alias}}.ndarray( SMALL, offsetSMALL, LARGE, offsetLARGE ) | ||
| Adjust the underflow and overflow thresholds if the exponent range is | ||
| very large using alternative indexing semantics. | ||
|
|
||
| While typed array views mandate a view offset based on the underlying | ||
| buffer, the offset parameters support indexing semantics based on starting | ||
| indices. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| SMALL: Float64Array | ||
| Array containing an element equal to the underflow threshold. | ||
|
|
||
| offsetSMALL: integer | ||
| Index of the element in `SMALL`. | ||
|
|
||
| LARGE: Float64Array | ||
| Array containing an element equal to the overflow threshold. | ||
|
|
||
| offsetLARGE: integer | ||
| Index of the element in `LARGE`. | ||
|
|
||
| Examples | ||
| -------- | ||
| > var SMALL = new {{alias:@stdlib/array/float64}}( [ 0.0, 2.2250738585072014e-308, 0.0 ] ); | ||
| > var LARGE = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.7976931348623157e+308 ] ); | ||
| > {{alias}}.ndarray( SMALL, 1, LARGE, 2 ); | ||
| > SMALL | ||
| <Float64Array>[ 0.0, 2.2250738585072014e-308, 0.0 ] | ||
| > LARGE | ||
| <Float64Array>[ 0.0, 0.0, 1.7976931348623157e+308 ] | ||
|
|
||
| See Also | ||
| -------- |
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.
I think this approach seems more consistent. Reference:
stdlib/lapack/base/dladivUh oh!
There was an error while loading. Please reload this page.
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.
Thoughts, @iampratik13?