feat: add lapack/base/dlabad#12264
Open
iampratik13 wants to merge 3 commits into
Open
Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg_readmes
status: passed
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg_readmes
status: passed
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Contributor
There was a problem hiding this comment.
/**
* @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 Float64Array = require( '@stdlib/array/float64' );
var FLOAT64_MAX = require( '@stdlib/constants/float64/max' );
var FLOAT64_SMALLEST_NORMAL = require( '@stdlib/constants/float64/smallest-normal' );
var pkg = require( './../package.json' ).name;
var dlabad = require( './../lib' );
// VARIABLES //
var options = {
'dtype': 'float64'
};
// MAIN //
bench( pkg, function benchmark( b ) {
var LARGE;
var SMALL;
var large;
var small;
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 );
SMALL = new Float64Array( 1 );
LARGE = new Float64Array( 1 );
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % N;
k = ( i+1 ) % N;
SMALL[ 0 ] = small[ j ];
LARGE[ 0 ] = large[ k ];
dlabad( SMALL, LARGE );
if ( isnan( SMALL[ 0 ] ) || isnan( LARGE[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( SMALL[ 0 ] ) || isnan( LARGE[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});I think this approach seems more consistent. Reference: stdlib/lapack/base/dladiv
Contributor
There was a problem hiding this comment.
/**
* @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.
Comment on lines
+49
to
+54
| function dlabad( SMALL, offsetSMALL, LARGE, offsetLARGE ) { | ||
| if ( log10( LARGE[ offsetLARGE ] ) > 2000.0 ) { | ||
| SMALL[ offsetSMALL ] = sqrt( SMALL[ offsetSMALL ] ); | ||
| LARGE[ offsetLARGE ] = sqrt( LARGE[ offsetLARGE ] ); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
I'm unsure how useful this is in JS. We only have IEEE-754 doubles, so log10( LARGE ) never exceeds 2000 and the sqrt adjustment never runs. It’s a no-op in practice, like modern LAPACK describes. Fine for LAPACK compatibility, but probably not something JS apps would call directly.
Suggestions, @kgryte... Thanks!
Contributor
There was a problem hiding this comment.
| */ | ||
| interface Routine { | ||
| /** | ||
| * Adjust the underflow and overflow thresholds if the exponent range is very large. |
Contributor
There was a problem hiding this comment.
Suggested change
| * Adjust the underflow and overflow thresholds if the exponent range is very large. | |
| * Adjusts the double-precision underflow and overflow thresholds when the exponent range is very large. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves none.
Description
This pull request:
lapack/base/dlabadRelated Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers