From 67d206479d7216260d585173d253b1cb48b118f6 Mon Sep 17 00:00:00 2001 From: Ayaka <73595362+USERSATOSHI@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:33:19 +0530 Subject: [PATCH] feat: add C implementation for `@stdlib/math/base/special/erfcx` PR-URL: #2040 Closes: #1949 --------- Signed-off-by: Athan Reines Signed-off-by: Gunj Joshi Signed-off-by: Philipp Burckhardt Co-authored-by: Athan Reines Co-authored-by: Gunj Joshi Co-authored-by: Philipp Burckhardt Reviewed-by: Philipp Burckhardt Reviewed-by: Athan Reines Reviewed-by: Pranav Goswami Reviewed-by: Gunj Joshi --- .../@stdlib/math/base/special/erfcx/README.md | 88 ++ .../base/special/erfcx/benchmark/benchmark.js | 7 +- .../erfcx/benchmark/benchmark.native.js | 61 + .../special/erfcx/benchmark/c/native/Makefile | 146 +++ .../erfcx/benchmark/c/native/benchmark.c | 136 ++ .../math/base/special/erfcx/binding.gyp | 170 +++ .../base/special/erfcx/examples/c/Makefile | 146 +++ .../base/special/erfcx/examples/c/example.c | 31 + .../math/base/special/erfcx/include.gypi | 53 + .../include/stdlib/math/base/special/erfcx.h | 38 + .../math/base/special/erfcx/lib/main.js | 6 +- .../math/base/special/erfcx/lib/native.js | 66 + .../math/base/special/erfcx/manifest.json | 81 ++ .../math/base/special/erfcx/src/Makefile | 71 + .../math/base/special/erfcx/src/addon.c | 23 + .../math/base/special/erfcx/src/main.c | 1161 +++++++++++++++++ .../math/base/special/erfcx/test/test.js | 20 +- .../base/special/erfcx/test/test.native.js | 238 ++++ 18 files changed, 2527 insertions(+), 15 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/include/stdlib/math/base/special/erfcx.h create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/erfcx/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/erfcx/README.md b/lib/node_modules/@stdlib/math/base/special/erfcx/README.md index bc82e9f0381..3ec5fd40a23 100644 --- a/lib/node_modules/@stdlib/math/base/special/erfcx/README.md +++ b/lib/node_modules/@stdlib/math/base/special/erfcx/README.md @@ -120,6 +120,94 @@ for ( i = 0; i < x.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/erfcx.h" +``` + +#### erfcx( x ) + +Evaluates the [scaled complementary error function][complementary-error-function]. + +```c +double y = stdlib_base_erfcx( 0.0 ); +// returns 1.0 + +y = stdlib_base_erfcx( 1.0 ); +// returns ~0.4276 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. + +```c +double stdlib_base_erfcx( const double x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/erfcx.h" +#include + +int main( void ) { + const double x[] = { 0.0, 0.22, 0.44, 0.67, 0.89, 1.11, 1.33, 1.56, 1.78, 2.0 }; + + double v; + int i; + for ( i = 0; i < 10; i++ ) { + v = stdlib_base_erfcx( x[ i ] ); + printf( "x: %lf, erfcx(x): %lf\n", x[ i ], v ); + } +} +``` + +
+ + + +
+ + +