From 6e4c472a6e7e8fe8523002db6353d083bf27a0c2 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 28 Feb 2025 22:22:49 -0800 Subject: [PATCH 1/2] refactor: move implementations and macros to separate files --- 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: 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/math/base/napi/unary/README.md | 498 ++++++------- .../include/stdlib/math/base/napi/unary.h | 511 +------------ .../include/stdlib/math/base/napi/unary/c_c.h | 93 +++ .../include/stdlib/math/base/napi/unary/c_f.h | 84 +++ .../include/stdlib/math/base/napi/unary/d_d.h | 81 ++ .../include/stdlib/math/base/napi/unary/f_f.h | 81 ++ .../include/stdlib/math/base/napi/unary/f_i.h | 84 +++ .../include/stdlib/math/base/napi/unary/i_d.h | 84 +++ .../include/stdlib/math/base/napi/unary/i_f.h | 84 +++ .../include/stdlib/math/base/napi/unary/i_i.h | 84 +++ .../include/stdlib/math/base/napi/unary/z_d.h | 84 +++ .../include/stdlib/math/base/napi/unary/z_z.h | 93 +++ .../math/base/napi/unary/manifest.json | 11 +- .../@stdlib/math/base/napi/unary/src/c_c.c | 129 ++++ .../@stdlib/math/base/napi/unary/src/c_f.c | 109 +++ .../@stdlib/math/base/napi/unary/src/d_d.c | 69 ++ .../@stdlib/math/base/napi/unary/src/f_f.c | 69 ++ .../@stdlib/math/base/napi/unary/src/f_i.c | 70 ++ .../@stdlib/math/base/napi/unary/src/i_d.c | 70 ++ .../@stdlib/math/base/napi/unary/src/i_f.c | 70 ++ .../@stdlib/math/base/napi/unary/src/i_i.c | 70 ++ .../@stdlib/math/base/napi/unary/src/main.c | 697 ------------------ .../@stdlib/math/base/napi/unary/src/z_d.c | 109 +++ .../@stdlib/math/base/napi/unary/src/z_z.c | 129 ++++ 24 files changed, 2017 insertions(+), 1446 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_c.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/d_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_i.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_f.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_i.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_d.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_z.h create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/c_c.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/c_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/d_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/f_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/f_i.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/i_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/i_f.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/i_i.c delete mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/z_d.c create mode 100644 lib/node_modules/@stdlib/math/base/napi/unary/src/z_z.c diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/README.md b/lib/node_modules/@stdlib/math/base/napi/unary/README.md index 83918fe74e6c..8e7467e895fc 100644 --- a/lib/node_modules/@stdlib/math/base/napi/unary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/unary/README.md @@ -104,55 +104,51 @@ console.log( headerDir ); #include "stdlib/math/base/napi/unary.h" ``` -#### stdlib_math_base_napi_d_d( env, info, fcn ) + -Invokes a unary function accepting and returning double-precision floating-point numbers. +#### STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a unary 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 scale( const stdlib_complex64_t x ) { + float re; + float im; -static double identity( const double x ) { - return x; -} + stdlib_complex64_reim( x, &re, &im ); -// ... + re *= 10.0f; + im *= 10.0f; -/** -* 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_d_d( env, info, identity ); + return stdlib_complex64( re, im ); } // ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); ``` -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 )` unary function. +- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function. -```c -void stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( 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_f_f( env, info, fcn ) +#### stdlib_math_base_napi_c_c( env, info, fcn ) -Invokes a unary function accepting and returning single-precision floating-point numbers. +Invokes a unary function accepting and returning single-precision complex floating-point numbers. ```c +#include "stdlib/complex/float32/ctor.h" #include // ... -static float identityf( const float x ) { +static stdlib_complex64_t identity( const stdlib_complex64_t x ) { return x; } @@ -166,7 +162,7 @@ static float identityf( const float x ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_f_f( env, info, identityf ); + return stdlib_math_base_napi_c_c( env, info, identity ); } // ... @@ -176,63 +172,46 @@ 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 )` unary function. +- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function. ```c -void stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ); +void stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); ``` -#### stdlib_math_base_napi_z_z( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) -Invokes a unary function accepting and returning double-precision complex floating-point numbers. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. ```c -#include "stdlib/complex/float64/ctor.h" -#include - -// ... +#include "stdlib/complex/float32/ctor.h" -static stdlib_complex128_t identity( const stdlib_complex128_t x ) { - return x; +static float fcn( const stdlib_complex64_t x ) { + // ... } // ... -/** -* 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_z_z( env, info, identity ); -} - -// ... +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); ``` -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 )` unary function. +- **fcn**: `float (*fcn)( stdlib_complex64_t )` unary function. -```c -void stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( 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_z_d( env, info, fcn ) +#### stdlib_math_base_napi_c_f( env, info, fcn ) -Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. +Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. ```c -#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float32/ctor.h" #include // ... -static double fcn( const stdlib_complex128_t x ) { +static float fcn( const stdlib_complex64_t x ) { // ... } @@ -246,7 +225,7 @@ static double fcn( const stdlib_complex128_t x ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_z_d( env, info, fcn ); + return stdlib_math_base_napi_c_f( env, info, fcn ); } // ... @@ -256,23 +235,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)( stdlib_complex128_t )` unary function. +- **fcn**: `[in] float (*fcn)( stdlib_complex64_t )` unary function. ```c -void stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); +void stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); ``` -#### stdlib_math_base_napi_c_c( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) -Invokes a unary function accepting and returning single-precision complex floating-point numbers. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers. + +```c +static double scale( const double x ) { + return x * 10.0; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double )` unary 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_d_d( env, info, fcn ) + +Invokes a unary function accepting and returning double-precision floating-point numbers. ```c -#include "stdlib/complex/float32/ctor.h" #include // ... -static stdlib_complex64_t identity( const stdlib_complex64_t x ) { +static double identity( const double x ) { return x; } @@ -286,7 +285,7 @@ static stdlib_complex64_t identity( const stdlib_complex64_t x ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_c_c( env, info, identity ); + return stdlib_math_base_napi_d_d( env, info, identity ); } // ... @@ -296,24 +295,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 )` unary function. +- **fcn**: `[in] double (*fcn)( double )` unary function. ```c -void stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); +void stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ); ``` -#### stdlib_math_base_napi_c_f( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) -Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers. + +```c +static float scale( const float x ) { + return x * 10.0f; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); +``` + +The macro expects the following arguments: + +- **fcn**: `float (*fcn)( float )` unary 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_f_f( env, info, fcn ) + +Invokes a unary function accepting and returning single-precision floating-point numbers. ```c -#include "stdlib/complex/float32/ctor.h" #include // ... -static float fcn( const stdlib_complex64_t x ) { - // ... +static float identityf( const float x ) { + return x; } // ... @@ -326,7 +345,7 @@ static float fcn( const stdlib_complex64_t x ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_c_f( env, info, fcn ); + return stdlib_math_base_napi_f_f( env, info, identityf ); } // ... @@ -336,15 +355,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] float (*fcn)( stdlib_complex64_t )` unary function. +- **fcn**: `[in] float (*fcn)( float )` unary function. ```c -void stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); +void stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ); ``` -#### stdlib_math_base_napi_i_i( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ) -Invokes a unary function accepting and returning signed 32-bit integers. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. + +```c +#include + +static int32_t fcn( const float x ) { + // ... +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ); +``` + +The macro expects the following arguments: + +- **fcn**: `int32_t (*fcn)( float )` unary 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_f_i( env, info, fcn ) + +Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. ```c #include @@ -352,8 +394,8 @@ Invokes a unary function accepting and returning signed 32-bit integers. // ... -static int32_t identity( const int32_t x ) { - return x; +static int32_t fcn( const float x ) { + // ... } // ... @@ -366,7 +408,7 @@ static int32_t identity( const int32_t x ) { * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_i_i( env, info, identity ); + return stdlib_math_base_napi_f_i( env, info, fcn ); } // ... @@ -376,12 +418,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] int32_t (*fcn)( int32_t )` unary function. +- **fcn**: `[in] int32_t (*fcn)( float )` unary function. ```c -void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ); +void stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ); +``` + +#### STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. + +```c +#include + +static double scale( const int32_t x ) { + return x * 10.0; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); ``` +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( int32_t )` unary 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_i_d( env, info, fcn ) Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. @@ -422,45 +487,28 @@ The function accepts the following arguments: void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); ``` -#### stdlib_math_base_napi_f_i( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ) -Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. ```c -#include #include -// ... - -static int32_t fcn( const float x ) { +static float fcn( const int32_t x ) { // ... } // ... -/** -* 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_f_i( env, info, fcn ); -} - -// ... +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ); ``` -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] int32_t (*fcn)( float )` unary function. +- **fcn**: `float (*fcn)( int32_t )` unary function. -```c -void stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ); -``` +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_i_f( env, info, fcn ) @@ -502,79 +550,68 @@ The function accepts the following arguments: void stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ); ``` -#### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers. ```c -static double scale( const double x ) { - return x * 10.0; -} - -// ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); -``` - -The macro expects the following arguments: - -- **fcn**: `double (*fcn)( double )` unary 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_F_F( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers. +#include -```c -static float scale( const float x ) { - return x * 10.0f; +static int32_t scale( const int32_t x ) { + return x * 10; } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); +STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); ``` The macro expects the following arguments: -- **fcn**: `float (*fcn)( float )` unary function. +- **fcn**: `int32_t (*fcn)( int32_t )` unary 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_Z_Z( fcn ) +#### stdlib_math_base_napi_i_i( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers. +Invokes a unary function accepting and returning signed 32-bit integers. ```c -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float64/reim.h" +#include +#include -static stdlib_complex128_t scale( const stdlib_complex128_t x ) { - double re; - double im; +// ... - stdlib_complex128_reim( x, &re, &im ); +static int32_t identity( const int32_t x ) { + return x; +} - re *= 10.0; - im *= 10.0; +// ... - 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_i_i( env, info, identity ); } // ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary 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 )` unary 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_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ); +``` #### STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) @@ -599,152 +636,117 @@ 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_C_C( fcn ) +#### stdlib_math_base_napi_z_d( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision complex floating-point numbers. +Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. ```c -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float32/reim.h" - -static stdlib_complex64_t scale( const stdlib_complex64_t x ) { - float re; - float im; - - stdlib_complex64_reim( x, &re, &im ); +#include "stdlib/complex/float64/ctor.h" +#include - re *= 10.0f; - im *= 10.0f; +// ... - return stdlib_complex64( re, im ); +static double fcn( const stdlib_complex128_t x ) { + // ... } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); -``` - -The macro expects the following arguments: - -- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary 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_C_F( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -static float fcn( const stdlib_complex64_t x ) { - // ... +/** +* 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_z_d( env, info, fcn ); } // ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); ``` -The macro expects the following arguments: - -- **fcn**: `float (*fcn)( stdlib_complex64_t )` unary 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_I_I( fcn ) +The function accepts the following arguments: -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] double (*fcn)( stdlib_complex128_t )` unary function. ```c -#include - -static int32_t scale( const int32_t x ) { - return x * 10; -} - -// ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); +void stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); ``` -The macro expects the following arguments: +#### STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) -- **fcn**: `int32_t (*fcn)( int32_t )` unary function. +Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers. -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. +```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" -#### STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) +static stdlib_complex128_t scale( const stdlib_complex128_t x ) { + double re; + double im; -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. + stdlib_complex128_reim( x, &re, &im ); -```c -#include + re *= 10.0; + im *= 10.0; -static double scale( const int32_t x ) { - return x * 10.0; + return stdlib_complex128( re, im ); } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); +STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( int32_t )` unary function. +- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary 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_F_I( fcn ) +#### stdlib_math_base_napi_z_z( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. +Invokes a unary function accepting and returning double-precision complex floating-point numbers. ```c -#include - -static int32_t fcn( const float x ) { - // ... -} +#include "stdlib/complex/float64/ctor.h" +#include // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ); -``` - -The macro expects the following arguments: - -- **fcn**: `int32_t (*fcn)( float )` unary 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_I_F( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. +static stdlib_complex128_t identity( const stdlib_complex128_t x ) { + return x; +} -```c -#include +// ... -static float fcn( const int32_t x ) { - // ... +/** +* 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_z_z( env, info, identity ); } // ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ); ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `float (*fcn)( int32_t )` unary 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 )` unary 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_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); +``` diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary.h index af04ffd4e2c1..4e8d5735fc0b 100644 --- a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary.h +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary.h @@ -19,505 +19,16 @@ #ifndef STDLIB_MATH_BASE_NAPI_UNARY_H #define STDLIB_MATH_BASE_NAPI_UNARY_H -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float64/ctor.h" -#include -#include -#include - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision floating-point numbers. -* -* @param fcn unary function -* -* @example -* static double scale( const double x ) { -* return x * 10.0; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) \ - static napi_value stdlib_math_base_napi_d_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_d_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_d_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_d_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_d_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision floating-point numbers. -* -* @param fcn unary function -* -* @example -* static float scale( const float x ) { -* return x * 10.0f; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) \ - static napi_value stdlib_math_base_napi_f_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_f_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_f_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_f_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_f_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision complex floating-point numbers. -* -* @param fcn unary function -* -* @example -* #include "stdlib/complex/float64/ctor.h" -* #include "stdlib/complex/float64/reim.h" -* -* static stdlib_complex128_t scale( const stdlib_complex128_t x ) { -* double re; -* double im; -* -* stdlib_complex128_reim( x, &re, &im ); -* -* re *= 10.0; -* im *= 10.0; -* -* return stdlib_complex128( re, im ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) \ - static napi_value stdlib_math_base_napi_z_z_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_z_z( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_z_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_z_z_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_z_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. -* -* @param fcn unary function -* -* @example -* #include "stdlib/complex/float64/ctor.h" -* -* static double fcn( const stdlib_complex128_t x ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) \ - static napi_value stdlib_math_base_napi_z_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_z_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_z_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_z_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision complex floating-point numbers. -* -* @param fcn unary function -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* #include "stdlib/complex/float32/reim.h" -* -* static stdlib_complex64_t scale( const stdlib_complex64_t x ) { -* float re; -* float im; -* -* stdlib_complex64_reim( x, &re, &im ); -* -* re *= 10.0f; -* im *= 10.0f; -* -* return stdlib_complex64( re, im ); -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) \ - static napi_value stdlib_math_base_napi_c_c_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_c_c( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_c_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_c_c_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_c_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. -* -* @param fcn unary function -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* static float fcn( const stdlib_complex64_t x ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) \ - static napi_value stdlib_math_base_napi_c_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_c_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_c_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_c_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_f_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers. -* -* @param fcn unary function -* -* @example -* #include -* -* static int32_t scale( const int32_t x ) { -* return x * 10; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) \ - static napi_value stdlib_math_base_napi_i_i_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_i_i( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_i_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_i_i_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_i_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. -* -* @param fcn unary function -* -* @example -* #include -* -* static double scale( const int32_t x ) { -* return x * 10.0; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) \ - static napi_value stdlib_math_base_napi_i_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_i_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_i_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_i_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. -* -* @param fcn unary function -* -* @example -* #include -* -* static int32_t fcn( const float x ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ) \ - static napi_value stdlib_math_base_napi_f_i_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_f_i( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_f_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_f_i_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_i_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. -* -* @param fcn unary function -* -* @example -* #include -* -* static float fcn( const int32_t x ) { -* // ... -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ) \ - static napi_value stdlib_math_base_napi_i_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_i_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_i_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_i_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_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 unary function accepting and returning double-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ); - -/** -* Invokes a unary function accepting and returning single-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ); - -/** -* Invokes a unary function accepting and returning double-precision complex floating-point numbers. -*/ -napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); - -/** -* Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); - -/** -* Invokes a unary function accepting and returning single-precision complex floating-point numbers. -*/ -napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); - -/** -* Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); - -/** -* Invokes a unary function accepting and returning signed 32-bit integers. -*/ -napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ); - -/** -* Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); - -/** -* Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. -*/ -napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ); - -/** -* Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. -*/ -napi_value stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ); - -#ifdef __cplusplus -} -#endif +// NOTE: keep in alphabetical order... +#include "stdlib/math/base/napi/unary/c_c.h" +#include "stdlib/math/base/napi/unary/c_f.h" +#include "stdlib/math/base/napi/unary/d_d.h" +#include "stdlib/math/base/napi/unary/f_f.h" +#include "stdlib/math/base/napi/unary/f_i.h" +#include "stdlib/math/base/napi/unary/i_d.h" +#include "stdlib/math/base/napi/unary/i_f.h" +#include "stdlib/math/base/napi/unary/i_i.h" +#include "stdlib/math/base/napi/unary/z_d.h" +#include "stdlib/math/base/napi/unary/z_z.h" #endif // !STDLIB_MATH_BASE_NAPI_UNARY_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_c.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_c.h new file mode 100644 index 000000000000..bb0f6734552c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_c.h @@ -0,0 +1,93 @@ +/** +* @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_UNARY_C_C_H +#define STDLIB_MATH_BASE_NAPI_UNARY_C_C_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision complex floating-point numbers. +* +* @param fcn unary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include "stdlib/complex/float32/reim.h" +* +* static stdlib_complex64_t scale( const stdlib_complex64_t x ) { +* float re; +* float im; +* +* stdlib_complex64_reim( x, &re, &im ); +* +* re *= 10.0f; +* im *= 10.0f; +* +* return stdlib_complex64( re, im ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) \ + static napi_value stdlib_math_base_napi_c_c_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_c_c( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_c_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_c_c_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_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 unary function accepting and returning single-precision complex floating-point numbers. +*/ +napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_C_C_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_f.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_f.h new file mode 100644 index 000000000000..8434bc91e4c6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/c_f.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_UNARY_C_F_H +#define STDLIB_MATH_BASE_NAPI_UNARY_C_F_H + +#include "stdlib/complex/float32/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. +* +* @param fcn unary function +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* +* static float fcn( const stdlib_complex64_t x ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) \ + static napi_value stdlib_math_base_napi_c_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_c_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_c_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_c_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_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 unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_C_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/d_d.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/d_d.h new file mode 100644 index 000000000000..83f1c16aa176 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/d_d.h @@ -0,0 +1,81 @@ +/** +* @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_UNARY_D_D_H +#define STDLIB_MATH_BASE_NAPI_UNARY_D_D_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision floating-point numbers. +* +* @param fcn unary function +* +* @example +* static double scale( const double x ) { +* return x * 10.0; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) \ + static napi_value stdlib_math_base_napi_d_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_d_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_d_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_d_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_d_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 unary function accepting and returning double-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_D_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_f.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_f.h new file mode 100644 index 000000000000..43064badf4df --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_f.h @@ -0,0 +1,81 @@ +/** +* @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_UNARY_F_F_H +#define STDLIB_MATH_BASE_NAPI_UNARY_F_F_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision floating-point numbers. +* +* @param fcn unary function +* +* @example +* static float scale( const float x ) { +* return x * 10.0f; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) \ + static napi_value stdlib_math_base_napi_f_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_f_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_f_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_f_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_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 unary function accepting and returning single-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_F_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_i.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_i.h new file mode 100644 index 000000000000..8e94b343f33b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/f_i.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_UNARY_F_I_H +#define STDLIB_MATH_BASE_NAPI_UNARY_F_I_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. +* +* @param fcn unary function +* +* @example +* #include +* +* static int32_t fcn( const float x ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ) \ + static napi_value stdlib_math_base_napi_f_i_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_f_i( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_f_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_f_i_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_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 unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. +*/ +napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_F_I_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_d.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_d.h new file mode 100644 index 000000000000..c93ec9e530c6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_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_UNARY_I_D_H +#define STDLIB_MATH_BASE_NAPI_UNARY_I_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. +* +* @param fcn unary function +* +* @example +* #include +* +* static double scale( const int32_t x ) { +* return x * 10.0; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) \ + static napi_value stdlib_math_base_napi_i_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_i_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_i_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_i_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_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 unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_I_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_f.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_f.h new file mode 100644 index 000000000000..a3f0a3f56f40 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_f.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_UNARY_I_F_H +#define STDLIB_MATH_BASE_NAPI_UNARY_I_F_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. +* +* @param fcn unary function +* +* @example +* #include +* +* static float fcn( const int32_t x ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ) \ + static napi_value stdlib_math_base_napi_i_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_i_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_i_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_i_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_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 unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_I_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_i.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_i.h new file mode 100644 index 000000000000..a6e1019c23bd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/i_i.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_UNARY_I_I_H +#define STDLIB_MATH_BASE_NAPI_UNARY_I_I_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers. +* +* @param fcn unary function +* +* @example +* #include +* +* static int32_t scale( const int32_t x ) { +* return x * 10; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) \ + static napi_value stdlib_math_base_napi_i_i_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_i_i( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_i_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_i_i_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_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 unary function accepting and returning signed 32-bit integers. +*/ +napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_I_I_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_d.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_d.h new file mode 100644 index 000000000000..c05ab1daae4f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_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_UNARY_Z_D_H +#define STDLIB_MATH_BASE_NAPI_UNARY_Z_D_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. +* +* @param fcn unary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* +* static double fcn( const stdlib_complex128_t x ) { +* // ... +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) \ + static napi_value stdlib_math_base_napi_z_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_z_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_z_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_z_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_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 unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_Z_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_z.h b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_z.h new file mode 100644 index 000000000000..0edecde5a425 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/z_z.h @@ -0,0 +1,93 @@ +/** +* @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_UNARY_Z_Z_H +#define STDLIB_MATH_BASE_NAPI_UNARY_Z_Z_H + +#include "stdlib/complex/float64/ctor.h" +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision complex floating-point numbers. +* +* @param fcn unary function +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/reim.h" +* +* static stdlib_complex128_t scale( const stdlib_complex128_t x ) { +* double re; +* double im; +* +* stdlib_complex128_reim( x, &re, &im ); +* +* re *= 10.0; +* im *= 10.0; +* +* return stdlib_complex128( re, im ); +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) \ + static napi_value stdlib_math_base_napi_z_z_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_z_z( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_z_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_z_z_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_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 unary function accepting and returning double-precision complex floating-point numbers. +*/ +napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_UNARY_Z_Z_H diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/manifest.json b/lib/node_modules/@stdlib/math/base/napi/unary/manifest.json index a5633139306e..a8963755942a 100644 --- a/lib/node_modules/@stdlib/math/base/napi/unary/manifest.json +++ b/lib/node_modules/@stdlib/math/base/napi/unary/manifest.json @@ -25,7 +25,16 @@ "confs": [ { "src": [ - "./src/main.c" + "./src/c_c.c", + "./src/c_f.c", + "./src/d_d.c", + "./src/f_f.c", + "./src/f_i.c", + "./src/i_d.c", + "./src/i_f.c", + "./src/i_i.c", + "./src/z_d.c", + "./src/z_z.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/c_c.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/c_c.c new file mode 100644 index 000000000000..7afb9cfdc75a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/c_c.c @@ -0,0 +1,129 @@ +/** +* @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/unary/c_c.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" +#include +#include +#include + +/** +* Invokes a unary 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); + 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. 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. 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. 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. 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 ); + + stdlib_complex64_t v = fcn( 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/unary/src/c_f.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/c_f.c new file mode 100644 index 000000000000..c76743155f2a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/c_f.c @@ -0,0 +1,109 @@ +/** +* @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/unary/c_f.h" +#include "stdlib/complex/float32/ctor.h" +#include +#include +#include + +/** +* Invokes a unary function accepting a single-precision complex floating-point number 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); + 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. 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. 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. 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. Argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re; + status = napi_get_value_double( env, xre, &re ); + assert( status == napi_ok ); + + double im; + status = napi_get_value_double( env, xim, &im ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( stdlib_complex64( (float)re, (float)im ) ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/d_d.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/d_d.c new file mode 100644 index 000000000000..7833ae9e42ab --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/d_d.c @@ -0,0 +1,69 @@ +/** +* @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/unary/d_d.h" +#include +#include + +/** +* Invokes a unary 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); + 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. Must provide a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/f_f.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/f_f.c new file mode 100644 index 000000000000..6aede28731a0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/f_f.c @@ -0,0 +1,69 @@ +/** +* @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/unary/f_f.h" +#include +#include + +/** +* Invokes a unary 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); + 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. Must provide a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( (float)x ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/f_i.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/f_i.c new file mode 100644 index 000000000000..0f91ad0e71e2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/f_i.c @@ -0,0 +1,70 @@ +/** +* @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/unary/f_i.h" +#include +#include +#include + +/** +* Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API signed 32-bit integer +*/ +napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); + 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. Must provide a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_int32( env, (int32_t)fcn( (float)x ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/i_d.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/i_d.c new file mode 100644 index 000000000000..8d2f787a429c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/i_d.c @@ -0,0 +1,70 @@ +/** +* @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/unary/i_d.h" +#include +#include +#include + +/** +* Invokes a unary function accepting 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); + 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. Must provide a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/i_f.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/i_f.c new file mode 100644 index 000000000000..4fd812c35a37 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/i_f.c @@ -0,0 +1,70 @@ +/** +* @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/unary/i_f.h" +#include +#include +#include + +/** +* Invokes a unary function accepting 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); + 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. Must provide a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, (double)fcn( x ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/i_i.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/i_i.c new file mode 100644 index 000000000000..3c92fb1531a6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/i_i.c @@ -0,0 +1,70 @@ +/** +* @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/unary/i_i.h" +#include +#include +#include + +/** +* Invokes a unary 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API signed 32-bit integer +*/ +napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); + 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. Must provide a number." ); + assert( status == napi_ok ); + return NULL; + } + + int32_t x; + status = napi_get_value_int32( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_int32( env, fcn( x ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/main.c deleted file mode 100644 index 571fe05cbf94..000000000000 --- a/lib/node_modules/@stdlib/math/base/napi/unary/src/main.c +++ /dev/null @@ -1,697 +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/unary.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 unary 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); - 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. Must provide a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); - 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. Must provide a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( (float)x ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); - 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. 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. 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. 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. 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 ); - - stdlib_complex128_t v = fcn( 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; -} - -/** -* Invokes a unary function accepting a double-precision complex 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); - 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. 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. 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. 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. Argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re; - status = napi_get_value_double( env, xre, &re ); - assert( status == napi_ok ); - - double im; - status = napi_get_value_double( env, xim, &im ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( stdlib_complex128( re, im ) ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); - 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. 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. 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. 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. 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 ); - - stdlib_complex64_t v = fcn( 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; -} - -/** -* Invokes a unary function accepting a single-precision complex floating-point number 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API complex-like object -*/ -napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); - 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. 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. 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. 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. Argument must have an imaginary component which a number." ); - assert( status == napi_ok ); - return NULL; - } - - double re; - status = napi_get_value_double( env, xre, &re ); - assert( status == napi_ok ); - - double im; - status = napi_get_value_double( env, xim, &im ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( stdlib_complex64( (float)re, (float)im ) ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API signed 32-bit integer -*/ -napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); - 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. Must provide a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_int32( env, fcn( x ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary function accepting 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); - 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. Must provide a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API signed 32-bit integer -*/ -napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); - 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. Must provide a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_int32( env, (int32_t)fcn( (float)x ), &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Invokes a unary function accepting 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. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn unary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ) { - napi_status status; - - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); - 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. Must provide a number." ); - assert( status == napi_ok ); - return NULL; - } - - int32_t x; - status = napi_get_value_int32( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, (double)fcn( x ), &v ); - assert( status == napi_ok ); - - return v; -} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/z_d.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/z_d.c new file mode 100644 index 000000000000..41648536141c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/z_d.c @@ -0,0 +1,109 @@ +/** +* @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/unary/z_d.h" +#include "stdlib/complex/float64/ctor.h" +#include +#include +#include + +/** +* Invokes a unary function accepting a double-precision complex 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); + 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. 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. 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. 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. Argument must have an imaginary component which a number." ); + assert( status == napi_ok ); + return NULL; + } + + double re; + status = napi_get_value_double( env, xre, &re ); + assert( status == napi_ok ); + + double im; + status = napi_get_value_double( env, xim, &im ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( stdlib_complex128( re, im ) ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/src/z_z.c b/lib/node_modules/@stdlib/math/base/napi/unary/src/z_z.c new file mode 100644 index 000000000000..b27bb53a59ab --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/unary/src/z_z.c @@ -0,0 +1,129 @@ +/** +* @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/unary/z_z.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include +#include + +/** +* Invokes a unary 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. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn unary function +* @return function return value as a Node-API complex-like object +*/ +napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ) { + napi_status status; + + size_t argc = 1; + napi_value argv[ 1 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 1 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); + 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. 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. 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. 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. 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 ); + + stdlib_complex128_t v = fcn( 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; +} From 911b72f1dcf9ad658d71b955d40992a73e694e57 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 28 Feb 2025 23:00:19 -0800 Subject: [PATCH 2/2] chore: fix typo in README --- 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 --- --- lib/node_modules/@stdlib/math/base/napi/unary/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/napi/unary/README.md b/lib/node_modules/@stdlib/math/base/napi/unary/README.md index 8e7467e895fc..1da8c8ac9615 100644 --- a/lib/node_modules/@stdlib/math/base/napi/unary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/unary/README.md @@ -484,7 +484,7 @@ The function accepts the following arguments: - **fcn**: `[in] double (*fcn)( int32_t )` unary function. ```c -void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); +void stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); ``` #### STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn )