From c9ab1f2313cac54672d24e82665a13ff37b79a93 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 24 Jun 2024 18:25:32 +0530 Subject: [PATCH] feat: add C implementation for `math/base/special/cotd` PR-URL: #2443 Ref: #649 Reviewed-by: Philipp Burckhardt --- .../@stdlib/math/base/special/cotd/README.md | 88 +++++++++ .../cotd/benchmark/benchmark.native.js | 60 +++++++ .../special/cotd/benchmark/c/native/Makefile | 146 +++++++++++++++ .../cotd/benchmark/c/native/benchmark.c | 136 ++++++++++++++ .../math/base/special/cotd/binding.gyp | 170 ++++++++++++++++++ .../base/special/cotd/examples/c/Makefile | 146 +++++++++++++++ .../base/special/cotd/examples/c/example.c | 31 ++++ .../math/base/special/cotd/include.gypi | 53 ++++++ .../include/stdlib/math/base/special/cotd.h | 41 +++++ .../math/base/special/cotd/lib/native.js | 62 +++++++ .../math/base/special/cotd/manifest.json | 81 +++++++++ .../math/base/special/cotd/src/Makefile | 70 ++++++++ .../math/base/special/cotd/src/addon.c | 22 +++ .../@stdlib/math/base/special/cotd/src/main.c | 45 +++++ .../base/special/cotd/test/test.native.js | 119 ++++++++++++ 15 files changed, 1270 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/include/stdlib/math/base/special/cotd.h create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/cotd/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/cotd/README.md b/lib/node_modules/@stdlib/math/base/special/cotd/README.md index 50c14505a51..eb2a1098fdb 100644 --- a/lib/node_modules/@stdlib/math/base/special/cotd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cotd/README.md @@ -78,6 +78,94 @@ for ( i = 0; i < x.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/cotd.h" +``` + +#### stdlib_base_cotd( x ) + +Evaluates the [cotangent][trigonometric-functions] of `x` (in degrees). + +```c +double out = stdlib_base_cotd( 0.0 ); +// returns Infinity + +out = stdlib_base_cotd( 60.0 ); +// returns ~0.58 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. + +```c +double stdlib_base_cotd( const double x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/cotd.h" +#include + +int main( void ) { + const double x[] = { 0.0, 30.0, 45.0, 60.0, 90.0 }; + + double y; + int i; + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_cotd( x[ i ] ); + printf( "cotd(%lf) = %lf\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + +