From 82c8ae03edea7886ce0f67ca6e1c2a3028ef8fd9 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Thu, 4 Jul 2024 08:25:43 +0530 Subject: [PATCH] feat: add C implementation for `math/base/special/floor2` PR-URL: #2503 Ref: #649 --------- Signed-off-by: GUNJ JOSHI Reviewed-by: Philipp Burckhardt --- .../math/base/special/floor2/README.md | 85 +++++++++ .../floor2/benchmark/benchmark.native.js | 60 ++++++ .../floor2/benchmark/c/native/Makefile | 146 +++++++++++++++ .../floor2/benchmark/c/native/benchmark.c | 136 ++++++++++++++ .../math/base/special/floor2/binding.gyp | 170 +++++++++++++++++ .../base/special/floor2/examples/c/Makefile | 146 +++++++++++++++ .../base/special/floor2/examples/c/example.c | 31 +++ .../math/base/special/floor2/include.gypi | 53 ++++++ .../include/stdlib/math/base/special/floor2.h | 41 ++++ .../math/base/special/floor2/lib/native.js | 54 ++++++ .../math/base/special/floor2/manifest.json | 102 ++++++++++ .../math/base/special/floor2/src/Makefile | 70 +++++++ .../math/base/special/floor2/src/addon.c | 22 +++ .../math/base/special/floor2/src/main.c | 73 ++++++++ .../base/special/floor2/test/test.native.js | 176 ++++++++++++++++++ 15 files changed, 1365 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/include/stdlib/math/base/special/floor2.h create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/floor2/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/floor2/README.md b/lib/node_modules/@stdlib/math/base/special/floor2/README.md index 17b75511e52..e222a7b0331 100644 --- a/lib/node_modules/@stdlib/math/base/special/floor2/README.md +++ b/lib/node_modules/@stdlib/math/base/special/floor2/README.md @@ -101,6 +101,91 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/floor2.h" +``` + +#### stdlib_base_floor2( x ) + +Rounds a `numeric` value to the nearest power of two toward negative infinity. + +```c +double y = stdlib_base_floor2( -4.2 ); +// returns -8.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. + +```c +double stdlib_base_floor2( const double x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/floor2.h" +#include + +int main( void ) { + const double x[] = { 3.14, -3.14, 0.0, 0.0 / 0.0 }; + + double y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_floor2( x[ i ] ); + printf( "floor2(%lf) = %lf\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + +