From dce31cca0315ae50904c7fc34a95bb427bd03192 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 23 Oct 2024 21:58:31 +0530 Subject: [PATCH 1/3] docs: fix function name in examples PR-URL: https://github.com/stdlib-js/stdlib/pull/3032 Reviewed-by: Athan Reines Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nanmin/docs/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts index 036bd1d85f1..1f415fd48d1 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts @@ -26,15 +26,15 @@ * @returns minimum value * * @example -* var v = min( 3.14, 4.2 ); +* var v = nanmin( 3.14, 4.2 ); * // returns 3.14 * * @example -* var v = min( 4.14, NaN ); +* var v = nanmin( 4.14, NaN ); * // returns 4.14 * * @example -* var v = min( NaN, NaN ); +* var v = nanmin( NaN, NaN ); * // returns NaN */ declare function nanmin( x: number, y: number ): number; From 2e8204e28f8bf5a3952938d5f6ff5160e027d175 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Thu, 24 Oct 2024 00:02:42 +0530 Subject: [PATCH 2/3] docs: use correct format specifier PR-URL: https://github.com/stdlib-js/stdlib/pull/3033 Reviewed-by: Athan Reines Signed-off-by: Gunj Joshi --- lib/node_modules/@stdlib/math/base/special/nanmin/README.md | 2 +- .../@stdlib/math/base/special/nanmin/examples/c/example.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md index ff1dfafce3c..622860ba241 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -190,7 +190,7 @@ int main( void ) { int i; for ( i = 0; i < 10; i++ ) { v = stdlib_base_nanmin( x[i], y[i] ); - printf( "x[ %d ]: %f, y[ %d ]: %f, nanmin( x[ %d ], y[ %d ] ): %f\n", i, x[ i ], i, y[ i ], i, i, v ); + printf( "x[ %d ]: %lf, y[ %d ]: %lf, nanmin( x[ %d ], y[ %d ] ): %lf\n", i, x[ i ], i, y[ i ], i, i, v ); } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/c/example.c index d07f7420651..b5d31fb86c0 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/c/example.c @@ -27,6 +27,6 @@ int main( void ) { int i; for ( i = 0; i < 10; i++ ) { v = stdlib_base_nanmin( x[ i ], y[ i ] ); - printf( "x[ %d ]: %f, y[ %d ]: %f, nanmin( x[ %d ], y[ %d ] ): %f\n", i, x[ i ], i, y[ i ], i, i, v ); + printf( "x[ %d ]: %lf, y[ %d ]: %lf, nanmin( x[ %d ], y[ %d ] ): %lf\n", i, x[ i ], i, y[ i ], i, i, v ); } } From bccdfa26987e00d4994a7a1d8265a21c5545ff98 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Thu, 24 Oct 2024 00:12:15 +0530 Subject: [PATCH 3/3] feat: add C implementation for `math/base/special/nanmax` PR-URL: https://github.com/stdlib-js/stdlib/pull/3031 Ref: https://github.com/stdlib-js/stdlib/issues/649 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Signed-off-by: Gunj Joshi Signed-off-by: Athan Reines --- .../math/base/special/nanmax/README.md | 124 +++++++++++++ .../nanmax/benchmark/benchmark.native.js | 64 +++++++ .../nanmax/benchmark/c/native/Makefile | 146 +++++++++++++++ .../nanmax/benchmark/c/native/benchmark.c | 138 ++++++++++++++ .../math/base/special/nanmax/binding.gyp | 170 ++++++++++++++++++ .../base/special/nanmax/examples/c/Makefile | 146 +++++++++++++++ .../base/special/nanmax/examples/c/example.c | 32 ++++ .../math/base/special/nanmax/include.gypi | 53 ++++++ .../include/stdlib/math/base/special/nanmax.h | 38 ++++ .../math/base/special/nanmax/lib/native.js | 55 ++++++ .../math/base/special/nanmax/manifest.json | 75 ++++++++ .../math/base/special/nanmax/src/Makefile | 70 ++++++++ .../math/base/special/nanmax/src/addon.c | 22 +++ .../math/base/special/nanmax/src/main.c | 43 +++++ .../math/base/special/nanmax/test/test.js | 10 +- .../base/special/nanmax/test/test.native.js | 75 ++++++++ 16 files changed, 1256 insertions(+), 5 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/include/stdlib/math/base/special/nanmax.h create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md index 71d3e2e861a..08ce5e0ecee 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md @@ -79,6 +79,130 @@ var v = nanmax( NaN, NaN ); + + + + +
+ +## Examples + + + +```javascript +var nanmax = require( '@stdlib/math/base/special/nanmax' ); + +var m = nanmax( 3.0, 4.0 ); +console.log( m ); +// => 4.0 + +m = nanmax( NaN, 4.0 ); +console.log( m ); +// => 4.0 + +m = nanmax( 4.0, NaN ); +console.log( m ); +// => 4.0 + +m = nanmax( NaN, NaN ); +console.log( m ); +// => NaN +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/nanmax.h" +``` + +#### stdlib_base_nanmax( x, y ) + +Returns the minimum value, ignoring NaN. + +```c +double out = stdlib_base_nanmax( 4.2, 3.14 ); +// returns 4.2 + +out = stdlib_base_nanmax( 4.14, 0.0 / 0.0 ); +// returns 4.14 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **y**: `[in] double` input value. + +```c +double stdlib_base_nanmax( const double x, const double y ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/nanmax.h" +#include + +int main( void ) { + const double x[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 }; + const double y[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 }; + + double v; + int i; + for ( i = 0; i < 10; i++ ) { + v = stdlib_base_nanmax( x[i], y[i] ); + printf( "x[ %d ]: %lf, y[ %d ]: %lf, nanmax( x[ %d ], y[ %d ] ): %lf\n", i, x[ i ], i, y[ i ], i, i, v ); + } +} +``` + +
+ + + +
+ + +