From 9b6e665811fd7f149dfceaa4e0eda65d7f4d9113 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI <gunjjoshi8372@gmail.com> Date: Mon, 10 Jun 2024 17:11:46 +0530 Subject: [PATCH 1/5] feat: add C implementation for math/base/special/sin --- .../@stdlib/math/base/special/sin/README.md | 85 +++++++ .../special/sin/benchmark/benchmark.native.js | 60 +++++ .../special/sin/benchmark/c/native/Makefile | 146 ++++++++++++ .../sin/benchmark/c/native/benchmark.c | 136 +++++++++++ .../@stdlib/math/base/special/sin/binding.gyp | 170 ++++++++++++++ .../math/base/special/sin/examples/c/Makefile | 146 ++++++++++++ .../base/special/sin/examples/c/example.c | 31 +++ .../math/base/special/sin/include.gypi | 53 +++++ .../include/stdlib/math/base/special/sin.h | 43 ++++ .../math/base/special/sin/lib/native.js | 58 +++++ .../math/base/special/sin/manifest.json | 93 ++++++++ .../math/base/special/sin/src/Makefile | 70 ++++++ .../@stdlib/math/base/special/sin/src/addon.c | 22 ++ .../@stdlib/math/base/special/sin/src/main.c | 107 +++++++++ .../math/base/special/sin/test/test.native.js | 219 ++++++++++++++++++ 15 files changed, 1439 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/include/stdlib/math/base/special/sin.h create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/sin/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/sin/README.md b/lib/node_modules/@stdlib/math/base/special/sin/README.md index 282f31c328a0..73bde3e8b64e 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/README.md +++ b/lib/node_modules/@stdlib/math/base/special/sin/README.md @@ -72,6 +72,91 @@ for ( i = 0; i < x.length; i++ ) { <!-- /.examples --> +<!-- C interface documentation. --> + +* * * + +<section class="c"> + +## C APIs + +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> + +<section class="intro"> + +</section> + +<!-- /.intro --> + +<!-- C usage documentation. --> + +<section class="usage"> + +### Usage + +```c +#include "stdlib/math/base/special/sin.h" +``` + +#### stdlib_base_sin( x ) + +Computes the [sine][sine] of a `number` (in radians). + +```c +double y = stdlib_base_sin( 3.141592653589793 / 2.0 ); +// returns ~1.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. + +```c +double stdlib_base_sin( const double x ); +``` + +</section> + +<!-- /.usage --> + +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> + +<section class="notes"> + +</section> + +<!-- /.notes --> + +<!-- C API usage examples. --> + +<section class="examples"> + +### Examples + +```c +#include "stdlib/math/base/special/sin.h" +#include <stdio.h> + +int main( void ) { + const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 }; + + double y; + int i; + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_sin( x[ i ] ); + printf( "sin(%lf) = %lf\n", x[ i ], y ); + } +} +``` + +</section> + +<!-- /.examples --> + +</section> + +<!-- /.c --> + <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> <section class="related"> diff --git a/lib/node_modules/@stdlib/math/base/special/sin/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/sin/benchmark/benchmark.native.js new file mode 100644 index 000000000000..57d351e134a8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/benchmark/benchmark.native.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var sin = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( sin instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 20.0 ) - 10.0; + y = sin( x ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..547dd6210ea0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/benchmark/c/native/benchmark.c @@ -0,0 +1,136 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Benchmark `sin`. +*/ +#include "stdlib/math/base/special/sin.h" +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <time.h> +#include <sys/time.h> + +#define NAME "sin" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +void print_version() { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +double tic() { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1]. +* +* @return random number +*/ +double rand_double() { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +double benchmark() { + double elapsed; + double x; + double y; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( 20.0 * rand_double() ) - 10.0; + y = stdlib_base_sin( x ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/sin/binding.gyp b/lib/node_modules/@stdlib/math/base/special/sin/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/sin/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/sin/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/sin/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/sin/examples/c/example.c new file mode 100644 index 000000000000..577da05e185f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/sin.h" +#include <stdio.h> + +int main( void ) { + const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 }; + + double y; + int i; + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_sin( x[ i ] ); + printf( "sin(%lf) = %lf\n", x[ i ], y ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/sin/include.gypi b/lib/node_modules/@stdlib/math/base/special/sin/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + + # Add-on destination directory: + 'addon_output_dir': './src', + + # Source files: + 'src_files': [ + '<(src_dir)/addon.c', + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + + # Library dependencies: + 'libraries': [ + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + + # Library directories: + 'library_dirs': [ + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + }, # end variables +} diff --git a/lib/node_modules/@stdlib/math/base/special/sin/include/stdlib/math/base/special/sin.h b/lib/node_modules/@stdlib/math/base/special/sin/include/stdlib/math/base/special/sin.h new file mode 100644 index 000000000000..ca0f9dea7e87 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/include/stdlib/math/base/special/sin.h @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Header file containing function declarations. +*/ +#ifndef STDLIB_MATH_BASE_SPECIAL_SIN_H +#define STDLIB_MATH_BASE_SPECIAL_SIN_H + +#include <stdint.h> + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Computes the sine of a number. +*/ +double stdlib_base_sin( const double x ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_SIN_H diff --git a/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js b/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js new file mode 100644 index 000000000000..6b1dea58756f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the sine of a number. +* +* @private +* @param {number} x - input value (in radians) +* @returns {number} sine +* +* @example +* var v = sin( 0.0 ); +* // returns ~0.0 +* +* @example +* var v = sin( 3.141592653589793/2.0 ); +* // returns ~1.0 +* +* @example +* var v = sin( -3.141592653589793/6.0 ); +* // returns ~-0.5 +* +* @example +* var v = sin( NaN ); +* // returns NaN +*/ +function sin( x ) { + return addon( x ); +} + + +// EXPORTS // + +module.exports = sin; diff --git a/lib/node_modules/@stdlib/math/base/special/sin/manifest.json b/lib/node_modules/@stdlib/math/base/special/sin/manifest.json new file mode 100644 index 000000000000..001290c3a2c2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/manifest.json @@ -0,0 +1,93 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/number/float64/base/get-high-word", + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-exponent-mask", + "@stdlib/math/base/special/kernel-cos", + "@stdlib/math/base/special/kernel-sin", + "@stdlib/math/base/special/rempio2" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/number/float64/base/get-high-word", + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-exponent-mask", + "@stdlib/math/base/special/kernel-cos", + "@stdlib/math/base/special/kernel-sin", + "@stdlib/math/base/special/rempio2" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/number/float64/base/get-high-word", + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-exponent-mask", + "@stdlib/math/base/special/kernel-cos", + "@stdlib/math/base/special/kernel-sin", + "@stdlib/math/base/special/rempio2" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/sin/src/Makefile b/lib/node_modules/@stdlib/math/base/special/sin/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/sin/src/addon.c b/lib/node_modules/@stdlib/math/base/special/sin/src/addon.c new file mode 100644 index 000000000000..533e915ad4f5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/src/addon.c @@ -0,0 +1,22 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/sin.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_sin ) diff --git a/lib/node_modules/@stdlib/math/base/special/sin/src/main.c b/lib/node_modules/@stdlib/math/base/special/sin/src/main.c new file mode 100644 index 000000000000..6d4a961d7af4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/src/main.c @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* +* ## Notice +* +* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/s_sin.c}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +#include "stdlib/math/base/special/sin.h" +#include "stdlib/number/float64/base/get_high_word.h" +#include "stdlib/constants/float64/high_word_abs_mask.h" +#include "stdlib/constants/float64/high_word_exponent_mask.h" +#include "stdlib/math/base/special/kernel_cos.h" +#include "stdlib/math/base/special/kernel_sin.h" +#include "stdlib/math/base/special/rempio2.h" +#include <stdint.h> + +// High word for PI/4: 0x3fe921fb = 1072243195 => 00111111111010010010000111111011 +static const int32_t PIO4_HIGH_WORD = 0x3fe921fb; + +// 2^-26 = 1.4901161193847656e-8 => 0011111001010000000000000000000000000000000000000000000000000000 => high word => 00111110010100000000000000000000 => 0x3e500000 = 1045430272 +static const int32_t SMALL_HIGH_WORD = 0x3e500000; + +/** +* Computes the sine of a number. +* +* ## Method +* +* - Let \\(S\\), \\(C\\), and \\(T\\) denote the \\(\sin\\), \\(\cos\\), and \\(\tan\\), respectively, on \\(\[-\pi/4, +\pi/4\]\\). +* +* - Reduce the argument \\(x\\) to \\(y1+y2 = x-k\pi/2\\) in \\(\[-\pi/4, +\pi/4\]\\), and let \\(n = k \mod 4\\). +* +* - We have +* +* | n | sin(x) | cos(x) | tan(x) | +* | - | ------ | ------ | ------ | +* | 0 | S | C | T | +* | 1 | C | -S | -1/T | +* | 2 | -S | -C | T | +* | 3 | -C | S | -1/T | +* +* @param x input value (in radians) +* @returns sine +* +* @example +* double y = stdlib_base_sin( 3.141592653589793 / 2.0 ); +* // returns ~1.0 +*/ +double stdlib_base_sin( const double x ) { + double Y[ 2 ]; + uint32_t uix; + int32_t ix; + int32_t n; + + stdlib_base_float64_get_high_word( x, &uix ); + ix = (int32_t)uix; + ix &= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK; + + // Case: |x| ~< π/4 + if ( ix <= PIO4_HIGH_WORD ) { + // Case: |x| ~< 2^-26 + if ( ix < SMALL_HIGH_WORD ) { + return x; + } + return stdlib_base_kernel_sin( x, 0.0 ); + } + // Case: x is NaN or infinity + if ( ix >= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) { + return 0.0 / 0.0; // NaN + } + // Argument reduction... + n = stdlib_base_rempio2( x, &Y[ 0 ], &Y[ 1 ] ); + switch ( n & 3 ) { + case 0: + return stdlib_base_kernel_sin( Y[ 0 ], Y[ 1 ] ); + case 1: + return stdlib_base_kernel_cos( Y[ 0 ], Y[ 1 ] ); + case 2: + return -stdlib_base_kernel_sin( Y[ 0 ], Y[ 1 ] ); + default: + return -stdlib_base_kernel_cos( Y[ 0 ], Y[ 1 ] ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/sin/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sin/test/test.native.js new file mode 100644 index 000000000000..1e7061ed3094 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/sin/test/test.native.js @@ -0,0 +1,219 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var mediumNegative = require( './fixtures/julia/medium_negative.json' ); +var mediumPositive = require( './fixtures/julia/medium_positive.json' ); +var largeNegative = require( './fixtures/julia/large_negative.json' ); +var largePositive = require( './fixtures/julia/large_positive.json' ); +var hugeNegative = require( './fixtures/julia/huge_negative.json' ); +var hugePositive = require( './fixtures/julia/huge_positive.json' ); + + +// VARIABLES // + +var sin = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( sin instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the sine (medium negative values)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + x = mediumNegative.x; + expected = mediumNegative.expected; + + for ( i = 0; i < x.length; i++ ) { + y = sin( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); + +tape( 'the function computes the sine (medium positive values)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + x = mediumPositive.x; + expected = mediumPositive.expected; + + for ( i = 0; i < x.length; i++ ) { + y = sin( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); + +tape( 'the function computes the sine (large negative values)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + x = largeNegative.x; + expected = largeNegative.expected; + + for ( i = 0; i < x.length; i++ ) { + y = sin( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); + +tape( 'the function computes the sine (large positive values)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + x = largePositive.x; + expected = largePositive.expected; + + for ( i = 0; i < x.length; i++ ) { + y = sin( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); + +tape( 'the function computes the sine (huge negative values)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + x = hugeNegative.x; + expected = hugeNegative.expected; + + for ( i = 0; i < x.length; i++ ) { + y = sin( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); + +tape( 'the function computes the sine (huge positive values)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + x = hugePositive.x; + expected = hugePositive.expected; + + for ( i = 0; i < x.length; i++ ) { + y = sin( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var v = sin( NaN ); + t.equal( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `+infinity`', opts, function test( t ) { + var v = sin( PINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `-infinity`', opts, function test( t ) { + var v = sin( NINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + t.end(); +}); From c24caf28bc5d73830136a3997e4cbd73ddf5cf4b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI <gunjjoshi8372@gmail.com> Date: Mon, 10 Jun 2024 17:23:52 +0530 Subject: [PATCH 2/5] fix indentation Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com> --- .../math/base/special/sin/manifest.json | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sin/manifest.json b/lib/node_modules/@stdlib/math/base/special/sin/manifest.json index 001290c3a2c2..f1729548edb3 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/sin/manifest.json @@ -1,93 +1,93 @@ { - "options": { - "task": "build" - }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/napi/unary", - "@stdlib/number/float64/base/get-high-word", + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/number/float64/base/get-high-word", "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/constants/float64/high-word-exponent-mask", "@stdlib/math/base/special/kernel-cos", "@stdlib/math/base/special/kernel-sin", "@stdlib/math/base/special/rempio2" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/number/float64/base/get-high-word", + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/number/float64/base/get-high-word", "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/constants/float64/high-word-exponent-mask", "@stdlib/math/base/special/kernel-cos", "@stdlib/math/base/special/kernel-sin", "@stdlib/math/base/special/rempio2" - ] - }, - { - "task": "examples", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ "@stdlib/number/float64/base/get-high-word", "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/constants/float64/high-word-exponent-mask", "@stdlib/math/base/special/kernel-cos", "@stdlib/math/base/special/kernel-sin", "@stdlib/math/base/special/rempio2" - ] - } - ] + ] + } + ] } From 54c6be5f69eb0417bc55d2a027de71dc5b66e3b7 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI <gunjjoshi8372@gmail.com> Date: Mon, 10 Jun 2024 17:24:25 +0530 Subject: [PATCH 3/5] fix indentation Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com> --- lib/node_modules/@stdlib/math/base/special/sin/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sin/manifest.json b/lib/node_modules/@stdlib/math/base/special/sin/manifest.json index f1729548edb3..a5286e487f73 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/sin/manifest.json @@ -81,7 +81,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/number/float64/base/get-high-word", + "@stdlib/number/float64/base/get-high-word", "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/constants/float64/high-word-exponent-mask", "@stdlib/math/base/special/kernel-cos", From 5ca5f1555f3b733e9c27c26ec1011c4cd21ced98 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI <gunjjoshi8372@gmail.com> Date: Mon, 10 Jun 2024 18:01:47 +0530 Subject: [PATCH 4/5] Update native.js Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com> --- lib/node_modules/@stdlib/math/base/special/sin/lib/native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js b/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js index 6b1dea58756f..fdcda25f5d32 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/sin/lib/native.js @@ -37,11 +37,11 @@ var addon = require( './../src/addon.node' ); * // returns ~0.0 * * @example -* var v = sin( 3.141592653589793/2.0 ); +* var v = sin( 3.141592653589793 / 2.0 ); * // returns ~1.0 * * @example -* var v = sin( -3.141592653589793/6.0 ); +* var v = sin( -3.141592653589793 / 6.0 ); * // returns ~-0.5 * * @example From eb30338044cb12f1945733117fd7acb59a9d1d74 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt <pburckhardt@outlook.com> Date: Mon, 10 Jun 2024 08:55:26 -0400 Subject: [PATCH 5/5] docs: fix return annotation Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com> --- lib/node_modules/@stdlib/math/base/special/sin/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sin/src/main.c b/lib/node_modules/@stdlib/math/base/special/sin/src/main.c index 6d4a961d7af4..252f144057a7 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/sin/src/main.c @@ -64,7 +64,7 @@ static const int32_t SMALL_HIGH_WORD = 0x3e500000; * | 3 | -C | S | -1/T | * * @param x input value (in radians) -* @returns sine +* @return sine * * @example * double y = stdlib_base_sin( 3.141592653589793 / 2.0 );