feat: add lapack/base/dlaisnan#12183
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
status: passed
- 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
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
/stdlib update-copyright-years |
| if ( typeof out !== 'number' ) { | ||
| b.fail( 'should return a number' ); | ||
| z = dlaisnan( x[ i % len ], y[ i % len ] ); | ||
| if ( isnan( z ) ) { |
There was a problem hiding this comment.
dlaisnan returns a boolean, but this benchmark uses @stdlib/math/base/assert/is-nan on the result. isnan(true) / isnan(false) are always false, so this guard never fails and doesn’t validate the return type.
There was a problem hiding this comment.
Please follow the pattern in @stdlib/math/base/assert/is-nan/benchmark/benchmark.js
| /** | ||
| * Reinterpret a `Float16Array` as a `Uint16Array`. | ||
| * Tests whether two double-precision floating-point arguments are unequal and thus at least one is NaN. |
There was a problem hiding this comment.
The summary says the function tests inequality “and thus at least one is NaN.” That’s only true when both arguments are the same value
For dlaisnan(1.0, 2.0) the result is true with no NaN involved.
| /** | ||
| * Reinterpret a `Float16Array` as a `Uint16Array`. | ||
| * Tests whether two double-precision floating-point arguments are unequal and thus at least one is NaN. |
There was a problem hiding this comment.
| * Tests whether two double-precision floating-point arguments are unequal and thus at least one is NaN. | |
| * Tests input for NaN by comparing two double-precision floating-point arguments for inequality. |
I think leaving it as this, is better. Thoughts?
There was a problem hiding this comment.
+This change applies throughout the PR
| * @example | ||
| * var Float16Array = require( '@stdlib/array/float16' ); | ||
| * var reinterpret = require( '@stdlib/strided/base/reinterpret-float16' ); | ||
| * - This routine exists solely to avoid over-optimization in DISNAN. |
There was a problem hiding this comment.
| * - This routine exists solely to avoid over-optimization in DISNAN. | |
| * - This routine exists solely to avoid over-optimization in `disnan`. |
| ## Notes | ||
|
|
||
| - `dlaisnan()` corresponds to the [LAPACK][LAPACK] auxiliary routine [`dlaisnan`][lapack-dlaisnan]. | ||
| - This routine is not for general use. It exists solely to avoid over-optimization in `disnan`. |
There was a problem hiding this comment.
Let's add a link to lapack isnan too
[lapack-disnan]: https://www.netlib.org/lapack/explore-html/d0/d4c/group__isnan_ga7aa3164d5df8d883754b0a70e9c7209c.html
| <section class="notes"> | ||
|
|
||
| ## Notes | ||
|
|
||
| - `dlaisnan()` corresponds to the [LAPACK][LAPACK] auxiliary routine [`dlaisnan`][lapack-dlaisnan]. |
There was a problem hiding this comment.
| - `dlaisnan()` corresponds to the [LAPACK][LAPACK] auxiliary routine [`dlaisnan`][lapack-dlaisnan]. | |
| - `dlaisnan()` corresponds to the [LAPACK][lapack] auxiliary routine [`dlaisnan`][lapack-dlaisnan]. |
|
|
||
| - `dlaisnan()` corresponds to the [LAPACK][LAPACK] auxiliary routine [`dlaisnan`][lapack-dlaisnan]. | ||
| - This routine is not for general use. It exists solely to avoid over-optimization in `disnan`. | ||
| - `dlaisnan` checks for NaNs by comparing its two arguments for inequality. `NaN` is the only floating-point value where `NaN != NaN` returns `true`. To check for NaNs, pass the same variable as both arguments (i.e., `dlaisnan( x, x )`). |
There was a problem hiding this comment.
| - `dlaisnan` checks for NaNs by comparing its two arguments for inequality. `NaN` is the only floating-point value where `NaN != NaN` returns `true`. To check for NaNs, pass the same variable as both arguments (i.e., `dlaisnan( x, x )`). | |
| - `dlaisnan` checks for NaNs by comparing its two arguments for inequality. `NaN` is the only floating-point value where `NaN !== NaN` returns `true`. To check for NaNs, pass the same variable as both arguments (i.e., `dlaisnan( x, x )`). |
| - `dlaisnan()` corresponds to the [LAPACK][LAPACK] auxiliary routine [`dlaisnan`][lapack-dlaisnan]. | ||
| - This routine is not for general use. It exists solely to avoid over-optimization in `disnan`. | ||
| - `dlaisnan` checks for NaNs by comparing its two arguments for inequality. `NaN` is the only floating-point value where `NaN != NaN` returns `true`. To check for NaNs, pass the same variable as both arguments (i.e., `dlaisnan( x, x )`). | ||
| - The function returns `true` whenever the two arguments are unequal, not only when one is NaN. This matches the Fortran reference implementation which simply returns `DIN1.NE.DIN2`. |
There was a problem hiding this comment.
| - The function returns `true` whenever the two arguments are unequal, not only when one is NaN. This matches the Fortran reference implementation which simply returns `DIN1.NE.DIN2`. | |
| - The function returns `true` whenever the two arguments are unequal, not only when one is `NaN`. This matches the Fortran reference implementation which simply returns `DIN1.NE.DIN2`. |
There was a problem hiding this comment.
I think we can also include
tape( 'the function returns expected values when passed the same variable as both arguments', function test( t ) {
var x;
var bool;
x = NaN;
bool = dlaisnan( x, x );
t.strictEqual( bool, true, 'returns expected value' );
x = 5.0;
bool = dlaisnan( x, x );
t.strictEqual( bool, false, 'returns expected value' );
x = 0.0;
bool = dlaisnan( x, x );
t.strictEqual( bool, false, 'returns expected value' );
x = -0.0;
bool = dlaisnan( x, x );
t.strictEqual( bool, false, 'returns expected value' );
x = PINF;
bool = dlaisnan( x, x );
t.strictEqual( bool, false, 'returns expected value' );
t.end();
});LAPACK documents NaN detection as passing the same variable twice: dlaisnan(x, x). The current tests use literals (e.g. dlaisnan(NaN, NaN) and dlaisnan(5.0, 5.0)), which don’t exercise that pattern or guard against an engine folding x === x.
| * @param {number} DIN1 - first number to compare | ||
| * @param {number} DIN2 - second number to compare |
There was a problem hiding this comment.
| * @param {number} DIN1 - first number to compare | |
| * @param {number} DIN2 - second number to compare | |
| * @param {number} DIN1 - first input number | |
| * @param {number} DIN2 - second input number |
Applies to other related files too.
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/dlaisnanRelated 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