From 29a1853afbb03850a51857a2f771d00bd401d809 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sun, 28 Jul 2024 10:49:26 +0530 Subject: [PATCH 1/2] feat: add C implementation for math/base/special/sincospi --- .../math/base/special/sincospi/README.md | 90 ++++++++++ .../sincospi/benchmark/benchmark.native.js | 60 +++++++ .../sincospi/benchmark/c/native/Makefile | 146 +++++++++++++++ .../sincospi/benchmark/c/native/benchmark.c | 134 ++++++++++++++ .../math/base/special/sincospi/binding.gyp | 170 ++++++++++++++++++ .../base/special/sincospi/examples/c/Makefile | 146 +++++++++++++++ .../special/sincospi/examples/c/example.c | 32 ++++ .../math/base/special/sincospi/include.gypi | 53 ++++++ .../stdlib/math/base/special/sincospi.h | 38 ++++ .../math/base/special/sincospi/lib/native.js | 61 +++++++ .../math/base/special/sincospi/manifest.json | 96 ++++++++++ .../math/base/special/sincospi/src/Makefile | 70 ++++++++ .../math/base/special/sincospi/src/addon.c | 41 +++++ .../math/base/special/sincospi/src/main.c | 92 ++++++++++ .../base/special/sincospi/test/test.native.js | 151 ++++++++++++++++ 15 files changed, 1380 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/include/stdlib/math/base/special/sincospi.h create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sincospi/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/sincospi/README.md b/lib/node_modules/@stdlib/math/base/special/sincospi/README.md index 0c199256843a..80887205249a 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincospi/README.md +++ b/lib/node_modules/@stdlib/math/base/special/sincospi/README.md @@ -90,6 +90,96 @@ for ( i = 0; i < x.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/sincospi.h" +``` + +#### stdlib_base_sincospi( x, &sine, &cosine ) + +Simultaneously computes the [sine][@stdlib/math/base/special/sin] and [cosine][@stdlib/math/base/special/cos] of a `number` times [π][@stdlib/constants/float64/pi] more accurately than `sincos(pi*x)`, especially for large `x`. + +```c +double cosine; +double sine; + +stdlib_base_sincospi( 4.0, &sine, &cosine ); +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **sine**: `[out] double*` destination for the sine. +- **cosine**: `[out] double*` destination for the cosine. + +```c +void stdlib_base_sincospi( const double x, double *sine, double *cosine ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/sincospi.h" +#include + +int main( void ) { + const double x[] = { 0.0, 1.57, 3.14, 6.28 }; + + double cosine; + double sine; + int i; + for ( i = 0; i < 4; i++ ) { + stdlib_base_sincospi( x[ i ], &sine, &cosine ); + printf( "x: %lf => sine: %lf, cosine: %lf\n", x[ i ], sine, cosine ); + } +} +``` + +
+ + + +
+ + +