Skip to content

feat: add lapack/base/disnan#12289

Open
iampratik13 wants to merge 2 commits into
stdlib-js:developfrom
iampratik13:lapack/disnan
Open

feat: add lapack/base/disnan#12289
iampratik13 wants to merge 2 commits into
stdlib-js:developfrom
iampratik13:lapack/disnan

Conversation

@iampratik13

Copy link
Copy Markdown
Member

Resolves none.

Description

What is the purpose of this pull request?

This pull request:

  • feat: add lapack/base/disnan

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@iampratik13 iampratik13 requested a review from a team May 25, 2026 20:09
@stdlib-bot stdlib-bot added LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Review A pull request which needs code review. labels May 25, 2026
@iampratik13 iampratik13 marked this pull request as draft May 25, 2026 20:13
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label May 25, 2026
@kgryte kgryte added Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2026 Google Summer of Code (2026). labels May 31, 2026
@kgryte kgryte marked this pull request as ready for review May 31, 2026 23:51
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label May 31, 2026
// TypeScript Version: 4.1

/**
* Tests a double-precision floating-point numeric value for NaN.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Tests a double-precision floating-point numeric value for NaN.
* Tests whether a double-precision floating-point number is NaN.

/**
* Tests a double-precision floating-point numeric value for NaN.
*
* @param DIN - double-precision floating-point number to test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param DIN - double-precision floating-point number to test
* @param x - input value

* Tests a double-precision floating-point numeric value for NaN.
*
* @param DIN - double-precision floating-point number to test
* @returns boolean indicating whether the value is NaN

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns boolean indicating whether the value is NaN
* @returns boolean indicating whether an input value is NaN

* var bool = disnan( 5.0 );
* // returns false
*/
declare function disnan( DIN: number ): boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
declare function disnan( DIN: number ): boolean;
declare function disnan( x: number ): boolean;

Use normal JavaScript parameter names.

@@ -0,0 +1,24 @@

{{alias}}( din )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the same comments.

'use strict';

/**
* LAPACK auxiliary routine to test a double-precision floating-point numeric value for NaN.

@kgryte kgryte May 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* LAPACK auxiliary routine to test a double-precision floating-point numeric value for NaN.
* LAPACK auxiliary routine to test whether a double-precision floating-point number is NaN.

Comment on lines +31 to +34
* ## Notes
*
* - This routine uses `dlaisnan` to test for `NaN` by comparing the argument against itself for inequality.
*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* ## Notes
*
* - This routine uses `dlaisnan` to test for `NaN` by comparing the argument against itself for inequality.
*

@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
lapack/base/disnan $\color{green}96/96$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}96/96$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

// MAIN //

/**
* Tests a double-precision floating-point numeric value for NaN.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the same comments.

{
"name": "@stdlib/lapack/base/disnan",
"version": "0.0.0",
"description": "LAPACK auxiliary routine to test a double-precision floating-point numeric value for NaN.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "LAPACK auxiliary routine to test a double-precision floating-point numeric value for NaN.",
"description": "LAPACK auxiliary routine to test whether a double-precision floating-point number is NaN.",


# disnan

> LAPACK auxiliary routine to test a double-precision floating-point numeric value for `NaN`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> LAPACK auxiliary routine to test a double-precision floating-point numeric value for `NaN`.
> LAPACK auxiliary routine to test whether a double-precision floating-point number is `NaN`.

var disnan = require( '@stdlib/lapack/base/disnan' );
```

#### disnan( din )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the same comments.

## Notes

- `disnan()` corresponds to the [LAPACK][lapack] auxiliary routine [`disnan`][lapack-disnan].
- `disnan` tests for `NaN` by internally calling [`dlaisnan`][lapack-dlaisnan] with the same argument passed twice (i.e., `dlaisnan( din, din )`). This approach avoids issues with compiler optimization that might incorrectly evaluate `NaN !== NaN` as `false`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `disnan` tests for `NaN` by internally calling [`dlaisnan`][lapack-dlaisnan] with the same argument passed twice (i.e., `dlaisnan( din, din )`). This approach avoids issues with compiler optimization that might incorrectly evaluate `NaN !== NaN` as `false`.

This info isn't super relevant for the average user.

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to dlaisnan, I am not convinced that this package is particularly relevant/necessary for our JavaScript implementations where we can (and likely should) just use math/base/assert/is-nan. It becomes more relevant for the C and Fortran implementations.

Left a number of initial comments.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2026 Google Summer of Code (2026). LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants