Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 26, 2024
1 parent 1c16cb9 commit 18d6834
Show file tree
Hide file tree
Showing 25 changed files with 1,834 additions and 1 deletion.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<section class="release" id="unreleased">

## Unreleased (2024-10-23)
## Unreleased (2024-10-26)

<section class="packages">

Expand Down Expand Up @@ -428,6 +428,28 @@

<!-- /.package -->

<section class="package" id="math-base-special-nanminf-unreleased">

#### [@stdlib/math/base/special/nanminf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/nanminf)

<details>

<section class="features">

##### Features

- [`30d56c3`](https://github.com/stdlib-js/stdlib/commit/30d56c355e6fa871ff5e42ac12d30ecd95011e00) - add `math/base/special/nanminf` [(#3034)](https://github.com/stdlib-js/stdlib/pull/3034)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="math-base-special-xlogyf-unreleased">

#### [@stdlib/math/base/special/xlogyf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/xlogyf)
Expand Down Expand Up @@ -476,6 +498,7 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`30d56c3`](https://github.com/stdlib-js/stdlib/commit/30d56c355e6fa871ff5e42ac12d30ecd95011e00) - **feat:** add `math/base/special/nanminf` [(#3034)](https://github.com/stdlib-js/stdlib/pull/3034) _(by Gunj Joshi)_
- [`bccdfa2`](https://github.com/stdlib-js/stdlib/commit/bccdfa26987e00d4994a7a1d8265a21c5545ff98) - **feat:** add C implementation for `math/base/special/nanmax` [(#3031)](https://github.com/stdlib-js/stdlib/pull/3031) _(by Gunj Joshi, Athan Reines)_
- [`2e8204e`](https://github.com/stdlib-js/stdlib/commit/2e8204e28f8bf5a3952938d5f6ff5160e027d175) - **docs:** use correct format specifier [(#3033)](https://github.com/stdlib-js/stdlib/pull/3033) _(by Gunj Joshi)_
- [`dce31cc`](https://github.com/stdlib-js/stdlib/commit/dce31cca0315ae50904c7fc34a95bb427bd03192) - **docs:** fix function name in examples [(#3032)](https://github.com/stdlib-js/stdlib/pull/3032) _(by Gunj Joshi)_
Expand Down
224 changes: 224 additions & 0 deletions base/special/nanminf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
<!--
@license Apache-2.0
Copyright (c) 2024 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.
-->

# nanminf

> Return the minimum value of two single-precision floating-point numbers, ignoring NaN.
<!-- 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 -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var nanminf = require( '@stdlib/math/base/special/nanminf' );
```

#### nanminf( x, y )

Returns the minimum value of two single-precision floating-point numbers, ignoring NaN.

```javascript
var v = nanminf( 4.2, 3.14 );
// returns 3.14

v = nanminf( +0.0, -0.0 );
// returns -0.0
```

If any argument is `NaN`, the function returns the other operand.

```javascript
var v = nanminf( 4.2, NaN );
// returns 4.2

v = nanminf( NaN, 3.14 );
// returns 3.14
```

If both arguments are `NaN`, the function returns `NaN`.

```javascript
var v = nanminf( NaN, NaN );
// returns NaN
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

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

```javascript
var nanminf = require( '@stdlib/math/base/special/nanminf' );

var m = nanminf( 3.0, 4.0 );
console.log( m );
// => 3.0

m = nanminf( NaN, 4.0 );
console.log( m );
// => 4.0

m = nanminf( 4.0, NaN );
console.log( m );
// => 4.0

m = nanminf( NaN, NaN );
console.log( m );
// => NaN
```

</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
#include "stdlib/math/base/special/nanminf.h"
```

#### stdlib_base_nanminf( x, y )

Returns the minimum value of two single-precision floating-point numbers, ignoring NaN.

```c
float out = stdlib_base_nanminf( 4.2f, 3.14f );
// returns 3.14f

out = stdlib_base_nanminf( 4.14f, 0.0f / 0.0f );
// returns 4.14f
```

The function accepts the following arguments:

- **x**: `[in] float` input value.
- **y**: `[in] float` input value.

```c
float stdlib_base_nanminf( const float x, const float y );
```
</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
#include "stdlib/math/base/special/nanminf.h"
#include <stdio.h>
int main( void ) {
const float x[] = { 1.0f, 0.45f, -0.89f, 0.0f / 0.0f, -0.78f, -0.22f, 0.66f, 0.11f, -0.55f, 0.0f };
const float y[] = { -0.22f, 0.66f, 0.0f, -0.55f, 0.33f, 1.0f, 0.0f / 0.0f, 0.11f, 0.45f, -0.78f };
float v;
int i;
for ( i = 0; i < 10; i++ ) {
v = stdlib_base_nanminf( x[ i ], y[ i ] );
printf( "x[ %d ]: %f, y[ %d ]: %f, nanminf( x[ %d ], y[ %d ] ): %f\n", i, x[ i ], i, y[ i ], i, i, v );
}
}
```

</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">

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
55 changes: 55 additions & 0 deletions base/special/nanminf/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 isnanf = require( './../../../../base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
var nanminf = require( './../lib' );


// MAIN //

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

values = [ 3, 2, 2.0, 1.5, NaN ];
x = 0.4;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = values[ i % values.length ];
z = nanminf( x, y );
if ( isnanf( z ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( z ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
64 changes: 64 additions & 0 deletions base/special/nanminf/benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var nanminf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( nanminf instanceof Error )
};


// MAIN //

bench( pkg+'::native', opts, function benchmark( b ) {
var values;
var x;
var y;
var z;
var i;

values = [ 3, 2, 2.0, 1.5, NaN ];
x = 0.4;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = values[ i % values.length ];
z = nanminf( x, y );
if ( isnanf( z ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( z ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Loading

0 comments on commit 18d6834

Please sign in to comment.