From 3985f47c6ec78cc644a98aa916740a1b2d37338f Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Sun, 11 Aug 2024 07:31:54 +0530 Subject: [PATCH] feat: add C implementation for `math/base/special/gamma-delta-ratio` PR-URL: #2662 Ref: #649 --------- Signed-off-by: GUNJ JOSHI Signed-off-by: Philipp Burckhardt Co-authored-by: Athan Reines Co-authored-by: Philipp Burckhardt Reviewed-by: Philipp Burckhardt Reviewed-by: Athan Reines --- .../base/special/gamma-delta-ratio/README.md | 93 ++++++++ .../benchmark/benchmark.native.js | 86 +++++++ .../benchmark/c/native/Makefile | 146 ++++++++++++ .../benchmark/c/native/benchmark.c | 135 +++++++++++ .../special/gamma-delta-ratio/binding.gyp | 170 ++++++++++++++ .../gamma-delta-ratio/examples/c/Makefile | 146 ++++++++++++ .../gamma-delta-ratio/examples/c/example.c | 35 +++ .../special/gamma-delta-ratio/include.gypi | 53 +++++ .../math/base/special/gamma_delta_ratio.h | 38 ++++ .../lib/gamma_delta_ratio_lanczos.js | 8 +- .../special/gamma-delta-ratio/lib/main.js | 8 +- .../special/gamma-delta-ratio/lib/native.js | 55 +++++ .../special/gamma-delta-ratio/manifest.json | 105 +++++++++ .../special/gamma-delta-ratio/src/Makefile | 70 ++++++ .../special/gamma-delta-ratio/src/addon.c | 23 ++ .../base/special/gamma-delta-ratio/src/main.c | 171 ++++++++++++++ .../special/gamma-delta-ratio/test/test.js | 10 +- .../gamma-delta-ratio/test/test.native.js | 213 ++++++++++++++++++ 18 files changed, 1550 insertions(+), 15 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/include/stdlib/math/base/special/gamma_delta_ratio.h create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/README.md b/lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/README.md index c3008750cae..09067c724e7 100644 --- a/lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/README.md +++ b/lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/README.md @@ -74,6 +74,99 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/gamma_delta_ratio.h" +``` + +#### stdlib_base_gamma_delta_ratio( z, delta ) + +Computes the ratio of two [gamma functions][@stdlib/math/base/special/gamma]. Specifically, the function evaluates `Γ( z ) / Γ( z + delta )`. + +```c +double out = stdlib_base_gamma_delta_ratio( 2.0, 3.0 ); +// returns ~0.042 + +out = stdlib_base_gamma_delta_ratio( 4.0, 0.5 ); +// returns ~0.516 +``` + +The function accepts the following arguments: + +- **z**: `[in] double` first gamma parameter. +- **delta**: `[in] double` difference. + +```c +double stdlib_base_gamma_delta_ratio( const double z, const double delta ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/gamma_delta_ratio.h" +#include +#include + +int main( void ) { + double delta; + double out; + double z; + int i; + + for ( i = 0; i < 100; i++ ) { + z = (double)rand() * 10.0; + delta = (double)rand() * 10.0; + out = stdlib_base_gamma_delta_ratio( z, delta ); + printf( "gamma_delta_ratio(%lf, %lf) = %lf\n", z, delta, out ); + } +} +``` + +
+ + + +
+ + +