From 692afcb69e47de99d9675571503e6cc7a73dd1a7 Mon Sep 17 00:00:00 2001 From: Neeraj Pathak Date: Fri, 27 Dec 2024 14:30:14 +0530 Subject: [PATCH 01/12] refactor: update `stats/base/dnanmeanpn` native addon from C++ to C PR-URL: https://github.com/stdlib-js/stdlib/pull/4110 Reviewed-by: Athan Reines --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../stats/base/dnanmeanpn/include.gypi | 2 +- .../stats/base/dnanmeanpn/manifest.json | 39 +++++- .../@stdlib/stats/base/dnanmeanpn/src/addon.c | 43 +++++++ .../stats/base/dnanmeanpn/src/addon.cpp | 117 ------------------ 4 files changed, 82 insertions(+), 119 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dnanmeanpn/src/addon.c delete mode 100644 lib/node_modules/@stdlib/stats/base/dnanmeanpn/src/addon.cpp diff --git a/lib/node_modules/@stdlib/stats/base/dnanmeanpn/include.gypi b/lib/node_modules/@stdlib/stats/base/dnanmeanpn/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanmeanpn/include.gypi +++ b/lib/node_modules/@stdlib/stats/base/dnanmeanpn/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dnanmeanpn( N, X, stride ), v ); + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/stats/base/dnanmeanpn/src/addon.cpp b/lib/node_modules/@stdlib/stats/base/dnanmeanpn/src/addon.cpp deleted file mode 100644 index 8c46b762906b..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dnanmeanpn/src/addon.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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/stats/base/dnanmeanpn.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_stats_base_dnanmeanpn { - - /** - * Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_dnanmeanpn( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 1 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 2 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, stdlib_strided_dnanmeanpn( N, (double *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dnanmeanpn, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_stats_base_dnanmeanpn From 40686a836201e1f26379e68e38a4b149644382f9 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:05:48 +0530 Subject: [PATCH 02/12] feat: add C implementation for binomail stdev --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../stats/base/dists/binomial/stdev/README.md | 96 ++++++++++ .../binomial/stdev/benchmark/benchmark.js | 14 +- .../stdev/benchmark/benchmark.native.js | 71 ++++++++ .../dists/binomial/stdev/benchmark/c/Makefile | 146 +++++++++++++++ .../binomial/stdev/benchmark/c/benchmark.c | 141 +++++++++++++++ .../base/dists/binomial/stdev/binding.gyp | 170 ++++++++++++++++++ .../dists/binomial/stdev/examples/c/Makefile | 146 +++++++++++++++ .../dists/binomial/stdev/examples/c/example.c | 43 +++++ .../base/dists/binomial/stdev/include.gypi | 53 ++++++ .../stdlib/stats/base/dists/binomial/stdev.h | 38 ++++ .../base/dists/binomial/stdev/lib/native.js | 63 +++++++ .../base/dists/binomial/stdev/manifest.json | 88 +++++++++ .../base/dists/binomial/stdev/package.json | 3 + .../base/dists/binomial/stdev/src/Makefile | 70 ++++++++ .../base/dists/binomial/stdev/src/addon.c | 23 +++ .../base/dists/binomial/stdev/src/main.c | 49 +++++ .../dists/binomial/stdev/test/test.native.js | 119 ++++++++++++ 17 files changed, 1330 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md index 4c100329b085..097bce200fc4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md @@ -141,6 +141,102 @@ for ( i = 0; i < 10; i++ ) { + + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/binomial/stdev.h" +``` + +#### stdlib_base_dists_binomial_stdev( n, p ) + +Returns the standard deviation of a binomial distribution. + +```c +double out = stdlib_base_dists_binomial_stdev( 100, 0.1 ); +// returns 3 +``` + +The function accepts the following arguments: + +- **n**: `[in] int` number of trials. +- **p**: `[in] double` success probability. + +```c +double stdlib_base_dists_binomial_stdev( const int n, const double p ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/binomial/stdev.h" +#include "stdlib/math/base/special/ceil.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 n; + double p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + n = stdlib_base_ceil( random_uniform( 0, 100 ) ); + p = random_uniform( 0, 1 ); + y = stdlib_base_dists_binomial_stdev( n, p ); + printf( "n: %lf, p: %lf, SD(X;n,p): %lf\n", n, p, y ); + } + + return 0; +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js index 5b2ae301f23a..87f1398b7b62 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var ceil = require( '@stdlib/math/base/special/ceil' ); +var Float64Array = require( '@stdlib/array/float64' ); var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; @@ -31,16 +32,23 @@ var stdev = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { + var len; var n; var p; var y; var i; + len = 100; + n = new Float64Array( len ); + p = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + n[ i ] = ceil( randu()*100.0 ); + p[ i ] = randu(); + } + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - n = ceil( randu()*100.0 ); - p = randu(); - y = stdev( n, p ); + y = stdev( n[ i%len ], p[ i%len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js new file mode 100644 index 000000000000..40691f5f6baa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js @@ -0,0 +1,71 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var ceil = require( '@stdlib/math/base/special/ceil' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var stdev = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( stdev instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var len; + var n; + var p; + var y; + var i; + + len = 100; + n = new Float64Array( len ); + p = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + n[ i ] = ceil( randu()*100.0 ); + p[ i ] = randu(); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = stdev( n[ i % len ], p[ i % len ] ); + 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/stats/base/dists/binomial/stdev/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/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 := 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/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c new file mode 100644 index 000000000000..f0a6e4c81e33 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c @@ -0,0 +1,141 @@ +/** +* @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/stats/base/dists/binomial/stdev.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include +#include +#include + +#define NAME "binomial-stdev" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static 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 +*/ +static 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 +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double n[ 100 ]; + double p[ 100 ]; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + n[ i ] = stdlib_base_ceil( random_uniform( 0, 100 ) ); + p[ i ] = random_uniform( 0, 1 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_binomial_stdev( n[ i % 100 ], p[ i % 100 ] ); + 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::%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/stats/base/dists/binomial/stdev/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/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/stats/base/dists/binomial/stdev/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/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/stats/base/dists/binomial/stdev/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c new file mode 100644 index 000000000000..a09acfa0ca40 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c @@ -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. +*/ + +#include "stdlib/stats/base/dists/binomial/stdev.h" +#include "stdlib/math/base/special/ceil.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 n; + double p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + n = stdlib_base_ceil( random_uniform( 0, 100 ) ); + p = random_uniform( 0, 1 ); + y = stdlib_base_dists_binomial_stdev( n, p ); + printf( "n: %lf, p: %lf, SD(X;n,p): %lf\n", n, p, y ); + } + + return 0; +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/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': [ + ' 1.0 || + !stdlib_base_is_nonnegative_integer( n ) || + n == STDLIB_CONSTANT_FLOAT64_PINF + ) { + return 0.0 / 0.0; + } + return stdlib_base_sqrt( n * p * (1.0 - p) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js new file mode 100644 index 000000000000..cdb90688f798 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js @@ -0,0 +1,119 @@ +/** +* @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 PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// VARIABLES // + +var stdev = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( stdev instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/python/data.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof stdev, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) { + var v = stdev( NaN, 0.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( 10, NaN ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( NaN, NaN ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var v; + + v = stdev( 1.5, 0.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( -2, 0.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( -1, 0.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( 2.5, 0.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( PINF, 0.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided a success probability `p` outside of `[0,1]`, the function returns `NaN`', opts, function test( t ) { + var v; + + v = stdev( 20, -1.0 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( 20, 1.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( 20, NINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( 20, PINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns the standard deviation of a binomial distribution', opts, function test( t ) { + var expected; + var n; + var p; + var y; + var i; + + expected = data.expected; + n = data.n; + p = data.p; + for ( i = 0; i < n.length; i++ ) { + y = stdev( n[i], p[i] ); + t.equal( y, expected[i], 'n: '+n[i]+', p: '+p[i]+', y: '+y+', expected: '+expected[i] ); + } + t.end(); +}); From b8303d2b75194467fdb4ef114a09996f7c466095 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:02:47 +0530 Subject: [PATCH 03/12] chore: replace double to int32_t for n --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/napi/binary/README.md | 23 +++++++ .../include/stdlib/math/base/napi/binary.h | 47 ++++++++++++++ .../@stdlib/math/base/napi/binary/src/main.c | 62 +++++++++++++++++++ .../binomial/stdev/benchmark/benchmark.js | 3 +- .../stdev/benchmark/benchmark.native.js | 3 +- .../binomial/stdev/benchmark/c/benchmark.c | 3 +- .../dists/binomial/stdev/examples/c/example.c | 5 +- .../stdlib/stats/base/dists/binomial/stdev.h | 4 +- .../base/dists/binomial/stdev/src/addon.c | 2 +- .../base/dists/binomial/stdev/src/main.c | 9 ++- .../dists/binomial/stdev/test/test.native.js | 14 +---- 11 files changed, 150 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/README.md b/lib/node_modules/@stdlib/math/base/napi/binary/README.md index e1ff3cd3af7a..290e0e760314 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/binary/README.md @@ -820,6 +820,29 @@ The macro expects the following arguments: When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +#### STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn ) + +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. + +```c +#include + +static double mul( const int32_t x, const double y ) { + return x * y; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( int32_t, double )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + #### STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn ) Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h index 4315f1072eac..13328645083a 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h @@ -342,6 +342,48 @@ }; \ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_di_d_init ) +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static double mul( const int32_t n, const double x ) { +* return x * n; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn ) \ + static napi_value stdlib_math_base_napi_id_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_id_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_id_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_id_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_id_d_init ) + /** * Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. * @@ -690,6 +732,11 @@ napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, st */ napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ); +/** +* Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ); + /** * Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. */ diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c index 07d3b89c5f6e..b6de9eb38b48 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c @@ -524,6 +524,68 @@ napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, do return v; } +/** +* Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} + /** * Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. * diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js index 87f1398b7b62..5d46acc6b546 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var ceil = require( '@stdlib/math/base/special/ceil' ); +var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); @@ -39,7 +40,7 @@ bench( pkg, function benchmark( b ) { var i; len = 100; - n = new Float64Array( len ); + n = new Int32Array( len ); p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { n[ i ] = ceil( randu()*100.0 ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js index 40691f5f6baa..eeb1d812de95 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js @@ -22,6 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); +var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var ceil = require( '@stdlib/math/base/special/ceil' ); @@ -48,7 +49,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; len = 100; - n = new Float64Array( len ); + n = new Int32Array( len ); p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { n[ i ] = ceil( randu()*100.0 ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c index f0a6e4c81e33..ba894c362906 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c @@ -19,6 +19,7 @@ #include "stdlib/stats/base/dists/binomial/stdev.h" #include "stdlib/math/base/special/ceil.h" #include +#include #include #include #include @@ -94,7 +95,7 @@ static double random_uniform( const double min, const double max ) { */ static double benchmark( void ) { double elapsed; - double n[ 100 ]; + int32_t n[ 100 ]; double p[ 100 ]; double y; double t; diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c index a09acfa0ca40..b7e84f2ecc38 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c @@ -19,6 +19,7 @@ #include "stdlib/stats/base/dists/binomial/stdev.h" #include "stdlib/math/base/special/ceil.h" #include +#include #include static double random_uniform( const double min, const double max ) { @@ -27,7 +28,7 @@ static double random_uniform( const double min, const double max ) { } int main( void ) { - double n; + int32_t n; double p; double y; int i; @@ -36,7 +37,7 @@ int main( void ) { n = stdlib_base_ceil( random_uniform( 0, 100 ) ); p = random_uniform( 0, 1 ); y = stdlib_base_dists_binomial_stdev( n, p ); - printf( "n: %lf, p: %lf, SD(X;n,p): %lf\n", n, p, y ); + printf( "n: %d, p: %lf, SD(X;n,p): %lf\n", n, p, y ); } return 0; diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h index e412bd1fc3c1..1b5cf7b40c9c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h @@ -19,6 +19,8 @@ #ifndef STDLIB_STATS_BASE_DISTS_BINOMIAL_STDEV_H #define STDLIB_STATS_BASE_DISTS_BINOMIAL_STDEV_H +#include + /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. */ @@ -29,7 +31,7 @@ extern "C" { /** * Returns the standard deviation of a binomial distribution. */ -double stdlib_base_dists_binomial_stdev( const double n, const double p ); +double stdlib_base_dists_binomial_stdev( const int32_t n, const double p ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c index 15ffd84734cd..7b6da3ffbe8c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c @@ -20,4 +20,4 @@ #include "stdlib/math/base/napi/binary.h" // cppcheck-suppress shadowFunction -STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_binomial_stdev ); +STDLIB_MATH_BASE_NAPI_MODULE_ID_D( stdlib_base_dists_binomial_stdev ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c index d1809deab65f..1938da23c413 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c @@ -21,6 +21,7 @@ #include "stdlib/constants/float64/pinf.h" #include "stdlib/math/base/special/sqrt.h" #include "stdlib/math/base/assert/is_nonnegative_integer.h" +#include /** * Returns the standard deviation of a binomial distribution. @@ -33,15 +34,13 @@ * double y = stdlib_base_dists_binomial_stdev( 100, 0.1 ); * // returns 3.0 */ -double stdlib_base_dists_binomial_stdev( const double n, const double p ) { +double stdlib_base_dists_binomial_stdev( const int32_t n, const double p ) { if ( - stdlib_base_is_nan( n ) || stdlib_base_is_nan( p ) || n < 0.0 || + n >= INT32_MAX || p < 0.0 || - p > 1.0 || - !stdlib_base_is_nonnegative_integer( n ) || - n == STDLIB_CONSTANT_FLOAT64_PINF + p > 1.0 ) { return 0.0 / 0.0; } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js index cdb90688f798..65de850133d7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js @@ -50,36 +50,24 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) { - var v = stdev( NaN, 0.5 ); + var v = stdev( NaN, NaN ); t.equal( isnan( v ), true, 'returns NaN' ); v = stdev( 10, NaN ); t.equal( isnan( v ), true, 'returns NaN' ); - v = stdev( NaN, NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); - t.end(); }); tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { var v; - v = stdev( 1.5, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); - v = stdev( -2, 0.5 ); t.equal( isnan( v ), true, 'returns NaN' ); v = stdev( -1, 0.5 ); t.equal( isnan( v ), true, 'returns NaN' ); - v = stdev( 2.5, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); - - v = stdev( PINF, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); - t.end(); }); From 94f67a0ab09da155dca16da3b575dab114c289a4 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:03:50 +0530 Subject: [PATCH 04/12] docs: edited docs --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../@stdlib/stats/base/dists/binomial/stdev/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md index 097bce200fc4..2fe08fca8832 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md @@ -205,6 +205,7 @@ double stdlib_base_dists_binomial_stdev( const int n, const double p ); #include "stdlib/stats/base/dists/binomial/stdev.h" #include "stdlib/math/base/special/ceil.h" #include +#include #include static double random_uniform( const double min, const double max ) { @@ -213,7 +214,7 @@ static double random_uniform( const double min, const double max ) { } int main( void ) { - double n; + int32_t n; double p; double y; int i; @@ -222,7 +223,7 @@ int main( void ) { n = stdlib_base_ceil( random_uniform( 0, 100 ) ); p = random_uniform( 0, 1 ); y = stdlib_base_dists_binomial_stdev( n, p ); - printf( "n: %lf, p: %lf, SD(X;n,p): %lf\n", n, p, y ); + printf( "n: %d, p: %lf, SD(X;n,p): %lf\n", n, p, y ); } return 0; From 1d41590517fc94776f34258b7b272030785dc1b0 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:03:32 +0530 Subject: [PATCH 05/12] fix: edited examples Signed-off-by: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> --- .../@stdlib/stats/base/dists/binomial/stdev/lib/native.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js index 75db636470dd..a08934221346 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js @@ -42,10 +42,6 @@ var addon = require( './../src/addon.node' ); * // returns ~2.236 * * @example -* var v = stdev( 10.3, 0.5 ); -* // returns NaN -* -* @example * var v = stdev( 20, 1.1 ); * // returns NaN * From e0769fda1b4b1364806900a5ccf7e7b4ddc8b8b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 3 Jan 2025 12:35:37 +0000 Subject: [PATCH 06/12] chore: update copyright years --- .../base/dists/binomial/stdev/benchmark/benchmark.native.js | 2 +- .../stats/base/dists/binomial/stdev/benchmark/c/Makefile | 2 +- .../stats/base/dists/binomial/stdev/benchmark/c/benchmark.c | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/binding.gyp | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile | 2 +- .../stats/base/dists/binomial/stdev/examples/c/example.c | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/include.gypi | 2 +- .../stdev/include/stdlib/stats/base/dists/binomial/stdev.h | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/lib/native.js | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/src/Makefile | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/src/addon.c | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/src/main.c | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/test/test.native.js | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js index eeb1d812de95..b5569a5695e1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/Makefile index f69e9da2b4d3..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c index ba894c362906..601f7fbf091b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/binding.gyp index ec3992233442..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/binding.gyp +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile index 6aed70daf167..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c index b7e84f2ecc38..a47e0516d8fd 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi index 575cb043c0bf..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h index 1b5cf7b40c9c..b3355b6715fe 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js index a08934221346..84e957266a29 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/Makefile index bcf18aa46655..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c index 7b6da3ffbe8c..57a550f53544 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c index 1938da23c413..19de0cc71405 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js index 65de850133d7..e9503a40a57b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. From e2f2aec52496d6bb6f1e192bc008b46bb0a8b512 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:51:51 +0530 Subject: [PATCH 07/12] chore: minor changes as per given review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../stats/base/dists/binomial/stdev/benchmark/benchmark.js | 2 +- .../base/dists/binomial/stdev/benchmark/benchmark.native.js | 2 +- .../stats/base/dists/binomial/stdev/benchmark/c/benchmark.c | 4 ++-- .../stats/base/dists/binomial/stdev/examples/c/example.c | 4 ++-- .../stdev/include/stdlib/stats/base/dists/binomial/stdev.h | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/lib/native.js | 2 +- .../@stdlib/stats/base/dists/binomial/stdev/src/main.c | 3 +-- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js index 5d46acc6b546..8173b1795483 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js @@ -43,7 +43,7 @@ bench( pkg, function benchmark( b ) { n = new Int32Array( len ); p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - n[ i ] = ceil( randu()*100.0 ); + n[ i ] = ceil( randu() * 100.0 ); p[ i ] = randu(); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js index b5569a5695e1..91a9bc1c2a27 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js @@ -52,7 +52,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { n = new Int32Array( len ); p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - n[ i ] = ceil( randu()*100.0 ); + n[ i ] = ceil( randu() * 100.0 ); p[ i ] = randu(); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c index 601f7fbf091b..6208e2b6bebb 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/c/benchmark.c @@ -102,8 +102,8 @@ static double benchmark( void ) { int i; for ( i = 0; i < 100; i++ ) { - n[ i ] = stdlib_base_ceil( random_uniform( 0, 100 ) ); - p[ i ] = random_uniform( 0, 1 ); + n[ i ] = stdlib_base_ceil( random_uniform( 0.0, 100.0 ) ); + p[ i ] = random_uniform( 0.0, 1.0 ); } t = tic(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c index a47e0516d8fd..40e2a40cd795 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/examples/c/example.c @@ -34,8 +34,8 @@ int main( void ) { int i; for ( i = 0; i < 25; i++ ) { - n = stdlib_base_ceil( random_uniform( 0, 100 ) ); - p = random_uniform( 0, 1 ); + n = stdlib_base_ceil( random_uniform( 0.0, 100.0 ) ); + p = random_uniform( 0.0, 1.0 ); y = stdlib_base_dists_binomial_stdev( n, p ); printf( "n: %d, p: %lf, SD(X;n,p): %lf\n", n, p, y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h index b3355b6715fe..b09c21f04069 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/include/stdlib/stats/base/dists/binomial/stdev.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Returns the standard deviation of a binomial distribution. +* Returns the standard deviation of a binomial distribution with number of trials `n` and success probability `p`. */ double stdlib_base_dists_binomial_stdev( const int32_t n, const double p ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js index 84e957266a29..3a25ff14c04c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Returns the standard deviation of a binomial distribution. +* Returns the standard deviation of a binomial distribution with number of trials `n` and success probability `p`. * * @private * @param {NonNegativeInteger} n - number of trials diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c index 19de0cc71405..1741ad63130f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c @@ -37,8 +37,7 @@ double stdlib_base_dists_binomial_stdev( const int32_t n, const double p ) { if ( stdlib_base_is_nan( p ) || - n < 0.0 || - n >= INT32_MAX || + n < 0 || p < 0.0 || p > 1.0 ) { From 0c75d76b1f6f1334d238ecab8950521439cc8caf Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:01:45 +0530 Subject: [PATCH 08/12] chore: updated docs --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/math/base/napi/binary/README.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/README.md b/lib/node_modules/@stdlib/math/base/napi/binary/README.md index 290e0e760314..f92b10cb0563 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/binary/README.md @@ -331,6 +331,46 @@ The function accepts the following arguments: void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ); ``` +#### stdlib_math_base_napi_id_d( env, info, fcn ) + +Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. + +```c +#include +#include + +// ... + +static double mul( const int32_t x, const double y ) { + return x * y; +} + +// ... + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_id_d( env, info, mul ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( int32_t, double )` binary function. + +```c +void stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ); +``` + #### stdlib_math_base_napi_ii_i( env, info, fcn ) Invokes a binary function accepting and returning signed 32-bit integers. From 03b5650c4c4fb9a6ee2ca41f480adb24f877c800 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Sat, 11 Jan 2025 14:15:42 +0530 Subject: [PATCH 09/12] fix: removed unwanted dependencies --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/base/dists/binomial/stdev/manifest.json | 6 ------ .../@stdlib/stats/base/dists/binomial/stdev/src/main.c | 2 -- 2 files changed, 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json index f3fbdcce3ee3..601cc36d008e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json @@ -40,9 +40,7 @@ "dependencies": [ "@stdlib/math/base/napi/binary", "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/assert/is-nonnegative-integer", "@stdlib/math/base/special/sqrt", - "@stdlib/constants/float64/pinf", "@stdlib/math/base/special/ceil" ] }, @@ -59,9 +57,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/assert/is-nonnegative-integer", "@stdlib/math/base/special/sqrt", - "@stdlib/constants/float64/pinf", "@stdlib/math/base/special/ceil" ] }, @@ -78,9 +74,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/assert/is-nonnegative-integer", "@stdlib/math/base/special/sqrt", - "@stdlib/constants/float64/pinf", "@stdlib/math/base/special/ceil" ] } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c index 1741ad63130f..e4a75ab560bf 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/src/main.c @@ -18,9 +18,7 @@ #include "stdlib/stats/base/dists/binomial/stdev.h" #include "stdlib/math/base/assert/is_nan.h" -#include "stdlib/constants/float64/pinf.h" #include "stdlib/math/base/special/sqrt.h" -#include "stdlib/math/base/assert/is_nonnegative_integer.h" #include /** From 4e237c1f4cab384518e6e56662f9ce1a5d22ae4e Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Mon, 17 Feb 2025 22:28:30 +0530 Subject: [PATCH 10/12] chore: removed math/base/napi --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/math/base/napi/README.md | 4 +- .../@stdlib/math/base/napi/binary/README.md | 936 +++++++---- .../include/stdlib/math/base/napi/binary.h | 784 +--------- .../stdlib/math/base/napi/binary/cc_c.h | 98 ++ .../stdlib/math/base/napi/binary/cf_c.h | 89 ++ .../stdlib/math/base/napi/binary/ci_c.h | 91 ++ .../stdlib/math/base/napi/binary/dd_d.h | 81 + .../stdlib/math/base/napi/binary/di_d.h | 84 + .../stdlib/math/base/napi/binary/dz_z.h | 89 ++ .../stdlib/math/base/napi/binary/fc_c.h | 89 ++ .../stdlib/math/base/napi/binary/ff_f.h | 81 + .../stdlib/math/base/napi/binary/fi_f.h | 84 + .../stdlib/math/base/napi/binary/id_d.h | 84 + .../stdlib/math/base/napi/binary/ii_d.h | 84 + .../stdlib/math/base/napi/binary/ii_f.h | 84 + .../stdlib/math/base/napi/binary/ii_i.h | 84 + .../stdlib/math/base/napi/binary/ll_d.h | 84 + .../stdlib/math/base/napi/binary/zd_z.h | 89 ++ .../stdlib/math/base/napi/binary/zi_z.h | 91 ++ .../stdlib/math/base/napi/binary/zz_z.h | 98 ++ .../math/base/napi/binary/manifest.json | 17 +- .../@stdlib/math/base/napi/binary/src/cc_c.c | 179 +++ .../@stdlib/math/base/napi/binary/src/cf_c.c | 143 ++ .../@stdlib/math/base/napi/binary/src/ci_c.c | 143 ++ .../@stdlib/math/base/napi/binary/src/dd_d.c | 83 + .../@stdlib/math/base/napi/binary/src/di_d.c | 84 + .../@stdlib/math/base/napi/binary/src/dz_z.c | 142 ++ .../@stdlib/math/base/napi/binary/src/fc_c.c | 142 ++ .../@stdlib/math/base/napi/binary/src/ff_f.c | 83 + .../@stdlib/math/base/napi/binary/src/fi_f.c | 84 + .../@stdlib/math/base/napi/binary/src/id_d.c | 84 + .../@stdlib/math/base/napi/binary/src/ii_d.c | 84 + .../@stdlib/math/base/napi/binary/src/ii_f.c | 84 + .../@stdlib/math/base/napi/binary/src/ii_i.c | 84 + .../@stdlib/math/base/napi/binary/src/ll_d.c | 84 + .../@stdlib/math/base/napi/binary/src/main.c | 1373 ----------------- .../@stdlib/math/base/napi/binary/src/zd_z.c | 142 ++ .../@stdlib/math/base/napi/binary/src/zi_z.c | 143 ++ .../@stdlib/math/base/napi/binary/src/zz_z.c | 179 +++ .../@stdlib/math/base/napi/ternary/README.md | 376 ++++- .../include/stdlib/math/base/napi/ternary.h | 158 +- .../stdlib/math/base/napi/ternary/ccc_c.h | 101 ++ .../stdlib/math/base/napi/ternary/ddd_d.h | 81 + .../stdlib/math/base/napi/ternary/dii_d.h | 84 + .../stdlib/math/base/napi/ternary/fff_f.h | 81 + .../stdlib/math/base/napi/ternary/iid_d.h | 84 + .../stdlib/math/base/napi/ternary/iii_d.h | 84 + .../stdlib/math/base/napi/ternary/zzz_z.h | 101 ++ .../math/base/napi/ternary/manifest.json | 15 +- .../math/base/napi/ternary/src/ccc_c.c | 230 +++ .../math/base/napi/ternary/src/ddd_d.c | 97 ++ .../math/base/napi/ternary/src/dii_d.c | 98 ++ .../math/base/napi/ternary/src/fff_f.c | 97 ++ .../math/base/napi/ternary/src/iid_d.c | 98 ++ .../math/base/napi/ternary/src/iii_d.c | 98 ++ .../@stdlib/math/base/napi/ternary/src/main.c | 250 --- .../math/base/napi/ternary/src/zzz_z.c | 230 +++ 57 files changed, 6026 insertions(+), 2902 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cc_c.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cf_c.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ci_c.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dd_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/di_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dz_z.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fc_c.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ff_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fi_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/id_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_i.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ll_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zd_z.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zi_z.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zz_z.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/cc_c.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/cf_c.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/ci_c.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/dd_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/di_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/dz_z.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/fc_c.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/ff_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/fi_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/id_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/ii_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/ii_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/ii_i.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/ll_d.c delete mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/zd_z.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/zi_z.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/binary/src/zz_z.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ccc_c.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ddd_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/fff_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/zzz_z.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/ccc_c.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/ddd_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/dii_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/fff_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/iid_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/iii_d.c delete mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/ternary/src/zzz_z.c diff --git a/lib/node_modules/@stdlib/math/base/napi/README.md b/lib/node_modules/@stdlib/math/base/napi/README.md index 00808ad8ba9b..01e18d84d386 100644 --- a/lib/node_modules/@stdlib/math/base/napi/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/README.md @@ -45,10 +45,10 @@ The namespace contains the following packages:
-- [`binary( env, info, fcn )`][@stdlib/math/base/napi/binary]: C APIs for registering a Node-API module exporting interfaces for invoking binary numerical functions. +- [`binary( fcn )`][@stdlib/math/base/napi/binary]: C APIs for registering a Node-API module exporting interfaces for invoking binary numerical functions. - [`quaternary( env, info, fcn )`][@stdlib/math/base/napi/quaternary]: C APIs for registering a Node-API module exporting interfaces for invoking quaternary numerical functions. - [`quinary( env, info, fcn )`][@stdlib/math/base/napi/quinary]: C APIs for registering a Node-API module exporting interfaces for invoking quinary numerical functions. -- [`ternary( env, info, fcn )`][@stdlib/math/base/napi/ternary]: C APIs for registering a Node-API module exporting interfaces for invoking ternary numerical functions. +- [`ternary( fcn )`][@stdlib/math/base/napi/ternary]: C APIs for registering a Node-API module exporting interfaces for invoking ternary numerical functions. - [`unary( env, info, fcn )`][@stdlib/math/base/napi/unary]: C APIs for registering a Node-API module exporting interfaces for invoking unary numerical functions.
diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/README.md b/lib/node_modules/@stdlib/math/base/napi/binary/README.md index f92b10cb0563..79a911f63dd7 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/binary/README.md @@ -104,56 +104,71 @@ console.log( headerDir ); #include "stdlib/math/base/napi/binary.h" ``` -#### stdlib_math_base_napi_dd_d( env, info, fcn ) + -Invokes a binary function accepting and returning double-precision floating-point numbers. +#### STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision complex floating-point numbers. ```c -#include +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" -// ... +static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) { + float xre; + float xim; + float yre; + float yim; + float re; + float im; -static double add( const double x, const double y ) { - return x + y; -} + stdlib_complex64_reim( x, &xre, &xim ); + stdlib_complex64_reim( y, &yre, &yim ); -// ... + re = xre + yre; + im = xim + yim; -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_dd_d( env, info, add ); + return stdlib_complex64( re, im ); } // ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add ); ``` -The function accepts the following arguments: +The macro expects the following arguments: -- **env**: `[in] napi_env` environment under which the function is invoked. -- **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] double (*fcn)( double, double )` binary function. +- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function. -```c -void stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) ); -``` +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### stdlib_math_base_napi_ff_f( env, info, fcn ) +#### stdlib_math_base_napi_cc_c( env, info, fcn ) -Invokes a binary function accepting and returning single-precision floating-point numbers. +Invokes a binary function accepting and returning single-precision complex floating-point numbers. ```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" #include // ... -static float addf( const float x, const float y ) { - return x + y; +static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) { + float xre; + float xim; + float yre; + float yim; + float re; + float im; + + stdlib_complex64_reim( x, &xre, &xim ); + stdlib_complex64_reim( y, &yre, &yim ); + + re = xre + yre; + im = xim + yim; + + return stdlib_complex64( re, im ); } // ... @@ -166,7 +181,7 @@ static float addf( const float x, const float y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ff_f( env, info, addf ); + return stdlib_math_base_napi_cc_c( env, info, add ); } // ... @@ -176,91 +191,67 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] float (*fcn)( float, float )` binary function. +- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function. -````c -void stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) ); -```de "stdlib/math/base/napi/binary.h" -```` +```c +void stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) ); +``` -#### stdlib_math_base_napi_zz_z( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) -Invokes a binary function accepting and returning double-precision complex floating-point numbers. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. ```c -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float64/reim.h" -#include - -// ... +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" -static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) { - double xre; - double xim; - double yre; - double yim; - double re; - double im; +static stdlib_complex64_t add( const stdlib_complex64_t x, const float y ) { + float xre; + float xim; + float re; + float im; - stdlib_complex128_reim( x, &xre, &xim ); - stdlib_complex128_reim( y, &yre, &yim ); + stdlib_complex64_reim( x, &xre, &xim ); - re = xre + yre; - im = xim + yim; + re = xre * y; + im = xim * y; - return stdlib_complex128( re, im ); + return stdlib_complex64( re, im ); } // ... -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_zz_z( env, info, add ); -} - -// ... +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_CF_C( add ); ``` -The function accepts the following arguments: +The macro expects the following arguments: -- **env**: `[in] napi_env` environment under which the function is invoked. -- **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function. +- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function. -```c -void stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) ); -``` +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### stdlib_math_base_napi_cc_c( env, info, fcn ) +#### stdlib_math_base_napi_cf_c( env, info, fcn ) -Invokes a binary function accepting and returning single-precision complex floating-point numbers. +Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. ```c -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float64/reim.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include // ... -static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) { +static stdlib_complex64_t mul( const stdlib_complex64_t x, const float y ) { float xre; float xim; - float yre; - float yim; float re; float im; stdlib_complex64_reim( x, &xre, &xim ); - stdlib_complex64_reim( y, &yre, &yim ); - re = xre + yre; - im = xim + yim; + re = xre * y; + im = xim * y; return stdlib_complex64( re, im ); } @@ -275,7 +266,7 @@ static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex6 * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_cc_c( env, info, add ); + return stdlib_math_base_napi_cf_c( env, info, mul ); } // ... @@ -285,64 +276,71 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function. +- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function. ```c -void stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) ); +void stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) ); ``` -#### stdlib_math_base_napi_di_d( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) -Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. ```c -#include +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include -// ... +static stdlib_complex64_t add( const stdlib_complex64_t x, const int32_t y ) { + float xre; + float xim; + float re; + float im; -static double mul( const double x, const int32_t y ) { - return x * y; -} + stdlib_complex64_reim( x, &xre, &xim ); -// ... + re = xre * y; + im = xim * y; -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_di_d( env, info, mul ); + return stdlib_complex64( re, im ); } // ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_CI_C( add ); ``` -The function accepts the following arguments: +The macro expects the following arguments: -- **env**: `[in] napi_env` environment under which the function is invoked. -- **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] double (*fcn)( double, int32_t )` binary function. +- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function. -```c -void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ); -``` +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### stdlib_math_base_napi_id_d( env, info, fcn ) +#### stdlib_math_base_napi_ci_c( env, info, fcn ) -Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. ```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float32/reim.h" #include #include // ... -static double mul( const int32_t x, const double y ) { - return x * y; +static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) { + float xre; + float xim; + float re; + float im; + + stdlib_complex64_reim( x, &xre, &xim ); + + re = xre * y; + im = xim * y; + + return stdlib_complex64( re, im ); } // ... @@ -355,7 +353,7 @@ static double mul( const int32_t x, const double y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_id_d( env, info, mul ); + return stdlib_math_base_napi_ci_c( env, info, mul ); } // ... @@ -365,24 +363,44 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] double (*fcn)( int32_t, double )` binary function. +- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function. ```c -void stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ); +void stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ); ``` -#### stdlib_math_base_napi_ii_i( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) -Invokes a binary function accepting and returning signed 32-bit integers. +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision floating-point numbers. + +```c +static double add( const double x, const double y ) { + return x + y; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, double )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_dd_d( env, info, fcn ) + +Invokes a binary function accepting and returning double-precision floating-point numbers. ```c #include -#include // ... -static int32_t mul( const int32_t x, const int32_t y ) { - return x * y; +static double add( const double x, const double y ) { + return x + y; } // ... @@ -395,7 +413,7 @@ static int32_t mul( const int32_t x, const int32_t y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ii_i( env, info, mul ); + return stdlib_math_base_napi_dd_d( env, info, add ); } // ... @@ -405,55 +423,38 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] int32_t (*fcn)( int32_t, int32_t )` binary function. +- **fcn**: `[in] double (*fcn)( double, double )` binary function. ```c -void stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) ); +void stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) ); ``` -#### stdlib_math_base_napi_ii_d( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn ) -Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. ```c -#include #include -// ... - -static double mul( const int32_t x, const int32_t y ) { +static double mul( const double x, const int32_t y ) { return x * y; } // ... -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ii_d( env, info, mul ); -} - -// ... +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul ); ``` -The function accepts the following arguments: +The macro expects the following arguments: -- **env**: `[in] napi_env` environment under which the function is invoked. -- **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] double (*fcn)( int32_t, int32_t )` binary function. +- **fcn**: `double (*fcn)( double, int32_t )` binary function. -```c -void stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) ); -``` +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### stdlib_math_base_napi_fi_f( env, info, fcn ) +#### stdlib_math_base_napi_di_d( env, info, fcn ) -Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. +Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. ```c #include @@ -461,7 +462,7 @@ Invokes a binary function accepting a single-precision floating-point number and // ... -static float mulf( const float x, const int32_t y ) { +static double mul( const double x, const int32_t y ) { return x * y; } @@ -475,7 +476,7 @@ static float mulf( const float x, const int32_t y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_fi_f( env, info, mulf ); + return stdlib_math_base_napi_di_d( env, info, mul ); } // ... @@ -485,25 +486,58 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] float (*fcn)( float, int32_t )` binary function. +- **fcn**: `[in] double (*fcn)( double, int32_t )` binary function. ```c -void stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) ); +void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ); ``` -#### stdlib_math_base_napi_zi_z( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( fcn ) -Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. + +```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" + +static stdlib_complex128_t mul( const double y, const stdlib_complex128_t x ) { + double xre; + double xim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); + + re = xre * y; + im = xim * y; + + return stdlib_complex128( re, im ); +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( mul ); +``` + +The macro expects the following arguments: + +- **fcn**: `stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_dz_z( env, info, fcn ) + +Invokes a binary function accepting a double-precision floating-point number and a double-precision complex floating-point number and returning a double-precision complex floating-point number. ```c #include "stdlib/complex/float64/ctor.h" #include "stdlib/complex/float64/reim.h" #include -#include // ... -static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) { +static stdlib_complex128_t mul( const double y, const stdlib_complex128_t x ) { double xre; double xim; double re; @@ -527,7 +561,7 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_zi_z( env, info, mul ); + return stdlib_math_base_napi_dz_z( env, info, mul ); } // ... @@ -537,25 +571,58 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function. +- **fcn**: `[in] stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function. ```c -void stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ); +void stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) ); ``` -#### stdlib_math_base_napi_ci_c( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_FC_C( fcn ) -Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. ```c -#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" + +static stdlib_complex64_t mul( const float y, const stdlib_complex64_t x ) { + float xre; + float xim; + float re; + float im; + + stdlib_complex64_reim( x, &xre, &xim ); + + re = xre * y; + im = xim * y; + + return stdlib_complex64( re, im ); +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_FC_C( mul ); +``` + +The macro expects the following arguments: + +- **fcn**: `stdlib_complex64_t (*fcn)( float, stdlib_complex64_t )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_fc_c( env, info, fcn ) + +Invokes a binary function accepting a single-precision floating-point number and a single-precision complex floating-point number and returning a single-precision complex floating-point number. + +```c +#include "stdlib/complex/float32/ctor.h" #include "stdlib/complex/float32/reim.h" #include -#include // ... -static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) { +static stdlib_complex64_t mul( const float y, const stdlib_complex64_t x ) { float xre; float xim; float re; @@ -579,7 +646,7 @@ static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ci_c( env, info, mul ); + return stdlib_math_base_napi_fc_c( env, info, mul ); } // ... @@ -589,24 +656,44 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function. +- **fcn**: `[in] stdlib_complex64_t (*fcn)( float, stdlib_complex64_t )` binary function. ```c -void stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ); +void stdlib_math_base_napi_fc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( float, stdlib_complex64_t ) ); ``` -#### stdlib_math_base_napi_ll_d( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn ) -Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision floating-point numbers. + +```c +static float addf( const float x, const float y ) { + return x + y; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_FF_F( addf ); +``` + +The macro expects the following arguments: + +- **fcn**: `float (*fcn)( float, float )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_ff_f( env, info, fcn ) + +Invokes a binary function accepting and returning single-precision floating-point numbers. ```c #include -#include // ... -static double fcn( const int64_t x, const int64_t y ) { - // ... +static float addf( const float x, const float y ) { + return x + y; } // ... @@ -619,7 +706,7 @@ static double fcn( const int64_t x, const int64_t y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ll_d( env, info, fcn ); + return stdlib_math_base_napi_ff_f( env, info, addf ); } // ... @@ -629,15 +716,39 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] double (*fcn)( int64_t, int64_t )` binary function. +- **fcn**: `[in] float (*fcn)( float, float )` binary function. + +````c +void stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) ); +```de "stdlib/math/base/napi/binary.h" +```` + +#### STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn ) + +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. ```c -void stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ); +#include + +static float mulf( const float x, const int32_t y ) { + return x * y; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf ); ``` -#### stdlib_math_base_napi_ii_f( env, info, fcn ) +The macro expects the following arguments: -Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +- **fcn**: `float (*fcn)( float, int32_t )` binary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_fi_f( env, info, fcn ) + +Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. ```c #include @@ -645,8 +756,8 @@ Invokes a binary function accepting signed 32-bit integers and returning a singl // ... -static float fcn( const int32_t x, const int32_t y ) { - // ... +static float mulf( const float x, const int32_t y ) { + return x * y; } // ... @@ -659,7 +770,7 @@ static float fcn( const int32_t x, const int32_t y ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ii_f( env, info, fcn ); + return stdlib_math_base_napi_fi_f( env, info, mulf ); } // ... @@ -669,55 +780,74 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] float (*fcn)( int32_t, int32_t )` binary function. +- **fcn**: `[in] float (*fcn)( float, int32_t )` binary function. ```c -void stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ); +void stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) ); ``` -#### STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn ) -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision floating-point numbers. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. ```c -static double add( const double x, const double y ) { - return x + y; +#include + +static double mul( const int32_t x, const double y ) { + return x * y; } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add ); +STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( double, double )` binary function. +- **fcn**: `double (*fcn)( int32_t, double )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_II_I( fcn ) +#### stdlib_math_base_napi_id_d( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning signed 32-bit integers. +Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. ```c +#include #include -static int32_t add( const int32_t x, const int32_t y ) { - return x + y; +// ... + +static double mul( const int32_t x, const double y ) { + return x * y; } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_II_I( add ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_id_d( env, info, mul ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `int32_t (*fcn)( int32_t, int32_t )` binary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( int32_t, double )` binary function. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +void stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ); +``` #### STDLIB_MATH_BASE_NAPI_MODULE_II_D( fcn ) @@ -742,180 +872,244 @@ The macro expects the following arguments: When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn ) +#### stdlib_math_base_napi_ii_d( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision floating-point numbers. +Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. ```c -static float addf( const float x, const float y ) { - return x + y; -} +#include +#include // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_FF_F( addf ); -``` +static double mul( const int32_t x, const int32_t y ) { + return x * y; +} -The macro expects the following arguments: +// ... -- **fcn**: `float (*fcn)( float, float )` binary function. +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_ii_d( env, info, mul ); +} -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +// ... +``` -#### STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn ) +The function accepts the following arguments: -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision complex floating-point numbers. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( int32_t, int32_t )` binary function. ```c -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float64/reim.h" +void stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) ); +``` -static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) { - double xre; - double xim; - double yre; - double yim; - double re; - double im; +#### STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ) - stdlib_complex128_reim( x, &xre, &xim ); - stdlib_complex128_reim( y, &yre, &yim ); +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. - re = xre + yre; - im = xim + yim; +```c +#include - return stdlib_complex128( re, im ); +static float fcn( const int32_t x, const int32_t y ) { + // ... } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add ); +STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ); ``` The macro expects the following arguments: -- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function. +- **fcn**: `float (*fcn)( int32_t, int32_t )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) +#### stdlib_math_base_napi_ii_f( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision complex floating-point numbers. +Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. ```c -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float32/reim.h" +#include +#include -static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) { - float xre; - float xim; - float yre; - float yim; - float re; - float im; +// ... - stdlib_complex64_reim( x, &xre, &xim ); - stdlib_complex64_reim( y, &yre, &yim ); +static float fcn( const int32_t x, const int32_t y ) { + // ... +} - re = xre + yre; - im = xim + yim; +// ... - return stdlib_complex64( re, im ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_ii_f( env, info, fcn ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] float (*fcn)( int32_t, int32_t )` binary function. + +```c +void stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ); +``` + +#### STDLIB_MATH_BASE_NAPI_MODULE_II_I( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning signed 32-bit integers. + +```c +#include + +static int32_t add( const int32_t x, const int32_t y ) { + return x + y; } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add ); +STDLIB_MATH_BASE_NAPI_MODULE_II_I( add ); ``` The macro expects the following arguments: -- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function. +- **fcn**: `int32_t (*fcn)( int32_t, int32_t )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn ) +#### stdlib_math_base_napi_ii_i( env, info, fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. +Invokes a binary function accepting and returning signed 32-bit integers. ```c +#include #include -static double mul( const double x, const int32_t y ) { +// ... + +static int32_t mul( const int32_t x, const int32_t y ) { return x * y; } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_ii_i( env, info, mul ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `double (*fcn)( double, int32_t )` binary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] int32_t (*fcn)( int32_t, int32_t )` binary function. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +void stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) ); +``` -#### STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. ```c #include -static double mul( const int32_t x, const double y ) { - return x * y; +static double fcn( const int64_t x, const int64_t y ) { + // ... } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul ); +STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( int32_t, double )` binary function. +- **fcn**: `double (*fcn)( int64_t, int64_t )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn ) +#### stdlib_math_base_napi_ll_d( env, info, fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. +Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. ```c +#include #include -static float mulf( const float x, const int32_t y ) { - return x * y; +// ... + +static double fcn( const int64_t x, const int64_t y ) { + // ... } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_ll_d( env, info, fcn ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `float (*fcn)( float, int32_t )` binary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( int64_t, int64_t )` binary function. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +void stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ); +``` -#### STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. ```c #include "stdlib/complex/float64/ctor.h" #include "stdlib/complex/float64/reim.h" -#include -static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) { +static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) { double xre; double xim; double re; @@ -932,59 +1126,76 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) { // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul ); +STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul ); ``` The macro expects the following arguments: -- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function. +- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) +#### stdlib_math_base_napi_zd_z( env, info, fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. +Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. ```c -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float32/reim.h" -#include +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include -static stdlib_complex64_t add( const stdlib_complex64_t x, const int32_t y ) { - float xre; - float xim; - float re; - float im; +// ... - stdlib_complex64_reim( x, &xre, &xim ); +static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) { + double xre; + double xim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); re = xre * y; im = xim * y; - return stdlib_complex64( re, im ); + return stdlib_complex128( re, im ); } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_CI_C( add ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_zd_z( env, info, mul ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +void stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ); +``` -#### STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. +Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number. ```c #include "stdlib/complex/float64/ctor.h" #include "stdlib/complex/float64/reim.h" +#include -static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) { +static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) { double xre; double xim; double re; @@ -1001,94 +1212,157 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) { // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul ); +STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul ); ``` The macro expects the following arguments: -- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function. +- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) +#### stdlib_math_base_napi_zi_z( env, info, fcn ) -Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. +Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number. ```c -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float32/reim.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include -static stdlib_complex64_t add( const stdlib_complex64_t x, const float y ) { - float xre; - float xim; - float re; - float im; +// ... - stdlib_complex64_reim( x, &xre, &xim ); +static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) { + double xre; + double xim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); re = xre * y; im = xim * y; - return stdlib_complex64( re, im ); + return stdlib_complex128( re, im ); } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_CF_C( add ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_zi_z( env, info, mul ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +void stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ); +``` -#### STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn ) -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. +Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision complex floating-point numbers. ```c -#include +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" -static double fcn( const int64_t x, const int64_t y ) { - // ... +static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) { + double xre; + double xim; + double yre; + double yim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); + stdlib_complex128_reim( y, &yre, &yim ); + + re = xre + yre; + im = xim + yim; + + return stdlib_complex128( re, im ); } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ); +STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( int64_t, int64_t )` binary function. +- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ) +#### stdlib_math_base_napi_zz_z( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +Invokes a binary function accepting and returning double-precision complex floating-point numbers. ```c -#include +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include -static float fcn( const int32_t x, const int32_t y ) { - // ... +// ... + +static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) { + double xre; + double xim; + double yre; + double yim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); + stdlib_complex128_reim( y, &yre, &yim ); + + re = xre + yre; + im = xim + yim; + + return stdlib_complex128( re, im ); } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ); +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_zz_z( env, info, add ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `float (*fcn)( int32_t, int32_t )` binary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +void stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) ); +```
diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h index 13328645083a..a20fdf183d5c 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h @@ -19,771 +19,23 @@ #ifndef STDLIB_MATH_BASE_NAPI_BINARY_H #define STDLIB_MATH_BASE_NAPI_BINARY_H -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision floating-point numbers. -* -* @param fcn binary function -* -* @example -* static double add( const double x, const double y ) { -* return x + y; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) \ - static napi_value stdlib_math_base_napi_dd_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_dd_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_dd_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_dd_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dd_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning signed 32-bit integers. -* -* @param fcn binary function -* -* @example -* #include -* -* static int_32 add( const int_32 x, const int_32 y ) { -* return x + y; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_II_I( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_II_I( fcn ) \ - static napi_value stdlib_math_base_napi_ii_i_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ii_i( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ii_i_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ii_i_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_i_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. -* -* @param fcn binary function -* -* @example -* #include -* -* static double add( const int_32 x, const int_32 y ) { -* return x + y; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_II_D( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_II_D( fcn ) \ - static napi_value stdlib_math_base_napi_ii_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ii_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ii_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ii_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning single-precision floating-point numbers. -* -* @param fcn binary function -* -* @example -* static float addf( const float x, const float y ) { -* return x + y; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_FF_F( addf ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn ) \ - static napi_value stdlib_math_base_napi_ff_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ff_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ff_f_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ff_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ff_f_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision complex floating-point numbers. -* -* @param fcn binary function -* -* @example -* #include "stdlib/complex/float64/ctor.h" -* #include "stdlib/complex/float64/reim.h" -* -* static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) { -* double xre; -* double xim; -* double yre; -* double yim; -* double re; -* double im; -* -* stdlib_complex128_reim( x, &xre, &xim ); -* stdlib_complex128_reim( y, &yre, &yim ); -* -* re = xre + yre; -* im = xim + yim; -* -* return stdlib_complex128( re, im ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn ) \ - static napi_value stdlib_math_base_napi_zz_z_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_zz_z( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_zz_z_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_zz_z_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zz_z_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning single-precision complex floating-point numbers. -* -* @param fcn binary function -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* #include "stdlib/complex/float32/reim.h" -* -* static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) { -* float xre; -* float xim; -* float yre; -* float yim; -* float re; -* float im; -* -* stdlib_complex64_reim( x, &xre, &xim ); -* stdlib_complex64_reim( y, &yre, &yim ); -* -* re = xre + yre; -* im = xim + yim; -* -* return stdlib_complex64( re, im ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) \ - static napi_value stdlib_math_base_napi_cc_c_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_cc_c( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_cc_c_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_cc_c_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cc_c_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. -* -* @param fcn binary function -* -* @example -* #include -* -* static double mul( const double x, const int32_t n ) { -* return x * n; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn ) \ - static napi_value stdlib_math_base_napi_di_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_di_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_di_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_di_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_di_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. -* -* @param fcn binary function -* -* @example -* #include -* -* static double mul( const int32_t n, const double x ) { -* return x * n; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn ) \ - static napi_value stdlib_math_base_napi_id_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_id_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_id_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_id_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_id_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. -* -* @param fcn binary function -* -* @example -* #include -* -* static float mulf( const float x, const int32_t n ) { -* return x * n; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn ) \ - static napi_value stdlib_math_base_napi_fi_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_fi_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_fi_f_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_fi_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fi_f_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number. -* -* @param fcn binary function -* -* @example -* #include "stdlib/complex/float64/ctor.h" -* #include "stdlib/complex/float64/reim.h" -* #include -* -* static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t n ) { -* double re; -* double im; -* -* stdlib_complex128_reim( x, &re, &im ); -* return stdlib_complex128( re*n, im*n ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn ) \ - static napi_value stdlib_math_base_napi_zi_z_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_zi_z( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_zi_z_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_zi_z_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zi_z_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. -* -* @param fcn binary function -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* #include "stdlib/complex/float32/reim.h" -* #include -* -* static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t n ) { -* float re; -* float im; -* -* stdlib_complex64_reim( x, &re, &im ); -* return stdlib_complex64( re*n, im*n ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_CI_C( mul ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) \ - static napi_value stdlib_math_base_napi_ci_c_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ci_c( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ci_c_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ci_c_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ci_c_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. -* -* @param fcn binary function -* -* @example -* #include "stdlib/complex/float64/ctor.h" -* #include "stdlib/complex/float64/reim.h" -* -* static stdlib_complex128_t mul( const stdlib_complex128_t x, const double n ) { -* double re; -* double im; -* -* stdlib_complex128_reim( x, &re, &im ); -* return stdlib_complex128( re*n, im*n ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) \ - static napi_value stdlib_math_base_napi_zd_z_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_zd_z( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_zd_z_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_zd_z_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zd_z_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. -* -* @param fcn binary function -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* #include "stdlib/complex/float32/reim.h" -* -* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) { -* float re; -* float im; -* -* stdlib_complex64_reim( x, &re, &im ); -* return stdlib_complex64( re*n, im*n ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \ - static napi_value stdlib_math_base_napi_cf_c_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_cf_c( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_cf_c_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_cf_c_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cf_c_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. -* -* @param fcn binary function -* -* @example -* #include -* -* static double fcn( const int_64 x, const int_64 y ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ) \ - static napi_value stdlib_math_base_napi_ll_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ll_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ll_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ll_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ll_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. -* -* @param fcn binary function -* -* @example -* #include -* -* static float fcn( const int_32 x, const int_32 y ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ) \ - static napi_value stdlib_math_base_napi_ii_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ii_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ii_f_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ii_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_f_init ) - -/* -* 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 - -/** -* Invokes a binary function accepting and returning double-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) ); - -/** -* Invokes a binary function accepting and returning single-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) ); - -/** -* Invokes a binary function accepting and returning double-precision complex floating-point numbers. -*/ -napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) ); - -/** -* Invokes a binary function accepting and returning single-precision complex floating-point numbers. -*/ -napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) ); - -/** -* Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ); - -/** -* Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ); - -/** -* Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) ); - -/** -* Invokes a binary function accepting and returning signed 32-bit integers. -*/ -napi_value stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) ); - -/** -* Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) ); - -/** -* Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number. -*/ -napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ); - -/** -* Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. -*/ -napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ); - -/** -* Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. -*/ -napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ); - -/** -* Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. -*/ -napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) ); - -/** -* Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ); - -/** -* Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ); - -#ifdef __cplusplus -} -#endif +// NOTE: please keep in alphabetical order... +#include "stdlib/math/base/napi/binary/cc_c.h" +#include "stdlib/math/base/napi/binary/cf_c.h" +#include "stdlib/math/base/napi/binary/ci_c.h" +#include "stdlib/math/base/napi/binary/dd_d.h" +#include "stdlib/math/base/napi/binary/di_d.h" +#include "stdlib/math/base/napi/binary/dz_z.h" +#include "stdlib/math/base/napi/binary/fc_c.h" +#include "stdlib/math/base/napi/binary/ff_f.h" +#include "stdlib/math/base/napi/binary/fi_f.h" +#include "stdlib/math/base/napi/binary/id_d.h" +#include "stdlib/math/base/napi/binary/ii_d.h" +#include "stdlib/math/base/napi/binary/ii_f.h" +#include "stdlib/math/base/napi/binary/ii_i.h" +#include "stdlib/math/base/napi/binary/ll_d.h" +#include "stdlib/math/base/napi/binary/zd_z.h" +#include "stdlib/math/base/napi/binary/zi_z.h" +#include "stdlib/math/base/napi/binary/zz_z.h" #endif // !STDLIB_MATH_BASE_NAPI_BINARY_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cc_c.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cc_c.h new file mode 100644 index 000000000000..828feaf2e323 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cc_c.h @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H +#define STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning single-precision complex floating-point numbers. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/reim.h" +* +* static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) { +* float xre; +* float xim; +* float yre; +* float yim; +* float re; +* float im; +* +* stdlib_complex64_reim( x, &xre, &xim ); +* stdlib_complex64_reim( y, &yre, &yim ); +* +* re = xre + yre; +* im = xim + yim; +* +* return stdlib_complex64( re, im ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) \ + static napi_value stdlib_math_base_napi_cc_c_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_cc_c( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_cc_c_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_cc_c_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cc_c_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting and returning single-precision complex floating-point numbers. +*/ +napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cf_c.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cf_c.h new file mode 100644 index 000000000000..ae2df2a83964 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/cf_c.h @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H +#define STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/reim.h" +* +* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) { +* float re; +* float im; +* +* stdlib_complex64_reim( x, &re, &im ); +* return stdlib_complex64( re*n, im*n ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \ + static napi_value stdlib_math_base_napi_cf_c_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_cf_c( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_cf_c_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_cf_c_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cf_c_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. +*/ +napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ci_c.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ci_c.h new file mode 100644 index 000000000000..23b14438ad69 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ci_c.h @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H +#define STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/reim.h" +* #include +* +* static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t n ) { +* float re; +* float im; +* +* stdlib_complex64_reim( x, &re, &im ); +* return stdlib_complex64( re*n, im*n ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_CI_C( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) \ + static napi_value stdlib_math_base_napi_ci_c_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ci_c( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ci_c_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ci_c_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ci_c_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. +*/ +napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dd_d.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dd_d.h new file mode 100644 index 000000000000..619d9c7142d1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dd_d.h @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H +#define STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision floating-point numbers. +* +* @param fcn binary function +* +* @example +* static double add( const double x, const double y ) { +* return x + y; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) \ + static napi_value stdlib_math_base_napi_dd_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_dd_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_dd_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_dd_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dd_d_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting and returning double-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/di_d.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/di_d.h new file mode 100644 index 000000000000..ac5ecf7527df --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/di_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_DI_D_H +#define STDLIB_MATH_BASE_NAPI_BINARY_DI_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static double mul( const double x, const int32_t n ) { +* return x * n; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn ) \ + static napi_value stdlib_math_base_napi_di_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_di_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_di_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_di_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_di_d_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DI_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dz_z.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dz_z.h new file mode 100644 index 000000000000..9954e30c3a2f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/dz_z.h @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_DZ_Z_H +#define STDLIB_MATH_BASE_NAPI_BINARY_DZ_Z_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a double-precision complex floating-point number and returning a double-precision complex floating-point number. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/reim.h" +* +* static stdlib_complex128_t mul( const double n, const stdlib_complex128_t x ) { +* double re; +* double im; +* +* stdlib_complex128_reim( x, &re, &im ); +* return stdlib_complex128( re*n, im*n ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( fcn ) \ + static napi_value stdlib_math_base_napi_dz_z_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_dz_z( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_dz_z_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_dz_z_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dz_z_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a double-precision floating-point number and a double-precision complex floating-point number and returning a double-precision complex floating-point number. +*/ +napi_value stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DZ_Z_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fc_c.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fc_c.h new file mode 100644 index 000000000000..6b5cda310cb7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fc_c.h @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_FC_C_H +#define STDLIB_MATH_BASE_NAPI_BINARY_FC_C_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a single-precision complex floating-point number and returning a single-precision complex floating-point number. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/reim.h" +* +* static stdlib_complex64_t mul( const float n, const stdlib_complex64_t x ) { +* float re; +* float im; +* +* stdlib_complex64_reim( x, &re, &im ); +* return stdlib_complex64( re*n, im*n ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FC_C( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FC_C( fcn ) \ + static napi_value stdlib_math_base_napi_fc_c_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_fc_c( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_fc_c_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_fc_c_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fc_c_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a single-precision floating-point number and a single-precision complex floating-point number and returning a single-precision complex floating-point number. +*/ +napi_value stdlib_math_base_napi_fc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( float, stdlib_complex64_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_FC_C_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ff_f.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ff_f.h new file mode 100644 index 000000000000..8131f86ba3a0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ff_f.h @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_FF_F_H +#define STDLIB_MATH_BASE_NAPI_BINARY_FF_F_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning single-precision floating-point numbers. +* +* @param fcn binary function +* +* @example +* static float addf( const float x, const float y ) { +* return x + y; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FF_F( addf ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn ) \ + static napi_value stdlib_math_base_napi_ff_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ff_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ff_f_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ff_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ff_f_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting and returning single-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_FF_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fi_f.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fi_f.h new file mode 100644 index 000000000000..dbaa10a0f453 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/fi_f.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_FI_F_H +#define STDLIB_MATH_BASE_NAPI_BINARY_FI_F_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static float mulf( const float x, const int32_t n ) { +* return x * n; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn ) \ + static napi_value stdlib_math_base_napi_fi_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_fi_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_fi_f_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_fi_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fi_f_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_FI_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/id_d.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/id_d.h new file mode 100644 index 000000000000..883522bb3cc0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/id_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_ID_D_H +#define STDLIB_MATH_BASE_NAPI_BINARY_ID_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static double mul( const int32_t n, const double x ) { +* return x * n; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn ) \ + static napi_value stdlib_math_base_napi_id_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_id_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_id_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_id_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_id_d_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ID_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_d.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_d.h new file mode 100644 index 000000000000..c5b61b6fa95c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_II_D_H +#define STDLIB_MATH_BASE_NAPI_BINARY_II_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static double add( const int_32 x, const int_32 y ) { +* return x + y; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_II_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_II_D( fcn ) \ + static napi_value stdlib_math_base_napi_ii_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ii_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ii_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ii_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_d_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_II_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_f.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_f.h new file mode 100644 index 000000000000..7798ba8360e2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_f.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_II_F_H +#define STDLIB_MATH_BASE_NAPI_BINARY_II_F_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static float fcn( const int_32 x, const int_32 y ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn ) \ + static napi_value stdlib_math_base_napi_ii_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ii_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ii_f_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ii_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_f_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_II_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_i.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_i.h new file mode 100644 index 000000000000..3d5e6197a249 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ii_i.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_II_I_H +#define STDLIB_MATH_BASE_NAPI_BINARY_II_I_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning signed 32-bit integers. +* +* @param fcn binary function +* +* @example +* #include +* +* static int_32 add( const int_32 x, const int_32 y ) { +* return x + y; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_II_I( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_II_I( fcn ) \ + static napi_value stdlib_math_base_napi_ii_i_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ii_i( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ii_i_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ii_i_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ii_i_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting and returning signed 32-bit integers. +*/ +napi_value stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_II_I_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ll_d.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ll_d.h new file mode 100644 index 000000000000..5e45d036fab8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/ll_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_LL_D_H +#define STDLIB_MATH_BASE_NAPI_BINARY_LL_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. +* +* @param fcn binary function +* +* @example +* #include +* +* static double fcn( const int_64 x, const int_64 y ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ) \ + static napi_value stdlib_math_base_napi_ll_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ll_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ll_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ll_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ll_d_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_LL_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zd_z.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zd_z.h new file mode 100644 index 000000000000..316c16d28da7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zd_z.h @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_ZD_Z_H +#define STDLIB_MATH_BASE_NAPI_BINARY_ZD_Z_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/reim.h" +* +* static stdlib_complex128_t mul( const stdlib_complex128_t x, const double n ) { +* double re; +* double im; +* +* stdlib_complex128_reim( x, &re, &im ); +* return stdlib_complex128( re*n, im*n ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) \ + static napi_value stdlib_math_base_napi_zd_z_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_zd_z( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_zd_z_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_zd_z_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zd_z_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. +*/ +napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ZD_Z_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zi_z.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zi_z.h new file mode 100644 index 000000000000..1df831d4eddb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zi_z.h @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_ZI_Z_H +#define STDLIB_MATH_BASE_NAPI_BINARY_ZI_Z_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/reim.h" +* #include +* +* static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t n ) { +* double re; +* double im; +* +* stdlib_complex128_reim( x, &re, &im ); +* return stdlib_complex128( re*n, im*n ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn ) \ + static napi_value stdlib_math_base_napi_zi_z_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_zi_z( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_zi_z_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_zi_z_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zi_z_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number. +*/ +napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ZI_Z_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zz_z.h b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zz_z.h new file mode 100644 index 000000000000..d9dc08f9033a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary/zz_z.h @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_BINARY_ZZ_Z_H +#define STDLIB_MATH_BASE_NAPI_BINARY_ZZ_Z_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision complex floating-point numbers. +* +* @param fcn binary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/reim.h" +* +* static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) { +* double xre; +* double xim; +* double yre; +* double yim; +* double re; +* double im; +* +* stdlib_complex128_reim( x, &xre, &xim ); +* stdlib_complex128_reim( y, &yre, &yim ); +* +* re = xre + yre; +* im = xim + yim; +* +* return stdlib_complex128( re, im ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn ) \ + static napi_value stdlib_math_base_napi_zz_z_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_zz_z( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_zz_z_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_zz_z_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zz_z_init ) + +/* +* 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 + +/** +* Invokes a binary function accepting and returning double-precision complex floating-point numbers. +*/ +napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ZZ_Z_H diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/manifest.json b/lib/node_modules/@stdlib/math/base/napi/binary/manifest.json index a5633139306e..31ec5f789935 100644 --- a/lib/node_modules/@stdlib/math/base/napi/binary/manifest.json +++ b/lib/node_modules/@stdlib/math/base/napi/binary/manifest.json @@ -25,7 +25,22 @@ "confs": [ { "src": [ - "./src/main.c" + "./src/cc_c.c", + "./src/cf_c.c", + "./src/ci_c.c", + "./src/dd_d.c", + "./src/di_d.c", + "./src/dz_z.c", + "./src/fc_c.c", + "./src/ff_f.c", + "./src/fi_f.c", + "./src/id_d.c", + "./src/ii_d.c", + "./src/ii_f.c", + "./src/ll_d.c", + "./src/zd_z.c", + "./src/zi_z.c", + "./src/zz_z.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/cc_c.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/cc_c.c new file mode 100644 index 000000000000..1111e6a90360 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/cc_c.c @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/cc_c.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include + +/** +* Invokes a binary function accepting and returning single-precision complex floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two complex numbers." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yre; + status = napi_get_named_property( env, argv[ 1 ], "re", &yre ); + assert( status == napi_ok ); + + napi_valuetype yretype; + status = napi_typeof( env, yre, &yretype ); + assert( status == napi_ok ); + if ( yretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yim; + status = napi_get_named_property( env, argv[ 1 ], "im", &yim ); + assert( status == napi_ok ); + + napi_valuetype yimtype; + status = napi_typeof( env, yim, &yimtype ); + assert( status == napi_ok ); + if ( yimtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + double re1; + status = napi_get_value_double( env, yre, &re1 ); + assert( status == napi_ok ); + + double im1; + status = napi_get_value_double( env, yim, &im1 ); + assert( status == napi_ok ); + + stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), stdlib_complex64( (float)re1, (float)im1 ) ); + float re; + float im; + stdlib_complex64_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, (double)re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, (double)im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/cf_c.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/cf_c.c new file mode 100644 index 000000000000..2c598cedef3f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/cf_c.c @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/cf_c.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include +#include + +/** +* Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), (float)y ); + float re; + float im; + stdlib_complex64_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, (double)re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, (double)im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/ci_c.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/ci_c.c new file mode 100644 index 000000000000..65ffcbdb457a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/ci_c.c @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/ci_c.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include +#include + +/** +* Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), y ); + float re; + float im; + stdlib_complex64_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, (double)re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, (double)im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/dd_d.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/dd_d.c new file mode 100644 index 000000000000..9ed6be6cddb6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/dd_d.c @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/dd_d.h" +#include +#include + +/** +* Invokes a binary function accepting and returning double-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/di_d.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/di_d.c new file mode 100644 index 000000000000..016b5cbff308 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/di_d.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/di_d.h" +#include +#include +#include + +/** +* Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/dz_z.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/dz_z.c new file mode 100644 index 000000000000..4faa3efe64bb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/dz_z.c @@ -0,0 +1,142 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/dz_z.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include + +/** +* Invokes a binary function accepting a double-precision floating-point number and a double-precision complex floating-point number and returning a double-precision complex floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 1 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 1 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double y; + status = napi_get_value_double( env, argv[ 0 ], &y ); + assert( status == napi_ok ); + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + stdlib_complex128_t v = fcn( y, stdlib_complex128( re0, im0 ) ); + double re; + double im; + stdlib_complex128_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/fc_c.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/fc_c.c new file mode 100644 index 000000000000..124b4b890b1d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/fc_c.c @@ -0,0 +1,142 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/fc_c.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include + +/** +* Invokes a binary function accepting a single-precision floating-point number and a single-precision complex floating-point number and returning a single-precision complex floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_fc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( float, stdlib_complex64_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 1 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 1 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double y; + status = napi_get_value_double( env, argv[ 0 ], &y ); + assert( status == napi_ok ); + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + stdlib_complex64_t v = fcn( y, stdlib_complex64( (float)re0, (float)im0 ) ); + float re; + float im; + stdlib_complex64_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, (double)re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, (double)im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/ff_f.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/ff_f.c new file mode 100644 index 000000000000..8eee149aabe0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/ff_f.c @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/ff_f.h" +#include +#include + +/** +* Invokes a binary function accepting and returning single-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( (float)x, (float)y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/fi_f.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/fi_f.c new file mode 100644 index 000000000000..df679105490b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/fi_f.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/fi_f.h" +#include +#include +#include + +/** +* Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( (float)x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/id_d.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/id_d.c new file mode 100644 index 000000000000..9bc613f68245 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/id_d.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/id_d.h" +#include +#include +#include + +/** +* Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_d.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_d.c new file mode 100644 index 000000000000..d5184a1fbd81 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_d.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/ii_d.h" +#include +#include +#include + +/** +* Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_f.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_f.c new file mode 100644 index 000000000000..b0f9e30ec224 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_f.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/ii_f.h" +#include +#include +#include + +/** +* Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API single-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_i.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_i.c new file mode 100644 index 000000000000..60618ca39c5a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/ii_i.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/ii_i.h" +#include +#include +#include + +/** +* Invokes a binary function accepting and returning signed 32-bit integers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API signed 32-bit integer +*/ +napi_value stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_int32( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/ll_d.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/ll_d.c new file mode 100644 index 000000000000..8859f41432e0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/ll_d.c @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/ll_d.h" +#include +#include +#include + +/** +* Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int64_t x; + status = napi_get_value_int64( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int64_t y; + status = napi_get_value_int64( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c deleted file mode 100644 index b6de9eb38b48..000000000000 --- a/lib/node_modules/@stdlib/math/base/napi/binary/src/main.c +++ /dev/null @@ -1,1373 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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/napi/binary.h" -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float64/reim.h" -#include "stdlib/complex/float32/reim.h" -#include -#include -#include -#include - -/** -* Invokes a binary function accepting and returning double-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting and returning single-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( (float)x, (float)y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting and returning double-precision complex floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two complex numbers." ); - assert( status == napi_ok ); - return NULL; - } - - bool hprop; - status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xre; - status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); - assert( status == napi_ok ); - - napi_valuetype xretype; - status = napi_typeof( env, xre, &xretype ); - assert( status == napi_ok ); - if ( xretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xim; - status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); - assert( status == napi_ok ); - - napi_valuetype ximtype; - status = napi_typeof( env, xim, &ximtype ); - assert( status == napi_ok ); - if ( ximtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value yre; - status = napi_get_named_property( env, argv[ 1 ], "re", &yre ); - assert( status == napi_ok ); - - napi_valuetype yretype; - status = napi_typeof( env, yre, &yretype ); - assert( status == napi_ok ); - if ( yretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value yim; - status = napi_get_named_property( env, argv[ 1 ], "im", &yim ); - assert( status == napi_ok ); - - napi_valuetype yimtype; - status = napi_typeof( env, yim, &yimtype ); - assert( status == napi_ok ); - if ( yimtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re0; - status = napi_get_value_double( env, xre, &re0 ); - assert( status == napi_ok ); - - double im0; - status = napi_get_value_double( env, xim, &im0 ); - assert( status == napi_ok ); - - double re1; - status = napi_get_value_double( env, yre, &re1 ); - assert( status == napi_ok ); - - double im1; - status = napi_get_value_double( env, yim, &im1 ); - assert( status == napi_ok ); - - stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), stdlib_complex128( re1, im1 ) ); - double re; - double im; - stdlib_complex128_reim( v, &re, &im ); - - napi_value obj; - status = napi_create_object( env, &obj ); - assert( status == napi_ok ); - - napi_value vre; - status = napi_create_double( env, re, &vre ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "re", vre ); - assert( status == napi_ok ); - - napi_value vim; - status = napi_create_double( env, im, &vim ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "im", vim ); - assert( status == napi_ok ); - - return obj; -} - -/** -* Invokes a binary function accepting and returning single-precision complex floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two complex numbers." ); - assert( status == napi_ok ); - return NULL; - } - - bool hprop; - status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xre; - status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); - assert( status == napi_ok ); - - napi_valuetype xretype; - status = napi_typeof( env, xre, &xretype ); - assert( status == napi_ok ); - if ( xretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xim; - status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); - assert( status == napi_ok ); - - napi_valuetype ximtype; - status = napi_typeof( env, xim, &ximtype ); - assert( status == napi_ok ); - if ( ximtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value yre; - status = napi_get_named_property( env, argv[ 1 ], "re", &yre ); - assert( status == napi_ok ); - - napi_valuetype yretype; - status = napi_typeof( env, yre, &yretype ); - assert( status == napi_ok ); - if ( yretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value yim; - status = napi_get_named_property( env, argv[ 1 ], "im", &yim ); - assert( status == napi_ok ); - - napi_valuetype yimtype; - status = napi_typeof( env, yim, &yimtype ); - assert( status == napi_ok ); - if ( yimtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re0; - status = napi_get_value_double( env, xre, &re0 ); - assert( status == napi_ok ); - - double im0; - status = napi_get_value_double( env, xim, &im0 ); - assert( status == napi_ok ); - - double re1; - status = napi_get_value_double( env, yre, &re1 ); - assert( status == napi_ok ); - - double im1; - status = napi_get_value_double( env, yim, &im1 ); - assert( status == napi_ok ); - - stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), stdlib_complex64( (float)re1, (float)im1 ) ); - float re; - float im; - stdlib_complex64_reim( v, &re, &im ); - - napi_value obj; - status = napi_create_object( env, &obj ); - assert( status == napi_ok ); - - napi_value vre; - status = napi_create_double( env, (double)re, &vre ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "re", vre ); - assert( status == napi_ok ); - - napi_value vim; - status = napi_create_double( env, (double)im, &vim ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "im", vim ); - assert( status == napi_ok ); - - return obj; -} - -/** -* Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting and returning signed 32-bit integers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API signed 32-bit integer -*/ -napi_value stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_int32( env, fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( (float)x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); - assert( status == napi_ok ); - return NULL; - } - - bool hprop; - status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xre; - status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); - assert( status == napi_ok ); - - napi_valuetype xretype; - status = napi_typeof( env, xre, &xretype ); - assert( status == napi_ok ); - if ( xretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xim; - status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); - assert( status == napi_ok ); - - napi_valuetype ximtype; - status = napi_typeof( env, xim, &ximtype ); - assert( status == napi_ok ); - if ( ximtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re0; - status = napi_get_value_double( env, xre, &re0 ); - assert( status == napi_ok ); - - double im0; - status = napi_get_value_double( env, xim, &im0 ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), y ); - double re; - double im; - stdlib_complex128_reim( v, &re, &im ); - - napi_value obj; - status = napi_create_object( env, &obj ); - assert( status == napi_ok ); - - napi_value vre; - status = napi_create_double( env, re, &vre ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "re", vre ); - assert( status == napi_ok ); - - napi_value vim; - status = napi_create_double( env, im, &vim ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "im", vim ); - assert( status == napi_ok ); - - return obj; -} - -/** -* Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); - assert( status == napi_ok ); - return NULL; - } - - bool hprop; - status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xre; - status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); - assert( status == napi_ok ); - - napi_valuetype xretype; - status = napi_typeof( env, xre, &xretype ); - assert( status == napi_ok ); - if ( xretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xim; - status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); - assert( status == napi_ok ); - - napi_valuetype ximtype; - status = napi_typeof( env, xim, &ximtype ); - assert( status == napi_ok ); - if ( ximtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re0; - status = napi_get_value_double( env, xre, &re0 ); - assert( status == napi_ok ); - - double im0; - status = napi_get_value_double( env, xim, &im0 ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), y ); - float re; - float im; - stdlib_complex64_reim( v, &re, &im ); - - napi_value obj; - status = napi_create_object( env, &obj ); - assert( status == napi_ok ); - - napi_value vre; - status = napi_create_double( env, (double)re, &vre ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "re", vre ); - assert( status == napi_ok ); - - napi_value vim; - status = napi_create_double( env, (double)im, &vim ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "im", vim ); - assert( status == napi_ok ); - - return obj; -} - -/** -* Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); - assert( status == napi_ok ); - return NULL; - } - - bool hprop; - status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xre; - status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); - assert( status == napi_ok ); - - napi_valuetype xretype; - status = napi_typeof( env, xre, &xretype ); - assert( status == napi_ok ); - if ( xretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xim; - status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); - assert( status == napi_ok ); - - napi_valuetype ximtype; - status = napi_typeof( env, xim, &ximtype ); - assert( status == napi_ok ); - if ( ximtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re0; - status = napi_get_value_double( env, xre, &re0 ); - assert( status == napi_ok ); - - double im0; - status = napi_get_value_double( env, xim, &im0 ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), y ); - double re; - double im; - stdlib_complex128_reim( v, &re, &im ); - - napi_value obj; - status = napi_create_object( env, &obj ); - assert( status == napi_ok ); - - napi_value vre; - status = napi_create_double( env, re, &vre ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "re", vre ); - assert( status == napi_ok ); - - napi_value vim; - status = napi_create_double( env, im, &vim ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "im", vim ); - assert( status == napi_ok ); - - return obj; -} - -/** -* Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); - assert( status == napi_ok ); - return NULL; - } - - bool hprop; - status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xre; - status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); - assert( status == napi_ok ); - - napi_valuetype xretype; - status = napi_typeof( env, xre, &xretype ); - assert( status == napi_ok ); - if ( xretype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); - assert( status == napi_ok ); - return NULL; - } - - status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); - assert( status == napi_ok ); - if ( !hprop ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); - assert( status == napi_ok ); - return NULL; - } - - napi_value xim; - status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); - assert( status == napi_ok ); - - napi_valuetype ximtype; - status = napi_typeof( env, xim, &ximtype ); - assert( status == napi_ok ); - if ( ximtype != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re0; - status = napi_get_value_double( env, xre, &re0 ); - assert( status == napi_ok ); - - double im0; - status = napi_get_value_double( env, xim, &im0 ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), (float)y ); - float re; - float im; - stdlib_complex64_reim( v, &re, &im ); - - napi_value obj; - status = napi_create_object( env, &obj ); - assert( status == napi_ok ); - - napi_value vre; - status = napi_create_double( env, (double)re, &vre ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "re", vre ); - assert( status == napi_ok ); - - napi_value vim; - status = napi_create_double( env, (double)im, &vim ); - assert( status == napi_ok ); - - status = napi_set_named_property( env, obj, "im", vim ); - assert( status == napi_ok ); - - return obj; -} - -/** -* Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - int64_t x; - status = napi_get_value_int64( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int64_t y; - status = napi_get_value_int64( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn binary function -* @return function return value as a Node-API single-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) ) { - napi_status status; - - size_t argc = 2; - napi_value argv[ 2 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 2 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide two numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( x, y ), &v ); - assert( status == napi_ok ); - - return v; -} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/zd_z.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/zd_z.c new file mode 100644 index 000000000000..c344aff7fa4e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/zd_z.c @@ -0,0 +1,142 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/zd_z.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include + +/** +* Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), y ); + double re; + double im; + stdlib_complex128_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/zi_z.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/zi_z.c new file mode 100644 index 000000000000..f982a5f1e351 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/zi_z.c @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/zi_z.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include +#include + +/** +* Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), y ); + double re; + double im; + stdlib_complex128_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/binary/src/zz_z.c b/lib/node_modules/@stdlib/math/base/napi/binary/src/zz_z.c new file mode 100644 index 000000000000..d36830e8ceee --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/binary/src/zz_z.c @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/binary/zz_z.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include + +/** +* Invokes a binary function accepting and returning double-precision complex floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn binary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) ) { + napi_status status; + + size_t argc = 2; + napi_value argv[ 2 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 2 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide two complex numbers." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yre; + status = napi_get_named_property( env, argv[ 1 ], "re", &yre ); + assert( status == napi_ok ); + + napi_valuetype yretype; + status = napi_typeof( env, yre, &yretype ); + assert( status == napi_ok ); + if ( yretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yim; + status = napi_get_named_property( env, argv[ 1 ], "im", &yim ); + assert( status == napi_ok ); + + napi_valuetype yimtype; + status = napi_typeof( env, yim, &yimtype ); + assert( status == napi_ok ); + if ( yimtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + double re1; + status = napi_get_value_double( env, yre, &re1 ); + assert( status == napi_ok ); + + double im1; + status = napi_get_value_double( env, yim, &im1 ); + assert( status == napi_ok ); + + stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), stdlib_complex128( re1, im1 ) ); + double re; + double im; + stdlib_complex128_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/README.md b/lib/node_modules/@stdlib/math/base/napi/ternary/README.md index 4dca5fb065f2..cd51ef459186 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/README.md @@ -104,17 +104,77 @@ console.log( headerDir ); #include "stdlib/math/base/napi/ternary.h" ``` -#### stdlib_math_base_napi_ddd_d( env, info, fcn ) + -Invokes a ternary function accepting and returning double-precision floating-point numbers. +#### STDLIB_MATH_BASE_NAPI_MODULE_CCC_C( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision complex floating-point numbers. ```c +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" + +static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y, const stdlib_complex64_t z ) { + float xre; + float xim; + float yre; + float yim; + float zre; + float zim; + float re; + float im; + + stdlib_complex64_reim( x, &xre, &xim ); + stdlib_complex64_reim( y, &yre, &yim ); + stdlib_complex64_reim( z, &zre, &zim ); + + re = xre + yre + zre; + im = xim + yim + zim; + + return stdlib_complex64( re, im ); +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_CCC_C( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t )` ternary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_ccc_c( env, info, fcn ) + +Invokes a ternary function accepting and returning single-precision complex floating-point numbers. + +```c +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include // ... -static double add( const double x, const double y, const double z ) { - return x + y + z; +static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y, const stdlib_complex64_t z ) { + float xre; + float xim; + float yre; + float yim; + float zre; + float zim; + float re; + float im; + + stdlib_complex64_reim( x, &xre, &xim ); + stdlib_complex64_reim( y, &yre, &yim ); + stdlib_complex64_reim( z, &zre, &zim ); + + re = xre + yre + zre; + im = xim + yim + zim; + + return stdlib_complex64( re, im ); } // ... @@ -127,7 +187,7 @@ static double add( const double x, const double y, const double z ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ddd_d( env, info, add ); + return stdlib_math_base_napi_ccc_c( env, info, add ); } // ... @@ -137,22 +197,43 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] double (*fcn)( double, double, double )` ternary function. +- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t )` ternary function. ```c -void stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) ); +void stdlib_math_base_napi_ccc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t ) ); ``` -#### stdlib_math_base_napi_fff_f( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn ) -Invokes a ternary function accepting and returning single-precision floating-point numbers. +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision floating-point numbers. + +```c +static double add( const double x, const double y, const double z ) { + return x + y + z; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, double, double )` ternary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_ddd_d( env, info, fcn ) + +Invokes a ternary function accepting and returning double-precision floating-point numbers. ```c #include // ... -static float addf( const float x, const float y, const float z ) { +static double add( const double x, const double y, const double z ) { return x + y + z; } @@ -166,7 +247,7 @@ static float addf( const float x, const float y, const float z ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_fff_f( env, info, addf ); + return stdlib_math_base_napi_ddd_d( env, info, add ); } // ... @@ -176,12 +257,35 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] float (*fcn)( float, float, float )` ternary function. +- **fcn**: `[in] double (*fcn)( double, double, double )` ternary function. ```c -void stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) ); +void stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) ); +``` + +#### STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. + +```c +#include + +static double fcn( const double x, const int32_t y, const int32_t z ) { + // ... +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ); ``` +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, int32_t, int32_t )` ternary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + #### stdlib_math_base_napi_dii_d( env, info, fcn ) Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. @@ -222,71 +326,289 @@ The function accepts the following arguments: void stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) ); ``` -#### STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn ) -Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision floating-point numbers. +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision floating-point numbers. ```c -static double add( const double x, const double y, const double z ) { +static float addf( const float x, const float y, const float z ) { return x + y + z; } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add ); +STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( double, double, double )` ternary function. +- **fcn**: `float (*fcn)( float, float, float )` ternary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn ) +#### stdlib_math_base_napi_fff_f( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision floating-point numbers. +Invokes a ternary function accepting and returning single-precision floating-point numbers. ```c +#include + +// ... + static float addf( const float x, const float y, const float z ) { return x + y + z; } // ... +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_fff_f( env, info, addf ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] float (*fcn)( float, float, float )` ternary function. + +```c +void stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) ); +``` + +#### STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number. + +```c +#include + +static double fcn( const int32_t x, const int32_t y, const double z ) { + // ... +} + +// ... + // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf ); +STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn ); ``` The macro expects the following arguments: -- **fcn**: `float (*fcn)( float, float, float )` ternary function. +- **fcn**: `double (*fcn)( int32_t, int32_t, double )` ternary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. -#### STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ) +#### stdlib_math_base_napi_iid_d( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. +Invokes a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number. ```c +#include #include -static double fcn( const double x, const int32_t y, const int32_t z ) { +// ... + +static double fcn( const int32_t x, const int32_t y, const double z ) { + // ... +} + +// ... + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_iid_d( env, info, fcn ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( int32_t, int32_t, double )` ternary function. + +```c +void stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) ); +``` + +#### STDLIB_MATH_BASE_NAPI_MODULE_III_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number. + +```c +#include + +static double fcn( const int32_t x, const int32_t y, const int32_t z ) { // ... } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ); +STDLIB_MATH_BASE_NAPI_MODULE_III_D( fcn ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( double, int32_t, int32_t )` ternary function. +- **fcn**: `double (*fcn)( int32_t, int32_t, int32_t )` ternary function. When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +#### stdlib_math_base_napi_iii_d( env, info, fcn ) + +Invokes a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number. + +```c +#include +#include + +// ... + +static double fcn( const int32_t x, const int32_t y, const int32_t z ) { + // ... +} + +// ... + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_iii_d( env, info, fcn ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( int32_t, int32_t, int32_t )` ternary function. + +```c +void stdlib_math_base_napi_iii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, int32_t ) ); +``` + +#### STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision complex floating-point numbers. + +```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" + +static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) { + double xre; + double xim; + double yre; + double yim; + double zre; + double zim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); + stdlib_complex128_reim( y, &yre, &yim ); + stdlib_complex128_reim( z, &zre, &zim ); + + re = xre + yre + zre; + im = xim + yim + zim; + + return stdlib_complex128( re, im ); +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t )` ternary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + +#### stdlib_math_base_napi_zzz_z( env, info, fcn ) + +Invokes a ternary function accepting and returning double-precision complex floating-point numbers. + +```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include + +// ... + +static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) { + double xre; + double xim; + double yre; + double yim; + double zre; + double zim; + double re; + double im; + + stdlib_complex128_reim( x, &xre, &xim ); + stdlib_complex128_reim( y, &yre, &yim ); + stdlib_complex128_reim( z, &zre, &zim ); + + re = xre + yre + zre; + im = xim + yim + zim; + + return stdlib_complex128( re, im ); +} + +// ... + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +napi_value addon( napi_env env, napi_callback_info info ) { + return stdlib_math_base_napi_zzz_z( env, info, add ); +} + +// ... +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t )` ternary function. + +```c +void stdlib_math_base_napi_zzz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t ) ); +``` + diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary.h index 514b72add029..52a0383bcc35 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary.h +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary.h @@ -19,155 +19,13 @@ #ifndef STDLIB_MATH_BASE_NAPI_TERNARY_H #define STDLIB_MATH_BASE_NAPI_TERNARY_H -#include -#include - -/** -* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning double-precision floating-point numbers. -* -* @param fcn ternary function -* -* @example -* static double add( const double x, const double y, const double z ) { -* return x + y + z; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn ) \ - static napi_value stdlib_math_base_napi_ddd_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ddd_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ddd_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ddd_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ddd_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning single-precision floating-point numbers. -* -* @param fcn ternary function -* -* @example -* static float addf( const float x, const float y, const float z ) { -* return x + y + z; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn ) \ - static napi_value stdlib_math_base_napi_fff_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_fff_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_fff_f_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_fff_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fff_f_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. -* -* @param fcn ternary function -* -* @example -* #include -* -* static double fcn( const double x, const int_32 y, const int_32 z ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ) \ - static napi_value stdlib_math_base_napi_dii_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_dii_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_dii_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_dii_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dii_d_init ) - -/* -* If C++, prevent name mangling so that the compiler emits a ternary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Invokes a ternary function accepting and returning double-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) ); - -/** -* Invokes a ternary function accepting and returning single-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) ); - -/** -* Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) ); - -#ifdef __cplusplus -} -#endif +// NOTE: keep in alphabetical order... +#include "stdlib/math/base/napi/ternary/ccc_c.h" +#include "stdlib/math/base/napi/ternary/ddd_d.h" +#include "stdlib/math/base/napi/ternary/dii_d.h" +#include "stdlib/math/base/napi/ternary/fff_f.h" +#include "stdlib/math/base/napi/ternary/iid_d.h" +#include "stdlib/math/base/napi/ternary/iii_d.h" +#include "stdlib/math/base/napi/ternary/zzz_z.h" #endif // !STDLIB_MATH_BASE_NAPI_TERNARY_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ccc_c.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ccc_c.h new file mode 100644 index 000000000000..d68013a7d116 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ccc_c.h @@ -0,0 +1,101 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_CCC_C_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_CCC_C_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning single-precision complex floating-point numbers. +* +* @param fcn ternary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/reim.h" +* +* static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y, const stdlib_complex64_t z ) { +* float xre; +* float xim; +* float yre; +* float yim; +* float zre; +* float zim; +* float re; +* float im; +* +* stdlib_complex64_reim( x, &xre, &xim ); +* stdlib_complex64_reim( y, &yre, &yim ); +* stdlib_complex64_reim( z, &zre, &zim ); +* +* re = xre + yre + zre; +* im = xim + yim + zim; +* +* return stdlib_complex64( re, im ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_CCC_C( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_CCC_C( fcn ) \ + static napi_value stdlib_math_base_napi_ccc_c_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ccc_c( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ccc_c_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ccc_c_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ccc_c_init ) + +/* +* 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 + +/** +* Invokes a ternary function accepting and returning single-precision complex floating-point numbers. +*/ +napi_value stdlib_math_base_napi_ccc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_CCC_C_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ddd_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ddd_d.h new file mode 100644 index 000000000000..0a8b318b32d8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/ddd_d.h @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_DDD_D_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_DDD_D_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning double-precision floating-point numbers. +* +* @param fcn ternary function +* +* @example +* static double add( const double x, const double y, const double z ) { +* return x + y + z; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn ) \ + static napi_value stdlib_math_base_napi_ddd_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ddd_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ddd_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ddd_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ddd_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a ternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a ternary function accepting and returning double-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_DDD_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h new file mode 100644 index 000000000000..a998b146b360 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_DII_D_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_DII_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. +* +* @param fcn ternary function +* +* @example +* #include +* +* static double fcn( const double x, const int_32 y, const int_32 z ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn ) \ + static napi_value stdlib_math_base_napi_dii_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_dii_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_dii_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_dii_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dii_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a ternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_DII_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/fff_f.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/fff_f.h new file mode 100644 index 000000000000..1758e0d8632e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/fff_f.h @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_FFF_F_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_FFF_F_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning single-precision floating-point numbers. +* +* @param fcn ternary function +* +* @example +* static float addf( const float x, const float y, const float z ) { +* return x + y + z; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn ) \ + static napi_value stdlib_math_base_napi_fff_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_fff_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_fff_f_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_fff_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fff_f_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a ternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a ternary function accepting and returning single-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_FFF_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h new file mode 100644 index 000000000000..beb97f2b3b22 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_IID_D_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_IID_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number. +* +* @param fcn ternary function +* +* @example +* #include +* +* static double fcn( const int_32 x, const int_32 y, const double z ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn ) \ + static napi_value stdlib_math_base_napi_iid_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_iid_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_iid_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_iid_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_iid_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a ternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_IID_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h new file mode 100644 index 000000000000..23ef1cdd6706 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_III_D_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_III_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number. +* +* @param fcn ternary function +* +* @example +* #include +* +* static double fcn( const int_32 x, const int_32 y, const int_32 z ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_III_D( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_III_D( fcn ) \ + static napi_value stdlib_math_base_napi_iii_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_iii_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_iii_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_iii_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_iii_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a ternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_iii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_III_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/zzz_z.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/zzz_z.h new file mode 100644 index 000000000000..4e4d7099948b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/zzz_z.h @@ -0,0 +1,101 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_ZZZ_Z_H +#define STDLIB_MATH_BASE_NAPI_TERNARY_ZZZ_Z_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning double-precision complex floating-point numbers. +* +* @param fcn ternary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/reim.h" +* +* static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) { +* double xre; +* double xim; +* double yre; +* double yim; +* double zre; +* double zim; +* double re; +* double im; +* +* stdlib_complex128_reim( x, &xre, &xim ); +* stdlib_complex128_reim( y, &yre, &yim ); +* stdlib_complex128_reim( z, &zre, &zim ); +* +* re = xre + yre + zre; +* im = xim + yim + zim; +* +* return stdlib_complex128( re, im ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( fcn ) \ + static napi_value stdlib_math_base_napi_zzz_z_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_zzz_z( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_zzz_z_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_zzz_z_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zzz_z_init ) + +/* +* 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 + +/** +* Invokes a ternary function accepting and returning double-precision complex floating-point numbers. +*/ +napi_value stdlib_math_base_napi_zzz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_ZZZ_Z_H diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/manifest.json b/lib/node_modules/@stdlib/math/base/napi/ternary/manifest.json index 04e61e361caa..1d49b6d90248 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/manifest.json +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/manifest.json @@ -25,14 +25,25 @@ "confs": [ { "src": [ - "./src/main.c" + "./src/ccc_c.c", + "./src/ddd_d.c", + "./src/dii_d.c", + "./src/fff_f.c", + "./src/iid_d.c", + "./src/iii_d.c", + "./src/zzz_z.c" ], "include": [ "./include" ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/reim", + "@stdlib/complex/float32/reim" + ] } ] } diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/ccc_c.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/ccc_c.c new file mode 100644 index 000000000000..9dbf1c01fe6b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/ccc_c.c @@ -0,0 +1,230 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/napi/ternary/ccc_c.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include + +/** +* Invokes a ternary function accepting and returning single-precision complex floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_ccc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three complex numbers." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yre; + status = napi_get_named_property( env, argv[ 1 ], "re", &yre ); + assert( status == napi_ok ); + + napi_valuetype yretype; + status = napi_typeof( env, yre, &yretype ); + assert( status == napi_ok ); + if ( yretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yim; + status = napi_get_named_property( env, argv[ 1 ], "im", &yim ); + assert( status == napi_ok ); + + napi_valuetype yimtype; + status = napi_typeof( env, yim, &yimtype ); + assert( status == napi_ok ); + if ( yimtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 2 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value zre; + status = napi_get_named_property( env, argv[ 2 ], "re", &zre ); + assert( status == napi_ok ); + + napi_valuetype zretype; + status = napi_typeof( env, zre, &zretype ); + assert( status == napi_ok ); + if ( zretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 2 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value zim; + status = napi_get_named_property( env, argv[ 2 ], "im", &zim ); + assert( status == napi_ok ); + + napi_valuetype zimtype; + status = napi_typeof( env, zim, &zimtype ); + assert( status == napi_ok ); + if ( zimtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + double re1; + status = napi_get_value_double( env, yre, &re1 ); + assert( status == napi_ok ); + + double im1; + status = napi_get_value_double( env, yim, &im1 ); + assert( status == napi_ok ); + + double re2; + status = napi_get_value_double( env, zre, &re2 ); + assert( status == napi_ok ); + + double im2; + status = napi_get_value_double( env, zim, &im2 ); + assert( status == napi_ok ); + + stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ), stdlib_complex64( (float)re1, (float)im1 ), stdlib_complex64( (float)re2, (float)im2 ) ); + float re; + float im; + stdlib_complex64_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, (double)re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, (double)im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/ddd_d.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/ddd_d.c new file mode 100644 index 000000000000..885dc7b77475 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/ddd_d.c @@ -0,0 +1,97 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/ternary/ddd_d.h" +#include +#include + +/** +* Invokes a ternary function accepting and returning double-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + double z; + status = napi_get_value_double( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/dii_d.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/dii_d.c new file mode 100644 index 000000000000..34d5a639f3ee --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/dii_d.c @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/ternary/dii_d.h" +#include +#include +#include + +/** +* Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + int32_t z; + status = napi_get_value_int32( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/fff_f.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/fff_f.c new file mode 100644 index 000000000000..8b754bed575a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/fff_f.c @@ -0,0 +1,97 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/ternary/fff_f.h" +#include +#include + +/** +* Invokes a ternary function accepting and returning single-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + double z; + status = napi_get_value_double( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( (float)x, (float)y, (float)z ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/iid_d.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/iid_d.c new file mode 100644 index 000000000000..931a9b26aec5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/iid_d.c @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/ternary/iid_d.h" +#include +#include +#include + +/** +* Invokes a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 1 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 2 ], &y ); + assert( status == napi_ok ); + + double z; + status = napi_get_value_double( env, argv[ 0 ], &z ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/iii_d.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/iii_d.c new file mode 100644 index 000000000000..39f503bbd628 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/iii_d.c @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/napi/ternary/iii_d.h" +#include +#include +#include + +/** +* Invokes a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_iii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + int32_t z; + status = napi_get_value_int32( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/main.c deleted file mode 100644 index 92b89ca0999e..000000000000 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/src/main.c +++ /dev/null @@ -1,250 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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/napi/ternary.h" -#include -#include -#include - -/** -* Invokes a ternary function accepting and returning double-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* - `z`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn ternary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - double z; - status = napi_get_value_double( env, argv[ 2 ], &z ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y, z ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a ternary function accepting and returning single-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* - `z`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn ternary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - double z; - status = napi_get_value_double( env, argv[ 2 ], &z ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( (float)x, (float)y, (float)z ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* - `z`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn ternary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide three numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - int32_t y; - status = napi_get_value_int32( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - int32_t z; - status = napi_get_value_int32( env, argv[ 2 ], &z ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y, z ), &v ); - assert( status == napi_ok ); - - return v; -} diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/src/zzz_z.c b/lib/node_modules/@stdlib/math/base/napi/ternary/src/zzz_z.c new file mode 100644 index 000000000000..200b12f88758 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/src/zzz_z.c @@ -0,0 +1,230 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/napi/ternary/zzz_z.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include + +/** +* Invokes a ternary function accepting and returning double-precision complex floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn ternary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_zzz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t ) ) { + napi_status status; + + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide three complex numbers." ); + assert( status == napi_ok ); + return NULL; + } + + bool hprop; + status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xre; + status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); + assert( status == napi_ok ); + + napi_valuetype xretype; + status = napi_typeof( env, xre, &xretype ); + assert( status == napi_ok ); + if ( xretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value xim; + status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); + assert( status == napi_ok ); + + napi_valuetype ximtype; + status = napi_typeof( env, xim, &ximtype ); + assert( status == napi_ok ); + if ( ximtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yre; + status = napi_get_named_property( env, argv[ 1 ], "re", &yre ); + assert( status == napi_ok ); + + napi_valuetype yretype; + status = napi_typeof( env, yre, &yretype ); + assert( status == napi_ok ); + if ( yretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 1 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value yim; + status = napi_get_named_property( env, argv[ 1 ], "im", &yim ); + assert( status == napi_ok ); + + napi_valuetype yimtype; + status = napi_typeof( env, yim, &yimtype ); + assert( status == napi_ok ); + if ( yimtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 2 ], "re", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have a real component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value zre; + status = napi_get_named_property( env, argv[ 2 ], "re", &zre ); + assert( status == napi_ok ); + + napi_valuetype zretype; + status = napi_typeof( env, zre, &zretype ); + assert( status == napi_ok ); + if ( zretype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have a real component which is a number." ); + assert( status == napi_ok ); + return NULL; + } + + status = napi_has_named_property( env, argv[ 2 ], "im", &hprop ); + assert( status == napi_ok ); + if ( !hprop ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have an imaginary component." ); + assert( status == napi_ok ); + return NULL; + } + + napi_value zim; + status = napi_get_named_property( env, argv[ 2 ], "im", &zim ); + assert( status == napi_ok ); + + napi_valuetype zimtype; + status = napi_typeof( env, zim, &zimtype ); + assert( status == napi_ok ); + if ( zimtype != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re0; + status = napi_get_value_double( env, xre, &re0 ); + assert( status == napi_ok ); + + double im0; + status = napi_get_value_double( env, xim, &im0 ); + assert( status == napi_ok ); + + double re1; + status = napi_get_value_double( env, yre, &re1 ); + assert( status == napi_ok ); + + double im1; + status = napi_get_value_double( env, yim, &im1 ); + assert( status == napi_ok ); + + double re2; + status = napi_get_value_double( env, zre, &re2 ); + assert( status == napi_ok ); + + double im2; + status = napi_get_value_double( env, zim, &im2 ); + assert( status == napi_ok ); + + stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), stdlib_complex128( re1, im1 ), stdlib_complex128( re2, im2 ) ); + double re; + double im; + stdlib_complex128_reim( v, &re, &im ); + + napi_value obj; + status = napi_create_object( env, &obj ); + assert( status == napi_ok ); + + napi_value vre; + status = napi_create_double( env, re, &vre ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "re", vre ); + assert( status == napi_ok ); + + napi_value vim; + status = napi_create_double( env, im, &vim ); + assert( status == napi_ok ); + + status = napi_set_named_property( env, obj, "im", vim ); + assert( status == napi_ok ); + + return obj; +} From d7be9eb9260946a195fc08f8adfba74861c93f13 Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Mon, 17 Feb 2025 22:32:03 +0530 Subject: [PATCH 11/12] fix: changes in benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../binomial/stdev/benchmark/benchmark.js | 19 ------------------- .../stdev/benchmark/benchmark.native.js | 11 +++++------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js index 932a72171dcf..a3c58f2e4a3e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.js @@ -21,16 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -<<<<<<< HEAD -var ceil = require( '@stdlib/math/base/special/ceil' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var randu = require( '@stdlib/random/base/randu' ); -======= var Float64Array = require( '@stdlib/array/float64' ); var uniform = require( '@stdlib/random/base/uniform' ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); ->>>>>>> develop var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var stdev = require( './../lib' ); @@ -46,28 +39,16 @@ bench( pkg, function benchmark( b ) { var i; len = 100; -<<<<<<< HEAD - n = new Int32Array( len ); - p = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - n[ i ] = ceil( randu() * 100.0 ); - p[ i ] = randu(); -======= n = new Float64Array( len ); p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { n[ i ] = discreteUniform( 1, 100 ); p[ i ] = uniform( 0.0, 1.0 ); ->>>>>>> develop } b.tic(); for ( i = 0; i < b.iterations; i++ ) { -<<<<<<< HEAD - y = stdev( n[ i%len ], p[ i%len ] ); -======= y = stdev( n[ i % len ], p[ i % len ] ); ->>>>>>> develop if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js index 91a9bc1c2a27..dc5518110f1d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/benchmark/benchmark.native.js @@ -22,11 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Int32Array = require( '@stdlib/array/int32' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); -var ceil = require( '@stdlib/math/base/special/ceil' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; @@ -49,11 +48,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; len = 100; - n = new Int32Array( len ); + n = new Float64Array( len ); p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - n[ i ] = ceil( randu() * 100.0 ); - p[ i ] = randu(); + n[ i ] = discreteUniform( 1, 100 ); + p[ i ] = uniform( 0.0, 1.0 ); } b.tic(); From 1a8fb3a36ada3089d1ed0d96cf905a9141532137 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 17 Feb 2025 19:44:38 -0500 Subject: [PATCH 12/12] chore: apply suggestions from code review Signed-off-by: Philipp Burckhardt --- .../@stdlib/stats/base/dists/binomial/stdev/README.md | 11 +++++------ .../stats/base/dists/binomial/stdev/manifest.json | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md index 2fe08fca8832..cf2dea9f2ce7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/README.md @@ -167,7 +167,7 @@ for ( i = 0; i < 10; i++ ) { #### stdlib_base_dists_binomial_stdev( n, p ) -Returns the standard deviation of a binomial distribution. +Returns the [standard deviation][stdev] of a [binomial][binomial-distribution] distribution with number of trials `n` and success probability `p`. ```c double out = stdlib_base_dists_binomial_stdev( 100, 0.1 ); @@ -176,12 +176,11 @@ double out = stdlib_base_dists_binomial_stdev( 100, 0.1 ); The function accepts the following arguments: -- **n**: `[in] int` number of trials. +- **n**: `[in] int32_t` number of trials. - **p**: `[in] double` success probability. ```c -double stdlib_base_dists_binomial_stdev( const int n, const double p ); -``` +double stdlib_base_dists_binomial_stdev( const int32_t n, const double p ); @@ -220,8 +219,8 @@ int main( void ) { int i; for ( i = 0; i < 25; i++ ) { - n = stdlib_base_ceil( random_uniform( 0, 100 ) ); - p = random_uniform( 0, 1 ); + n = stdlib_base_ceil( random_uniform( 0.0, 100.0 ) ); + p = random_uniform( 0.0, 1.0 ); y = stdlib_base_dists_binomial_stdev( n, p ); printf( "n: %d, p: %lf, SD(X;n,p): %lf\n", n, p, y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json index 601cc36d008e..44a2bc36b3d5 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/stdev/manifest.json @@ -40,8 +40,7 @@ "dependencies": [ "@stdlib/math/base/napi/binary", "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/sqrt", - "@stdlib/math/base/special/ceil" + "@stdlib/math/base/special/sqrt" ] }, {