From 8a25861e88f196bc432d3355b26dcf0d2189c8f9 Mon Sep 17 00:00:00 2001
From: Manvith <148960168+manvith2003@users.noreply.github.com>
Date: Tue, 17 Dec 2024 15:37:08 +0530
Subject: [PATCH 1/9] feat: add C implementation for
stats/base/dists/normal/logcdf
---
.../stats/base/dists/normal/logcdf/README.md | 98 ++++++++++
.../normal/logcdf/benchmark/benchmark.js | 22 ++-
.../logcdf/benchmark/benchmark.native.js | 74 ++++++++
.../dists/normal/logcdf/benchmark/c/Makefile | 146 +++++++++++++++
.../normal/logcdf/benchmark/c/benchmark.c | 143 +++++++++++++++
.../base/dists/normal/logcdf/binding.gyp | 170 ++++++++++++++++++
.../dists/normal/logcdf/examples/c/Makefile | 146 +++++++++++++++
.../dists/normal/logcdf/examples/c/example.c | 43 +++++
.../base/dists/normal/logcdf/include.gypi | 53 ++++++
.../stdlib/stats/base/dists/normal/logcdf.h | 38 ++++
.../base/dists/normal/logcdf/lib/native.js | 77 ++++++++
.../base/dists/normal/logcdf/manifest.json | 94 ++++++++++
.../base/dists/normal/logcdf/package.json | 3 +
.../base/dists/normal/logcdf/src/Makefile | 70 ++++++++
.../base/dists/normal/logcdf/src/addon.c | 23 +++
.../stats/base/dists/normal/logcdf/src/main.c | 66 +++++++
.../dists/normal/logcdf/test/test.native.js | 160 +++++++++++++++++
17 files changed, 1420 insertions(+), 6 deletions(-)
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/benchmark/benchmark.native.js
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/benchmark/c/Makefile
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/benchmark/c/benchmark.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/binding.gyp
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/examples/c/Makefile
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/examples/c/example.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/include.gypi
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/include/stdlib/stats/base/dists/normal/logcdf.h
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/lib/native.js
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/manifest.json
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/src/Makefile
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/src/addon.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/src/main.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/test/test.native.js
diff --git a/lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/README.md
index 52d505ed7363..226535ccba82 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dists/normal/logcdf/README.md
@@ -128,6 +128,104 @@ for ( i = 0; i < 10; i++ ) {
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/stats/base/dists/normal/logcdf.h"
+```
+
+#### stdlib_base_dists_normal_logcdf( x, a, b )
+
+Evaluates the logarithm of the cumulative distribution function (logCDF) for a normal distribution.
+
+```c
+double out = stdlib_base_dists_normal_cdf( 2.0, 0.0, 1.0 );
+// returns ~-0.023
+```
+
+The function accepts the following arguments:
+
+- **x**: `[in] double` input value.
+- **mu**: `[in] double` mean.
+- **sigma**: `[in] double` standard deviation.
+
+```c
+double stdlib_base_dists_normal_logcdf( cconst double x, const double mu, const double sigma );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/stats/base/dists/normal/logcdf.h"
+#include
+#include
+
+static double random_uniform( const double min, const double max ) {
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
+ return min + ( v*(max-min) );
+}
+
+int main( void ) {
+ double x;
+ double mu;
+ double sigma;
+ double y;
+ int i;
+
+ for ( i = 0; i < 10; i++ ) {
+ x = random_uniform( 0.0, 10.0 );
+ mu = random_uniform( -5.0, 5.0 );
+ sigma = random_uniform( 0.1, 20.0 );
+ y = stdlib_base_dists_normal_logcdf( x, mu, sigma );
+ printf( "x: %lf, µ: %lf, σ: %lf, ln(F(x;µ,σ)): %lf\n", x, mu, sigma, y );
+ }
+}
+```
+
+
+
+
+
+
+
+
+