From 665c7357a0439decbaecb80519ce017d87a15f04 Mon Sep 17 00:00:00 2001 From: Rutam <138517416+performant23@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:01:45 +0530 Subject: [PATCH] feat: add C implementation for `math/base/special/xlogy` PR-URL: #1827 Closes: #1815 --------- Signed-off-by: Rutam <138517416+performant23@users.noreply.github.com> 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> Reviewed-by: Philipp Burckhardt --- .../@stdlib/math/base/special/xlogy/README.md | 90 +++++++++ .../xlogy/benchmark/benchmark.native.js | 62 ++++++ .../special/xlogy/benchmark/c/native/Makefile | 146 ++++++++++++++ .../xlogy/benchmark/c/native/benchmark.c | 138 +++++++++++++ .../math/base/special/xlogy/binding.gyp | 170 ++++++++++++++++ .../base/special/xlogy/examples/c/Makefile | 146 ++++++++++++++ .../base/special/xlogy/examples/c/example.c | 35 ++++ .../math/base/special/xlogy/include.gypi | 53 +++++ .../include/stdlib/math/base/special/xlogy.h | 38 ++++ .../math/base/special/xlogy/lib/native.js | 52 +++++ .../math/base/special/xlogy/manifest.json | 75 +++++++ .../math/base/special/xlogy/src/Makefile | 70 +++++++ .../math/base/special/xlogy/src/addon.c | 23 +++ .../math/base/special/xlogy/src/main.c | 42 ++++ .../base/special/xlogy/test/test.native.js | 187 ++++++++++++++++++ 15 files changed, 1327 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/include/stdlib/math/base/special/xlogy.h create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/xlogy/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/xlogy/README.md b/lib/node_modules/@stdlib/math/base/special/xlogy/README.md index 1e3bda42f46..6347709a290 100644 --- a/lib/node_modules/@stdlib/math/base/special/xlogy/README.md +++ b/lib/node_modules/@stdlib/math/base/special/xlogy/README.md @@ -89,6 +89,96 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/xlogy.h" +``` + +#### stdlib_base_xlogy( x, y ) + +Computes `x * ln(y)` so that the result is `0` if `x = 0`. + +```c +double v = stdlib_base_xlogy( 3.0, 2.0 ); +// returns ~2.079 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **y**: `[in] double` input value. + +```c +double stdlib_base_xlogy( const double x, const double y ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/xlogy.h" +#include +#include + +int main( void ) { + double out; + double x; + double y; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( (double)rand() / (double)RAND_MAX ) * 100.0; + y = ( (double)rand() / (double)RAND_MAX ) * 5.0; + out = stdlib_base_xlogy( x, y ); + printf( "xlogy(%lf, %lf) = %lf\n", x, y, out ); + } +} +``` + +
+ + + +
+ + +