From 5b5ce15628dac972c3f842b1b0233b3b9913f04e Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 18 Mar 2024 01:13:47 +0530 Subject: [PATCH] feat: add C implementation for `math/base/special/fast/pow-int` PR-URL: #1919 Closes: #1917 --------- Signed-off-by: GUNJ JOSHI Signed-off-by: Pranav Goswami Co-authored-by: Pranav Goswami Reviewed-by: Pranav Goswami Reviewed-by: Philipp Burckhardt --- .../math/base/special/fast/pow-int/README.md | 91 +++++ .../pow-int/benchmark/benchmark.native.js | 64 ++++ .../fast/pow-int/benchmark/c/native/Makefile | 146 ++++++++ .../pow-int/benchmark/c/native/benchmark.c | 138 ++++++++ .../base/special/fast/pow-int/binding.gyp | 170 +++++++++ .../special/fast/pow-int/examples/c/Makefile | 146 ++++++++ .../special/fast/pow-int/examples/c/example.c | 32 ++ .../base/special/fast/pow-int/include.gypi | 53 +++ .../stdlib/math/base/special/fast/pow.h | 40 +++ .../base/special/fast/pow-int/lib/native.js | 66 ++++ .../base/special/fast/pow-int/manifest.json | 81 +++++ .../base/special/fast/pow-int/src/Makefile | 70 ++++ .../base/special/fast/pow-int/src/addon.c | 22 ++ .../math/base/special/fast/pow-int/src/main.c | 71 ++++ .../special/fast/pow-int/test/test.native.js | 322 ++++++++++++++++++ 15 files changed, 1512 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/include/stdlib/math/base/special/fast/pow.h create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/README.md b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/README.md index 9e883d018b10..e119eea74efc 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/README.md +++ b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/README.md @@ -138,6 +138,97 @@ for ( y = 0; y < 309; y++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/fast/pow.h" +``` + +#### stdlib_base_fast_pow( x, y ) + +Evaluates the [exponential function][exponential-function] given a signed 32-bit integer `exponent`. + +```c +double out = stdlib_base_fast_pow( 2.0, 3 ); +// returns 8.0 + +out = stdlib_base_fast_pow( 3.14, 0 ); +// returns 1.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` base. +- **y**: `[in] double` exponent. + +```c +double stdlib_base_fast_pow( const double x, const int32_t y ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/fast/pow.h" +#include +#include + +int main( void ) { + const double x[] = { 3.14, 2.0, 2.0, 0.0 }; + const int32_t y[] = { 0, 3, -2, 0 }; + + double z; + int i; + for ( i = 0; i < 4; i++ ) { + z = stdlib_base_fast_pow( x[ i ], y[ i ] ); + printf( "pow( %lf, %d ) = %lf\n", x[ i ], y[ i ], z ); + } +} +``` + +
+ + + +
+ + +