Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlaisnan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<!--

@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.

-->

# dlaisnan

> LAPACK auxiliary routine to test input for NaN by comparing two double-precision floating-point arguments for inequality.

<section class="usage">

## Usage

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

#### dlaisnan( DIN1, DIN2 )

Tests whether two double-precision floating-point arguments are unequal and thus at least one is NaN.

```javascript
var bool = dlaisnan( NaN, NaN );
// returns true

bool = dlaisnan( NaN, 5.0 );
// returns true

bool = dlaisnan( 5.0, 5.0 );
// returns false
```

The function has the following parameters:

- **DIN1**: first number to compare.
- **DIN2**: second number to compare.

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dlaisnan()` corresponds to the [LAPACK][LAPACK] auxiliary routine [`dlaisnan`][lapack-dlaisnan].
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `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`.
Copy link
Copy Markdown
Contributor

@anandkaranubc anandkaranubc May 17, 2026

Choose a reason for hiding this comment

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

Let's add a link to lapack isnan too

[lapack-disnan]: https://www.netlib.org/lapack/explore-html/d0/d4c/group__isnan_ga7aa3164d5df8d883754b0a70e9c7209c.html

- `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 )`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `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 )`).

- 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`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- 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`.


</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var dlaisnan = require( '@stdlib/lapack/base/dlaisnan' );

var opts = {
'dtype': 'float64'
};
var x = discreteUniform( 100, -50, 50, opts );
var y = discreteUniform( 100, -50, 50, opts );

logEachMap( 'dlaisnan( %d, %d ) = %s', x, y, dlaisnan );
```

</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-dlaisnan]: https://www.netlib.org/lapack/explore-html/d3/d22/group__laisnan_gad49d1fe3d6890e9c4f60e0429abab3c9.html

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var uniform = require( '@stdlib/random/array/uniform' );
var pkg = require( './../package.json' ).name;
var dlaisnan = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var len;
var x;
var y;
var z;
var i;

len = 100;
x = uniform( len, -50, 50 );
y = uniform( len, -50, 50 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = dlaisnan( x[ i % len ], y[ i % len ] );
if ( isnan( z ) ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@anandkaranubc anandkaranubc May 17, 2026

Choose a reason for hiding this comment

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

Please follow the pattern in @stdlib/math/base/assert/is-nan/benchmark/benchmark.js

b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
29 changes: 29 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlaisnan/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

{{alias}}( DIN1, DIN2 )
Tests whether two double-precision floating-point arguments are unequal
and thus at least one is NaN.

Parameters
----------
DIN1: number
First number to compare.

DIN2: number
Second number to compare.

Returns
-------
bool: boolean
Boolean indicating whether the arguments are unequal.

Examples
--------
> var bool = {{alias}}( NaN, NaN )
true
> bool = {{alias}}( NaN, 5.0 )
true
> bool = {{alias}}( 5.0, 5.0 )
false

See Also
--------
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* @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.
*/

// TypeScript Version: 4.1

/**
* LAPACK auxiliary routine to test input for NaN by comparing two double-precision floating-point arguments for inequality.
*
* @param DIN1 - first number to compare
* @param DIN2 - second number to compare
* @returns boolean indicating whether the arguments are unequal
*
* @example
* var bool = dlaisnan( NaN, NaN );
* // returns true
*
* @example
* var bool = dlaisnan( 5.0, 5.0 );
* // returns false
*/
declare function dlaisnan( DIN1: number, DIN2: number ): boolean;


// EXPORTS //

export = dlaisnan;
56 changes: 56 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlaisnan/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* @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.
*/

import dlaisnan = require( './index' );


// TESTS //

// The function returns a boolean...
{
dlaisnan( 8, 2 ); // $ExpectType boolean
}

// The compiler throws an error if the function is provided values other than two numbers...
{
dlaisnan( true, 3 ); // $ExpectError
dlaisnan( false, 2 ); // $ExpectError
dlaisnan( '5', 1 ); // $ExpectError
dlaisnan( [], 1 ); // $ExpectError
dlaisnan( {}, 2 ); // $ExpectError
dlaisnan( ( x: number ): number => x, 2 ); // $ExpectError

dlaisnan( 9, true ); // $ExpectError
dlaisnan( 9, false ); // $ExpectError
dlaisnan( 5, '5' ); // $ExpectError
dlaisnan( 8, [] ); // $ExpectError
dlaisnan( 9, {} ); // $ExpectError
dlaisnan( 8, ( x: number ): number => x ); // $ExpectError

dlaisnan( [], true ); // $ExpectError
dlaisnan( {}, false ); // $ExpectError
dlaisnan( false, '5' ); // $ExpectError
dlaisnan( {}, [] ); // $ExpectError
dlaisnan( '5', ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided insufficient arguments...
{
dlaisnan(); // $ExpectError
dlaisnan( 3 ); // $ExpectError
}
Loading