From e59d704f754153cce428151f19bd716e0f4f3465 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 12 Mar 2024 18:52:14 +0530 Subject: [PATCH 1/6] feat: add C implementation for `math/base/special/gammasgn` PR-URL: #1841 Closes: #649 --------- Signed-off-by: GUNJ JOSHI Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> Co-authored-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> Reviewed-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- .../math/base/special/gammasgn/README.md | 90 ++++++++++ .../gammasgn/benchmark/benchmark.native.js | 60 +++++++ .../gammasgn/benchmark/c/native/Makefile | 146 +++++++++++++++ .../gammasgn/benchmark/c/native/benchmark.c | 136 ++++++++++++++ .../math/base/special/gammasgn/binding.gyp | 170 ++++++++++++++++++ .../base/special/gammasgn/examples/c/Makefile | 146 +++++++++++++++ .../special/gammasgn/examples/c/example.c | 33 ++++ .../math/base/special/gammasgn/include.gypi | 53 ++++++ .../stdlib/math/base/special/gammasgn.h | 40 +++++ .../math/base/special/gammasgn/lib/native.js | 55 ++++++ .../math/base/special/gammasgn/manifest.json | 75 ++++++++ .../math/base/special/gammasgn/src/Makefile | 70 ++++++++ .../math/base/special/gammasgn/src/addon.c | 22 +++ .../math/base/special/gammasgn/src/main.c | 51 ++++++ .../base/special/gammasgn/test/test.native.js | 162 +++++++++++++++++ 15 files changed, 1309 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/include/stdlib/math/base/special/gammasgn.h create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gammasgn/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/gammasgn/README.md b/lib/node_modules/@stdlib/math/base/special/gammasgn/README.md index 22e8e55c0aeb..18c63c01be7c 100644 --- a/lib/node_modules/@stdlib/math/base/special/gammasgn/README.md +++ b/lib/node_modules/@stdlib/math/base/special/gammasgn/README.md @@ -107,6 +107,96 @@ for ( i = 0; i < x.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/gammasgn.h" +``` + +#### stdlib_base_gammasgn( x ) + +Returns the sign of the [gamma-function][@stdlib/math/base/special/gamma]. + +```c +double out = stdlib_base_gammasgn( 1.0 ); +// returns 1.0 + +out = stdlib_base_gammasgn( -2.5 ); +// returns -1.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. + +```c +double stdlib_base_gammasgn( const double x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/gammasgn.h" +#include +#include + +int main( void ) { + double x; + double v; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( (double)rand() / (double)RAND_MAX ) * 100.0; + v = stdlib_base_gammasgn( x ); + printf( "gammasgn%lf = %lf\n", x, v ); + } +} +``` + +
+ + + +
+ + +