diff --git a/.github/workflows/check_licenses.yml b/.github/workflows/check_licenses.yml index 5f6a3e434863..434439cbf851 100644 --- a/.github/workflows/check_licenses.yml +++ b/.github/workflows/check_licenses.yml @@ -128,7 +128,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact: diff --git a/.github/workflows/lint_changed_files.yml b/.github/workflows/lint_changed_files.yml index 380805af49cb..719048ee0d6b 100644 --- a/.github/workflows/lint_changed_files.yml +++ b/.github/workflows/lint_changed_files.yml @@ -75,7 +75,7 @@ jobs: # Cache dependencies: - name: 'Cache dependencies' # Pin action to full length commit SHA - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 id: cache with: path: | @@ -264,7 +264,7 @@ jobs: - name: 'Setup R' if: ( success() || failure() ) && steps.check-r-files.outputs.files != '' # Pin action to full length commit SHA - uses: r-lib/actions/setup-r@473c68190595b311a74f208fba61a8d8c0d4c247 # v2.11.1 + uses: r-lib/actions/setup-r@14a7e741c1cb130261263aa1593718ba42cf443b # v2.11.2 with: r-version: '3.5.3' diff --git a/.github/workflows/lint_random_files.yml b/.github/workflows/lint_random_files.yml index b4dff058e24b..692cb3d8a65e 100644 --- a/.github/workflows/lint_random_files.yml +++ b/.github/workflows/lint_random_files.yml @@ -411,7 +411,7 @@ jobs: - name: 'Setup R' if: ( github.event.inputs.r != 'false' ) && ( success() || failure() ) # Pin action to full length commit SHA - uses: r-lib/actions/setup-r@473c68190595b311a74f208fba61a8d8c0d4c247 # v2.11.1 + uses: r-lib/actions/setup-r@14a7e741c1cb130261263aa1593718ba42cf443b # v2.11.2 with: r-version: '4.3.3' diff --git a/.github/workflows/linux_benchmark.yml b/.github/workflows/linux_benchmark.yml index 1009e17d51e3..99e66a2734ab 100644 --- a/.github/workflows/linux_benchmark.yml +++ b/.github/workflows/linux_benchmark.yml @@ -251,7 +251,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/linux_examples.yml b/.github/workflows/linux_examples.yml index 43246c05129c..6e8194607d16 100644 --- a/.github/workflows/linux_examples.yml +++ b/.github/workflows/linux_examples.yml @@ -251,7 +251,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/linux_test.yml b/.github/workflows/linux_test.yml index 2716dd136fff..f0dd616b829f 100644 --- a/.github/workflows/linux_test.yml +++ b/.github/workflows/linux_test.yml @@ -250,7 +250,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/linux_test_cov.yml b/.github/workflows/linux_test_cov.yml index 513d2d4b1012..8b827d867843 100644 --- a/.github/workflows/linux_test_cov.yml +++ b/.github/workflows/linux_test_cov.yml @@ -251,7 +251,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/linux_test_install.yml b/.github/workflows/linux_test_install.yml index 2b7937cbd58c..c00204f4c9e8 100644 --- a/.github/workflows/linux_test_install.yml +++ b/.github/workflows/linux_test_install.yml @@ -274,7 +274,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/macos_benchmark.yml b/.github/workflows/macos_benchmark.yml index 13fd5b82386d..495051244e28 100644 --- a/.github/workflows/macos_benchmark.yml +++ b/.github/workflows/macos_benchmark.yml @@ -237,7 +237,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/macos_test.yml b/.github/workflows/macos_test.yml index c4e8d898a33e..e75697d8dc6c 100644 --- a/.github/workflows/macos_test.yml +++ b/.github/workflows/macos_test.yml @@ -236,7 +236,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/macos_test_cov.yml b/.github/workflows/macos_test_cov.yml index 0104d22afafa..8cc505afc76f 100644 --- a/.github/workflows/macos_test_cov.yml +++ b/.github/workflows/macos_test_cov.yml @@ -237,7 +237,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/macos_test_npm_install.yml b/.github/workflows/macos_test_npm_install.yml index 2fa732ae3fad..56826bb34f97 100644 --- a/.github/workflows/macos_test_npm_install.yml +++ b/.github/workflows/macos_test_npm_install.yml @@ -233,7 +233,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/.github/workflows/markdown_links.yml b/.github/workflows/markdown_links.yml index 2b3b1b097f8b..7bf4c5198645 100644 --- a/.github/workflows/markdown_links.yml +++ b/.github/workflows/markdown_links.yml @@ -164,7 +164,7 @@ jobs: # Upload the log files: - name: 'Upload log files' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact: diff --git a/.github/workflows/markdown_src_attributes.yml b/.github/workflows/markdown_src_attributes.yml index 133898b95c61..e8edb537b227 100644 --- a/.github/workflows/markdown_src_attributes.yml +++ b/.github/workflows/markdown_src_attributes.yml @@ -119,7 +119,7 @@ jobs: # Upload the log files: - name: 'Upload log files' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact: diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml index 7864aec56504..9ac9d28fcd1c 100644 --- a/.github/workflows/npm_downloads.yml +++ b/.github/workflows/npm_downloads.yml @@ -88,7 +88,7 @@ jobs: # Upload the download data: - name: 'Upload data' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: # Define a name for the uploaded artifact (ensuring a unique name for each job): name: npm_downloads diff --git a/.github/workflows/ossf_scorecard.yml b/.github/workflows/ossf_scorecard.yml index 5850535ff52d..75165899cb34 100644 --- a/.github/workflows/ossf_scorecard.yml +++ b/.github/workflows/ossf_scorecard.yml @@ -69,7 +69,7 @@ jobs: - name: "Run analysis" # Pin action to full length commit SHA - uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 with: results_file: results.sarif results_format: sarif @@ -87,7 +87,7 @@ jobs: # Upload the results as artifacts: - name: "Upload artifact" # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: SARIF file path: results.sarif diff --git a/.github/workflows/run_affected_benchmarks.yml b/.github/workflows/run_affected_benchmarks.yml index 52253d7a55c5..453ba7be7681 100644 --- a/.github/workflows/run_affected_benchmarks.yml +++ b/.github/workflows/run_affected_benchmarks.yml @@ -89,7 +89,7 @@ jobs: # Cache dependencies: - name: 'Cache dependencies' # Pin action to full length commit SHA - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 id: cache with: path: | diff --git a/.github/workflows/run_affected_examples.yml b/.github/workflows/run_affected_examples.yml index 93e20ae705d9..b1b7b466e0f4 100644 --- a/.github/workflows/run_affected_examples.yml +++ b/.github/workflows/run_affected_examples.yml @@ -85,7 +85,7 @@ jobs: # Cache dependencies: - name: 'Cache dependencies' # Pin action to full length commit SHA - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 id: cache with: path: | diff --git a/.github/workflows/run_affected_tests.yml b/.github/workflows/run_affected_tests.yml index b13f9a65e29b..92a6d0b0a0ed 100644 --- a/.github/workflows/run_affected_tests.yml +++ b/.github/workflows/run_affected_tests.yml @@ -120,7 +120,7 @@ jobs: # Cache dependencies: - name: 'Cache dependencies' # Pin action to full length commit SHA - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 id: cache with: path: | diff --git a/.github/workflows/run_tests_coverage.yml b/.github/workflows/run_tests_coverage.yml index 7b67178c753f..0e9cf768646a 100644 --- a/.github/workflows/run_tests_coverage.yml +++ b/.github/workflows/run_tests_coverage.yml @@ -123,7 +123,7 @@ jobs: # Cache dependencies: - name: 'Cache dependencies' # Pin action to full length commit SHA - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 id: cache with: path: | diff --git a/.github/workflows/standalone_publish.yml b/.github/workflows/standalone_publish.yml index 9e26f098c273..9bdbe583fd84 100644 --- a/.github/workflows/standalone_publish.yml +++ b/.github/workflows/standalone_publish.yml @@ -130,7 +130,7 @@ jobs: # Archive list of to be published packages: - name: 'Archive package list' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: ordered-pkg-list path: | diff --git a/.github/workflows/too_many_good_first_prs.yml b/.github/workflows/too_many_good_first_prs.yml index bb4e94fe179a..a4831df5e005 100644 --- a/.github/workflows/too_many_good_first_prs.yml +++ b/.github/workflows/too_many_good_first_prs.yml @@ -34,8 +34,11 @@ jobs: # Define job name: name: 'Check if contributor has opened too many "Good First PRs"' - # Only run this job if the pull request did not have label `automated-pr`: - if: contains(github.event.pull_request.labels.*.name, 'automated-pr') == false + # Only run this job if the pull request did not have label `automated-pr` and is not from bots: + if: > + contains(github.event.pull_request.labels.*.name, 'automated-pr') == false && + github.event.pull_request.user.login != 'stdlib-bot' && + github.event.pull_request.user.login != 'dependabot[bot]' # Define job permissions: permissions: diff --git a/.github/workflows/windows_test_npm_install.yml b/.github/workflows/windows_test_npm_install.yml index 5e852577378f..721aac61e93b 100644 --- a/.github/workflows/windows_test_npm_install.yml +++ b/.github/workflows/windows_test_npm_install.yml @@ -155,7 +155,7 @@ jobs: # Install MSYS2: - name: 'Install MSYS2' # Pin action to full length commit SHA - uses: msys2/setup-msys2@d44ca8e88d8b43d56cf5670f91747359d5537f97 # v2.26.0 + uses: msys2/setup-msys2@61f9e5e925871ba6c9e3e8da24ede83ea27fa91f # v2.27.0 with: # Set the MSYS system: msystem: MINGW64 @@ -287,7 +287,7 @@ jobs: # Upload the log file: - name: 'Upload log file' # Pin action to full length commit SHA - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: always() with: # Define a name for the uploaded artifact (ensuring a unique name for each job): diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-nested-require/examples/index.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-nested-require/examples/index.js index ade5b212640d..2de0386c21fd 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-nested-require/examples/index.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-nested-require/examples/index.js @@ -36,17 +36,17 @@ result = linter.verify( code, { }); console.log( result ); /* => - [ - { - 'ruleId': 'no-nested-require', - 'severity': 2, - 'message': 'do not use nested property access for require() expressions', - 'line': 2, - 'column': 15, - 'nodeType': 'CallExpression', - 'source': 'var special = require( \'@stdlib/math\' ).base.special;', - 'endLine': 2, - 'endColumn': 29 - } - ] + [ + { + 'ruleId': 'no-nested-require', + 'severity': 2, + 'message': 'do not use nested property access for require() expressions', + 'line': 2, + 'column': 15, + 'nodeType': 'CallExpression', + 'source': 'var special = require( \'@stdlib/math\' ).base.special;', + 'endLine': 2, + 'endColumn': 29 + } + ] */ diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/README.md b/lib/node_modules/@stdlib/math/base/napi/quaternary/README.md index f30e652ac7e2..a2acc38e124f 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quaternary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/README.md @@ -104,6 +104,29 @@ console.log( headerDir ); #include "stdlib/math/base/napi/quaternary.h" ``` + + +#### STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning double-precision floating-point numbers. + +```c +static double add( const double x, const double y, const double z, const double w ) { + return x + y + z + w; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, double, double, double )` quaternary 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_dddd_d( env, info, fcn ) Invokes a quaternary function accepting and returning double-precision floating-point numbers. @@ -143,16 +166,37 @@ The function accepts the following arguments: void stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ); ``` -#### stdlib_math_base_napi_ffff_f( env, info, fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( fcn ) -Invokes a quaternary function accepting and returning single-precision floating-point numbers. +Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number. + +```c +static double add( const double x, const int32_t y, const int32_t z, const int32_t w ) { + return x + y + z + w; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, int32_t, int32_t, int32_t )` quaternary 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_diii_d( env, info, fcn ) + +Invokes a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number. ```c #include // ... -static float addf( const float x, const float y, const float z, const float w ) { +static double add( const double x, const int32_t y, const int32_t z, const int32_t w ) { return x + y + z + w; } @@ -166,7 +210,7 @@ static float addf( const float x, const float y, const float z, const float w ) * @return Node-API value */ napi_value addon( napi_env env, napi_callback_info info ) { - return stdlib_math_base_napi_ffff_f( env, info, addf ); + return stdlib_math_base_napi_diii_d( env, info, add ); } // ... @@ -176,53 +220,71 @@ The function accepts the following arguments: - **env**: `[in] napi_env` environment under which the function is invoked. - **info**: `[in] napi_callback_info` callback data. -- **fcn**: `[in] float (*fcn)( float, float, float, float )` quaternary function. +- **fcn**: `[in] double (*fcn)( double, int32_t, int32_t, int32_t )` quaternary function. ```c -void stdlib_math_base_napi_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) ); +void stdlib_math_base_napi_diii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t, int32_t ) ); ``` -#### STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn ) +#### STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( fcn ) -Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning double-precision floating-point numbers. +Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning single-precision floating-point numbers. ```c -static double add( const double x, const double y, const double z, const double w ) { +static float addf( const float x, const float y, const float z, const float w ) { return x + y + z + w; } // ... // Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add ); +STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf ); ``` The macro expects the following arguments: -- **fcn**: `double (*fcn)( double, double, double, double )` quaternary function. +- **fcn**: `float (*fcn)( float, float, float, float )` quaternary 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_FFFF_F( fcn ) +#### stdlib_math_base_napi_ffff_f( env, info, fcn ) -Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning single-precision floating-point numbers. +Invokes a quaternary function accepting and returning single-precision floating-point numbers. ```c +#include + +// ... + static float addf( const float x, const float y, const float z, const float w ) { return x + y + z + w; } // ... -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf ); +/** +* 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_ffff_f( env, info, addf ); +} + +// ... ``` -The macro expects the following arguments: +The function accepts the following arguments: -- **fcn**: `float (*fcn)( float, float, float, float )` quaternary function. +- **env**: `[in] napi_env` environment under which the function is invoked. +- **info**: `[in] napi_callback_info` callback data. +- **fcn**: `[in] float (*fcn)( float, float, float, float )` quaternary 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_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) ); +``` diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary.h b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary.h index 69d3f5b82ce7..921a9c35f2fb 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary.h +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary.h @@ -19,108 +19,9 @@ #ifndef STDLIB_MATH_BASE_NAPI_QUATERNARY_H #define STDLIB_MATH_BASE_NAPI_QUATERNARY_H -#include -#include - -/** -* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning double-precision floating-point numbers. -* -* @param fcn quaternary function -* -* @example -* static double add( const double x, const double y, const double z, const double w ) { -* return x + y + z + w; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn ) \ - static napi_value stdlib_math_base_napi_dddd_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_dddd_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_dddd_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_dddd_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dddd_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning single-precision floating-point numbers. -* -* @param fcn quaternary function -* -* @example -* static float addf( const float x, const float y, const float z, const float w ) { -* return x + y + z + w; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( fcn ) \ - static napi_value stdlib_math_base_napi_ffff_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ffff_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ffff_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_ffff_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ffff_f_init ) - -/* -* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Invokes a quaternary function accepting and returning double-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ); - -/** -* Invokes a quaternary function accepting and returning single-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) ); - -#ifdef __cplusplus -} -#endif +// NOTE: keep in alphabetical order... +#include "stdlib/math/base/napi/quaternary/dddd_d.h" +#include "stdlib/math/base/napi/quaternary/diii_d.h" +#include "stdlib/math/base/napi/quaternary/ffff_f.h" #endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/dddd_d.h b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/dddd_d.h new file mode 100644 index 000000000000..75f36b802f12 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/dddd_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_QUATERNARY_DDDD_D_H +#define STDLIB_MATH_BASE_NAPI_QUATERNARY_DDDD_D_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning double-precision floating-point numbers. +* +* @param fcn quaternary function +* +* @example +* static double add( const double x, const double y, const double z, const double w ) { +* return x + y + z + w; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn ) \ + static napi_value stdlib_math_base_napi_dddd_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_dddd_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_dddd_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_dddd_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dddd_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quaternary function accepting and returning double-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_DDDD_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/diii_d.h b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/diii_d.h new file mode 100644 index 000000000000..0d7490956c1f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/diii_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_QUATERNARY_DIII_D_H +#define STDLIB_MATH_BASE_NAPI_QUATERNARY_DIII_D_H + +#include +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number. +* +* @param fcn quaternary function +* +* @example +* #include +* +* static double add( const double x, const int32_t y, const int32_t z, const int32_t w ) { +* return x + y + z + w; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( fcn ) \ + static napi_value stdlib_math_base_napi_diii_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_diii_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_diii_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_diii_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_diii_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number. +*/ +napi_value stdlib_math_base_napi_diii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t, int32_t ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_DIII_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/ffff_f.h b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/ffff_f.h new file mode 100644 index 000000000000..e20a1fd79db3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/include/stdlib/math/base/napi/quaternary/ffff_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_QUATERNARY_FFFF_F_H +#define STDLIB_MATH_BASE_NAPI_QUATERNARY_FFFF_F_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning single-precision floating-point numbers. +* +* @param fcn quaternary function +* +* @example +* static float addf( const float x, const float y, const float z, const float w ) { +* return x + y + z + w; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( fcn ) \ + static napi_value stdlib_math_base_napi_ffff_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ffff_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ffff_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_ffff_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ffff_f_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quaternary function accepting and returning single-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_FFFF_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/manifest.json b/lib/node_modules/@stdlib/math/base/napi/quaternary/manifest.json index 04e61e361caa..f343df6aa8dc 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quaternary/manifest.json +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/manifest.json @@ -25,7 +25,9 @@ "confs": [ { "src": [ - "./src/main.c" + "./src/dddd_d.c", + "./src/diii_d.c", + "./src/ffff_f.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/src/dddd_d.c b/lib/node_modules/@stdlib/math/base/napi/quaternary/src/dddd_d.c new file mode 100644 index 000000000000..f868d4ab0ac5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/src/dddd_d.c @@ -0,0 +1,111 @@ +/** +* @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/quaternary/dddd_d.h" +#include +#include + +/** +* Invokes a quaternary function accepting and returning double-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* - `w`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn quaternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ) { + napi_status status; + + size_t argc = 4; + napi_value argv[ 4 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 4 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide four numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype3; + status = napi_typeof( env, argv[ 3 ], &vtype3 ); + assert( status == napi_ok ); + if ( vtype3 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + double z; + status = napi_get_value_double( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + double w; + status = napi_get_value_double( env, argv[ 3 ], &w ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z, w ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/src/diii_d.c b/lib/node_modules/@stdlib/math/base/napi/quaternary/src/diii_d.c new file mode 100644 index 000000000000..0765d6dd814d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/src/diii_d.c @@ -0,0 +1,112 @@ +/** +* @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/quaternary/diii_d.h" +#include +#include +#include + +/** +* Invokes a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* - `w`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn quaternary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_diii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t, int32_t ) ) { + napi_status status; + + size_t argc = 4; + napi_value argv[ 4 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 4 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide four numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype3; + status = napi_typeof( env, argv[ 3 ], &vtype3 ); + assert( status == napi_ok ); + if ( vtype3 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + int32_t y; + status = napi_get_value_int32( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + int32_t z; + status = napi_get_value_int32( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + int32_t w; + status = napi_get_value_int32( env, argv[ 3 ], &w ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z, w ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/quaternary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/quaternary/src/ffff_f.c similarity index 55% rename from lib/node_modules/@stdlib/math/base/napi/quaternary/src/main.c rename to lib/node_modules/@stdlib/math/base/napi/quaternary/src/ffff_f.c index 985e685a42f6..f90212579df4 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quaternary/src/main.c +++ b/lib/node_modules/@stdlib/math/base/napi/quaternary/src/ffff_f.c @@ -16,101 +16,10 @@ * limitations under the License. */ -#include "stdlib/math/base/napi/quaternary.h" +#include "stdlib/math/base/napi/quaternary/ffff_f.h" #include -#include #include -/** -* Invokes a quaternary function accepting and returning double-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* - `z`: input value. -* - `w`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn quaternary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ) { - napi_status status; - - size_t argc = 4; - napi_value argv[ 4 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 4 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide four numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - double z; - status = napi_get_value_double( env, argv[ 2 ], &z ); - assert( status == napi_ok ); - - double w; - status = napi_get_value_double( env, argv[ 3 ], &w ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y, z, w ), &v ); - assert( status == napi_ok ); - - return v; -} - /** * Invokes a quaternary function accepting and returning single-precision floating-point numbers. * diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/README.md b/lib/node_modules/@stdlib/math/base/napi/quinary/README.md index 66ec59bdb3c0..1cdb1f313743 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/README.md @@ -104,6 +104,29 @@ console.log( headerDir ); #include "stdlib/math/base/napi/quinary.h" ``` + + +#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers. + +```c +static double add( const double x, const double y, const double z, const double w, const double u ) { + return x + y + z + w + u; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary 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_ddddd_d( env, info, fcn ) Invokes a quinary function accepting and returning double-precision floating-point numbers. @@ -143,6 +166,27 @@ The function accepts the following arguments: void stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); ``` +#### STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers. + +```c +static float addf( const float x, const float y, const float z, const float w, const float u ) { + return x + y + z + w + u; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); +``` + +The macro expects the following arguments: + +- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary 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_fffff_f( env, info, fcn ) Invokes a quinary function accepting and returning single-precision floating-point numbers. @@ -182,48 +226,6 @@ The function accepts the following arguments: void stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); ``` -#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers. - -```c -static double add( const double x, const double y, const double z, const double w, const double u ) { - return x + y + z + w + u; -} - -// ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); -``` - -The macro expects the following arguments: - -- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary 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_FFFFF_F( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers. - -```c -static float addf( const float x, const float y, const float z, const float w, const float u ) { - return x + y + z + w + u; -} - -// ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); -``` - -The macro expects the following arguments: - -- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary function. - -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. - diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h index 59561359eb2b..fd7fff661f94 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h @@ -22,105 +22,8 @@ #include #include -/** -* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning double-precision floating-point numbers. -* -* @param fcn quinary function -* -* @example -* static double add( const double x, const double y, const double z, const double w, const double u ) { -* return x + y + z + w + u; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) \ - static napi_value stdlib_math_base_napi_ddddd_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ddddd_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ddddd_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_ddddd_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ddddd_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning single-precision floating-point numbers. -* -* @param fcn quinary function -* -* @example -* static float addf( const float x, const float y, const float z, const float w, const float u ) { -* return x + y + z + w + u; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) \ - static napi_value stdlib_math_base_napi_fffff_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_fffff_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_fffff_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_fffff_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fffff_f_init ) - -/* -* If C++, prevent name mangling so that the compiler emits a quinary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Invokes a quinary function accepting and returning double-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); - -/** -* Invokes a quinary function accepting and returning single-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); - -#ifdef __cplusplus -} -#endif +// NOTE: keep in alphabetical order... +#include "stdlib/math/base/napi/quinary/ddddd_d.h" +#include "stdlib/math/base/napi/quinary/fffff_f.h" #endif // !STDLIB_MATH_BASE_NAPI_QUINARY_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/ddddd_d.h b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/ddddd_d.h new file mode 100644 index 000000000000..4957f75a1dd8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/ddddd_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_QUINARY_DDDDD_D_H +#define STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_D_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning double-precision floating-point numbers. +* +* @param fcn quinary function +* +* @example +* static double add( const double x, const double y, const double z, const double w, const double u ) { +* return x + y + z + w + u; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) \ + static napi_value stdlib_math_base_napi_ddddd_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ddddd_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ddddd_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_ddddd_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ddddd_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quinary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quinary function accepting and returning double-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/fffff_f.h b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/fffff_f.h new file mode 100644 index 000000000000..613ea3d1d37b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/fffff_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_QUINARY_FFFFF_F_H +#define STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_F_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning single-precision floating-point numbers. +* +* @param fcn quinary function +* +* @example +* static float addf( const float x, const float y, const float z, const float w, const float u ) { +* return x + y + z + w + u; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) \ + static napi_value stdlib_math_base_napi_fffff_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_fffff_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_fffff_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_fffff_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fffff_f_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quinary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quinary function accepting and returning single-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json b/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json index 04e61e361caa..8a61ed423e2a 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json @@ -25,7 +25,8 @@ "confs": [ { "src": [ - "./src/main.c" + "./src/ddddd_d.c", + "./src/fffff_f.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/src/ddddd_d.c b/lib/node_modules/@stdlib/math/base/napi/quinary/src/ddddd_d.c new file mode 100644 index 000000000000..6b3764fd3fe9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/src/ddddd_d.c @@ -0,0 +1,125 @@ +/** +* @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/quinary/ddddd_d.h" +#include +#include + +/** +* Invokes a quinary function accepting and returning double-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* - `w`: input value. +* - `u`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn quinary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ) { + napi_status status; + + size_t argc = 5; + napi_value argv[ 5 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 5 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide five numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype3; + status = napi_typeof( env, argv[ 3 ], &vtype3 ); + assert( status == napi_ok ); + if ( vtype3 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype4; + status = napi_typeof( env, argv[ 4 ], &vtype4 ); + assert( status == napi_ok ); + if ( vtype4 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Fifth argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + double z; + status = napi_get_value_double( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + double w; + status = napi_get_value_double( env, argv[ 3 ], &w ); + assert( status == napi_ok ); + + double u; + status = napi_get_value_double( env, argv[ 4 ], &u ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z, w, u ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/quinary/src/fffff_f.c similarity index 53% rename from lib/node_modules/@stdlib/math/base/napi/quinary/src/main.c rename to lib/node_modules/@stdlib/math/base/napi/quinary/src/fffff_f.c index 50c4d2c5ec42..0a618154e8ab 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/src/main.c +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/src/fffff_f.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,115 +16,10 @@ * limitations under the License. */ -#include "stdlib/math/base/napi/quinary.h" +#include "stdlib/math/base/napi/quinary/fffff_f.h" #include -#include #include -/** -* Invokes a quinary function accepting and returning double-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* - `z`: input value. -* - `w`: input value. -* - `u`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn quinary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ) { - napi_status status; - - size_t argc = 5; - napi_value argv[ 5 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 5 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide five numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype4; - status = napi_typeof( env, argv[ 4 ], &vtype4 ); - assert( status == napi_ok ); - if ( vtype4 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Fifth argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - double z; - status = napi_get_value_double( env, argv[ 2 ], &z ); - assert( status == napi_ok ); - - double w; - status = napi_get_value_double( env, argv[ 3 ], &w ); - assert( status == napi_ok ); - - double u; - status = napi_get_value_double( env, argv[ 4 ], &u ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y, z, w, u ), &v ); - assert( status == napi_ok ); - - return v; -} - /** * Invokes a quinary function accepting and returning single-precision floating-point numbers. * diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/did_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/did_d.h index a4cd08aa31bb..f23ec26c0b0e 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/did_d.h +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/did_d.h @@ -31,7 +31,7 @@ * @example * #include * -* static double fcn( const double x, const int_32 y, const double z ) { +* static double fcn( const double x, const int32_t y, const double z ) { * // ... * } * diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h index a998b146b360..269322b06c1e 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/dii_d.h @@ -31,7 +31,7 @@ * @example * #include * -* static double fcn( const double x, const int_32 y, const int_32 z ) { +* static double fcn( const double x, const int32_t y, const int32_t z ) { * // ... * } * diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h index beb97f2b3b22..e3187702c157 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iid_d.h @@ -31,7 +31,7 @@ * @example * #include * -* static double fcn( const int_32 x, const int_32 y, const double z ) { +* static double fcn( const int32_t x, const int32_t y, const double z ) { * // ... * } * diff --git a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h index 23ef1cdd6706..ea8524f19e2c 100644 --- a/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h +++ b/lib/node_modules/@stdlib/math/base/napi/ternary/include/stdlib/math/base/napi/ternary/iii_d.h @@ -31,7 +31,7 @@ * @example * #include * -* static double fcn( const int_32 x, const int_32 y, const int_32 z ) { +* static double fcn( const int32_t x, const int32_t y, const int32_t z ) { * // ... * } * 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..1da8c8ac9615 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. @@ -419,48 +484,31 @@ 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_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; +} diff --git a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.js index dfc0412ae71e..78cd38a74435 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var j0 = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = j0( x ); + y = j0( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.native.js index 8e98bee0f578..8f860019119f 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100000.0 ) - 0.0; - y = j0( x ); + y = j0( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/benchmark.c index a5225b15622a..d743fb9b1500 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/benchmark.c @@ -100,16 +100,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = j0( x ); + y = j0( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/cephes/benchmark.c index c857e91da331..66a80b9135ef 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/cephes/benchmark.c @@ -94,16 +94,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = j0( x ); + y = j0( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/native/benchmark.c index fb6e255fb836..d0f7d405c547 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/besselj0/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = 100000.0 * rand_double(); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100000.0 * rand_double() ) - 0.0; - y = stdlib_base_besselj0( x ); + y = stdlib_base_besselj0( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/besselj0/test/test.js b/lib/node_modules/@stdlib/math/base/special/besselj0/test/test.js index 5ce97679d8e0..c5ce285453e8 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj0/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/besselj0/test/test.js @@ -319,7 +319,7 @@ tape( 'the function is an even function (f(x) = f(-x))', function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = j0( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.js index 75ca49eaa217..12ec22f5c46e 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var j1 = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = j1( x ); + y = j1( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.native.js index e33590ec12e7..86da1bfc49f2 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100000.0 ) - 0.0; - y = j1( x ); + y = j1( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/benchmark.c index cb943e76334e..e3cd97a7ae37 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/benchmark.c @@ -100,16 +100,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = j1( x ); + y = j1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/cephes/benchmark.c index b1606fbdbb85..73b74fd765cc 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/cephes/benchmark.c @@ -94,16 +94,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = j1( x ); + y = j1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/native/benchmark.c index 32dbd0f894ef..9194bb2d406b 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/besselj1/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = 100000.0 * rand_double(); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100000.0 * rand_double() ) - 0.0; - y = stdlib_base_besselj1( x ); + y = stdlib_base_besselj1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/besselj1/test/test.js b/lib/node_modules/@stdlib/math/base/special/besselj1/test/test.js index fd296f3fe2ca..a46c3d5d52c7 100644 --- a/lib/node_modules/@stdlib/math/base/special/besselj1/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/besselj1/test/test.js @@ -319,7 +319,7 @@ tape( 'the function is an odd function (f(x) = -f(-x))', function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = j1( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.js index e01a94fe59d3..2d793deb859b 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var y0 = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = y0( x ); + y = y0( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.native.js index 3c66eb27156b..a2d00f840658 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100000.0 ) - 0.0; - y = y0( x ); + y = y0( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/benchmark.c index 0382a493d9d0..a43fa80b942b 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/benchmark.c @@ -100,16 +100,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = y0( x ); + y = y0( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/cephes/benchmark.c index 869c396e193d..dfae9da6bfd9 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/cephes/benchmark.c @@ -94,16 +94,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = y0( x ); + y = y0( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/native/benchmark.c index 4d283dc99378..09dde22587ff 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = 100000.0 * rand_double(); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100000.0 * rand_double() ) - 0.0; - y = stdlib_base_bessely0( x ); + y = stdlib_base_bessely0( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js b/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js index 31f3350c1100..f7b9c1d79978 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js @@ -266,7 +266,7 @@ tape( 'the function returns `NaN` for negative numbers', function test( t ) { for ( i = 0; i < 1000; i++ ) { x = -( randu() * 100.0 ) - EPS; v = y0( x ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); } t.end(); }); @@ -279,7 +279,7 @@ tape( 'the function returns `-Infintiy` if provided `0.0`', function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = y0( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -291,6 +291,6 @@ tape( 'the function returns `0.0` if provided `+infinity`', function test( t ) { tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = y0( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/benchmark.js index d6089a2d98b5..a9a084661354 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var y1 = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = y1( x ); + y = y1( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/benchmark.c index a130001cc91d..77072dac01b8 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/benchmark.c @@ -100,16 +100,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = y1( x ); + y = y1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/cephes/benchmark.c index c172e1b86c9b..df5362df8822 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/bessely1/benchmark/c/cephes/benchmark.c @@ -94,16 +94,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = y1( x ); + y = y1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js b/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js index 8ccb327be333..7344bdfe2bba 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js @@ -256,7 +256,7 @@ tape( 'the function returns `NaN` for negative numbers', function test( t ) { for ( i = 0; i < 1000; i++ ) { x = -( randu() * 100.0 ) - EPS; v = y1( x ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); } t.end(); }); @@ -269,7 +269,7 @@ tape( 'the function returns `-Infinity` if provided `0`', function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = y1( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -281,6 +281,6 @@ tape( 'the function returns `0.0` if provided `+infinity`', function test( t ) { tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = y1( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.js index 1d36e4549170..027e4e63034a 100644 --- a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var beta = require( './../lib' ); @@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) { var z; var i; + x = uniform( 100, 0.0, 1000.0 ); + y = uniform( 100, 0.0, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = ( randu()*1000.0 ) - 0.0; - z = beta( x, y ); + z = beta( x[ i % x.length ], y[ i % y.length ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.native.js index 4a0b4a47ab57..82775a1178c9 100644 --- a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) { var z; var i; + x = uniform( 100, 0.0, 1000.0 ); + y = uniform( 100, 0.0, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 1000.0 ) - 0.0; - y = ( randu() * 1000.0 ) - 0.0; - z = beta( x, y ); + z = beta( x[ i % x.length ], y[ i % y.length ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/cephes/benchmark.c index b8bd05e3906f..8433414901a4 100644 --- a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/cephes/benchmark.c @@ -94,18 +94,21 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; + double y[ 100 ]; double elapsed; - double x; - double y; double z; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = 1000.0 * rand_double(); + y[ i ]= 1000.0 * rand_double(); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) + 0.0; - y = ( 1000.0*rand_double() ) + 0.0; - z = beta( x, y ); + z = beta( x[ i%100 ], y[ i%100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/native/benchmark.c index c079551c2ecc..54bfb839fa4c 100644 --- a/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/beta/benchmark/c/native/benchmark.c @@ -90,18 +90,21 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; + double y[ 100 ]; double elapsed; - double x; - double y; double r; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_double() * 1000.0; + y[ i ]= rand_double() * 1000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( ( rand_double() * 1000.0 ) + 0.0 ); - y = ( ( rand_double() * 1000.0 ) + 0.0 ); - r = stdlib_base_beta( x, y ); + r = stdlib_base_beta( x[ i%100 ], y[ i%100 ] ); if ( r != r ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/beta/test/test.js b/lib/node_modules/@stdlib/math/base/special/beta/test/test.js index f7ba097da1b4..56b0c6d0a751 100644 --- a/lib/node_modules/@stdlib/math/base/special/beta/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/beta/test/test.js @@ -61,17 +61,17 @@ tape( 'main export is a function', function test( t ) { tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) { var val = beta( NaN, 2.0 ); - t.ok( isnan( val ), 'returns NaN' ); + t.ok( isnan( val ), 'returns expected value' ); val = beta( 2.0, NaN ); - t.ok( isnan( val ), 'returns NaN' ); + t.ok( isnan( val ), 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided negative values', function test( t ) { var val = beta( -2.0, 5.0 ); - t.ok( isnan( val ), 'returns NaN' ); + t.ok( isnan( val ), 'returns expected value' ); val = beta( 4.0, -3.0 ); - t.ok( isnan( val ), 'returns NaN' ); + t.ok( isnan( val ), 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/rsqrt/manifest.json b/lib/node_modules/@stdlib/math/base/special/rsqrt/manifest.json index 49bab5adff73..17be00eb8b97 100644 --- a/lib/node_modules/@stdlib/math/base/special/rsqrt/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/rsqrt/manifest.json @@ -1,78 +1,78 @@ { - "options": { - "task": "build" - }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "src": [ - "./src/rsqrt.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/napi/unary", - "@stdlib/math/base/special/sqrt" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/rsqrt.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/special/sqrt" - ] - }, - { - "task": "examples", - "src": [ - "./src/rsqrt.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/special/sqrt" - ] - } - ] + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/rsqrt.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/math/base/special/sqrt" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/rsqrt.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/sqrt" + ] + }, + { + "task": "examples", + "src": [ + "./src/rsqrt.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/sqrt" + ] + } + ] } diff --git a/lib/node_modules/@stdlib/math/strided/special/smskceil/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/math/strided/special/smskceil/benchmark/c/benchmark.length.c index c634a4df0243..4d183cbddc6e 100644 --- a/lib/node_modules/@stdlib/math/strided/special/smskceil/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/math/strided/special/smskceil/benchmark/c/benchmark.length.c @@ -128,6 +128,7 @@ static double benchmark( int iterations, int len ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar stdlib_strided_smskceil( len, x, 1, m, 1, y, 1 ); if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); diff --git a/lib/node_modules/@stdlib/ndarray/base/strides2offset/manifest.json b/lib/node_modules/@stdlib/ndarray/base/strides2offset/manifest.json index 890a937a3dc0..04e61e361caa 100644 --- a/lib/node_modules/@stdlib/ndarray/base/strides2offset/manifest.json +++ b/lib/node_modules/@stdlib/ndarray/base/strides2offset/manifest.json @@ -1,38 +1,38 @@ { - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/lib/node_modules/@stdlib/stats/base/README.md b/lib/node_modules/@stdlib/stats/base/README.md index 068869df4120..6fb98ba270b2 100644 --- a/lib/node_modules/@stdlib/stats/base/README.md +++ b/lib/node_modules/@stdlib/stats/base/README.md @@ -117,7 +117,7 @@ The namespace contains the following statistical functions: - [`dstdevyc( N, correction, x, strideX )`][@stdlib/stats/base/dstdevyc]: calculate the standard deviation of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. - [`dsvariance( N, correction, x, stride )`][@stdlib/stats/base/dsvariance]: calculate the variance of a single-precision floating-point strided array using extended accumulation and returning an extended precision result. - [`dsvariancepn( N, correction, x, stride )`][@stdlib/stats/base/dsvariancepn]: calculate the variance of a single-precision floating-point strided array using a two-pass algorithm with extended accumulation and returning an extended precision result. -- [`dvariance( N, correction, x, stride )`][@stdlib/stats/base/dvariance]: calculate the variance of a double-precision floating-point strided array. +- [`dvariance( N, correction, x, strideX )`][@stdlib/stats/base/dvariance]: calculate the variance of a double-precision floating-point strided array. - [`dvariancech( N, correction, x, strideX )`][@stdlib/stats/base/dvariancech]: calculate the variance of a double-precision floating-point strided array using a one-pass trial mean algorithm. - [`dvariancepn( N, correction, x, strideX )`][@stdlib/stats/base/dvariancepn]: calculate the variance of a double-precision floating-point strided array using a two-pass algorithm. - [`dvariancetk( N, correction, x, strideX )`][@stdlib/stats/base/dvariancetk]: calculate the variance of a double-precision floating-point strided array using a one-pass textbook algorithm. diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/README.md index a8e2156e839f..948041b5040e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/README.md @@ -147,6 +147,106 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/hypergeometric/skewness.h" +``` + +#### stdlib_base_dists_hypergeometric_skewness( N, K, n ) + +Returns the [skewness][skewness] of a [hypergeometric][hypergeometric-distribution] distribution with parameters `N` (population size), `K` (subpopulation size), and `n` (number of draws). + +```c +double out = stdlib_base_dists_hypergeometric_skewness( 16, 11, 4 ); +// returns ~-0.258 +``` + +The function accepts the following arguments: + +- **N**: `[in] int32_t` population size. +- **K**: `[in] int32_t` subpopulation size. +- **n**: `[in] int32_t` number of draws. + +```c +double stdlib_base_dists_hypergeometric_skewness( const int32_t N, const int32_t K, const int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/hypergeometric/skewness.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +int main( void ) { + int32_t N; + int32_t K; + int32_t n; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + N = stdlib_base_ceil( random_uniform( 10.0, 100.0 ) ); + K = stdlib_base_ceil( random_uniform( 0.0, N - 1 ) ); + n = stdlib_base_ceil( random_uniform( 0.0, N - 1 ) ); + y = stdlib_base_dists_hypergeometric_skewness( N, K, n ); + printf( "N: %d, K: %d, n: %d, skew(X;N,K,n): %lf\n", N, K, n, y ); + } +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/benchmark.native.js new file mode 100644 index 000000000000..85dc6266f039 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/benchmark.native.js @@ -0,0 +1,73 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var skewness = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( skewness instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var len; + var N; + var K; + var n; + var y; + var i; + + len = 100; + N = new Float64Array( len ); + K = new Float64Array( len ); + n = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + N[ i ] = discreteUniform( 10, 100 ); + K[ i ] = discreteUniform( 1, N[ i ] - 1 ); + n[ i ] = discreteUniform( 1, N[ i ] - 1 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = skewness( N[ i % len ], K[ i % len ], n[ i % len ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/c/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/c/benchmark.c new file mode 100644 index 000000000000..52843844ef88 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/benchmark/c/benchmark.c @@ -0,0 +1,143 @@ +/** +* @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/stats/base/dists/hypergeometric/skewness.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include +#include +#include + +#define NAME "hypergeometric-skewness" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; +} + +/** +* Generates a random number on the interval [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + int32_t N[ 100 ]; + int32_t K[ 100 ]; + int32_t n[ 100 ]; + double elapsed; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + N[ i ] = stdlib_base_ceil( random_uniform( 10.0, 100.0 ) ); + K[ i ] = stdlib_base_ceil( random_uniform( 0.0, N[ i ] - 1 ) ); + n[ i ] = stdlib_base_ceil( random_uniform( 0.0, N[ i ] - 1 ) ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_hypergeometric_skewness( N[ i%100 ], K[ i%100 ], n[ i%100 ] ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i + 1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/binding.gyp @@ -0,0 +1,170 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/examples/c/example.c new file mode 100644 index 000000000000..446b6f238362 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/examples/c/example.c @@ -0,0 +1,44 @@ +/** +* @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/stats/base/dists/hypergeometric/skewness.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +int main( void ) { + int32_t N; + int32_t K; + int32_t n; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + N = stdlib_base_ceil( random_uniform( 10.0, 100.0 ) ); + K = stdlib_base_ceil( random_uniform( 0.0, N - 1 ) ); + n = stdlib_base_ceil( random_uniform( 0.0, N - 1 ) ); + y = stdlib_base_dists_hypergeometric_skewness( N, K, n ); + printf( "N: %d, K: %d, n: %d, skew(X;N,K,n): %lf\n", N, K, n, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/include.gypi @@ -0,0 +1,53 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' + +/* +* 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 + +/** +* Returns the skewness of a hypergeometric distribution. +*/ +double stdlib_base_dists_hypergeometric_skewness( const int32_t N, const int32_t K, const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_STATS_BASE_DISTS_HYPERGEOMETRIC_SKEWNESS_H diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/lib/native.js new file mode 100644 index 000000000000..9e6d3aae8bd8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/lib/native.js @@ -0,0 +1,64 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Returns the skewness of a hypergeometric distribution. +* +* @private +* @param {NonNegativeInteger} N - population size +* @param {NonNegativeInteger} K - subpopulation size +* @param {NonNegativeInteger} n - number of draws +* @returns {number} skewness +* +* @example +* var v = skewness( 16, 11, 4 ); +* // returns ~-0.258 +* +* @example +* var v = skewness( 4, 2, 2 ); +* // returns 0.0 +* +* @example +* var v = skewness( 10, 5, 12 ); +* // returns NaN +* +* @example +* var v = skewness( 20, -2, 10 ); +* // returns NaN +* +* @example +* var v = skewness( -2, 4, 2 ); +* // returns NaN +*/ +function skewness( N, K, n ) { + return addon( N, K, n ); +} + + +// EXPORTS // + +module.exports = skewness; diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/manifest.json new file mode 100644 index 000000000000..4229e8aea358 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/manifest.json @@ -0,0 +1,78 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/ternary", + "@stdlib/math/base/special/sqrt" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/ceil" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/ceil" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/package.json b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/package.json index dbc7e3b912c2..6a6c420510de 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/package.json +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/Makefile @@ -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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/addon.c new file mode 100644 index 000000000000..b3ec787738e9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/addon.c @@ -0,0 +1,23 @@ +/** +* @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/stats/base/dists/hypergeometric/skewness.h" +#include "stdlib/math/base/napi/ternary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_III_D( stdlib_base_dists_hypergeometric_skewness ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/main.c new file mode 100644 index 000000000000..88c3416a1406 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/src/main.c @@ -0,0 +1,51 @@ +/** +* @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/stats/base/dists/hypergeometric/skewness.h" +#include "stdlib/math/base/special/sqrt.h" +#include + +/** +* Returns the skewness of a hypergeometric distribution. +* +* @param N population size +* @param K subpopulation size +* @param n number of draws +* @return skewness +* +* @example +* double skew = stdlib_base_dists_hypergeometric_skewness( 16, 11, 4 ); +* // returns ~-0.258 +*/ +double stdlib_base_dists_hypergeometric_skewness( const int32_t N, const int32_t K, const int32_t n ) { + double N_d; + double K_d; + double n_d; + double p; + double q; + + if ( N < 0 || K < 0 || n < 0 || K > N || n > N ) { + return 0.0/0.0; // NaN + } + N_d = (double)N; + K_d = (double)K; + n_d = (double)n; + p = ( N_d - ( 2.0*K_d ) ) * stdlib_base_sqrt( N_d-1.0 ) * ( N_d - ( 2.0*n_d ) ); + q = stdlib_base_sqrt( n_d * K_d * ( N_d-K_d ) * ( N_d-n_d ) ) * ( N_d-2.0 ); + return p / q; +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/test/test.native.js new file mode 100644 index 000000000000..a7e44cfd484d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/test/test.native.js @@ -0,0 +1,113 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); + + +// VARIABLES // + +var skewness = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( skewness instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof skewness, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided an `N` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var v; + + v = skewness( -2, 4, 2 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = skewness( -1, 4, 2 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided an `K` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var y; + + y = skewness( 20, -2, 10 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = skewness( 20, -1, 10 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var y; + + y = skewness( 40, 20, -2 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = skewness( 40, 20, -1 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns the skewness of a hypergeometric distribution', opts, function test( t ) { + var expected; + var delta; + var tol; + var N; + var K; + var n; + var y; + var i; + + expected = data.expected; + N = data.N; + K = data.K; + n = data.n; + for ( i = 0; i < n.length; i++ ) { + y = skewness( N[i], K[i], n[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'N: '+N[i]+', K: '+K[i]+', n: '+n[i]+', y: '+y+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 1.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. N: '+N[i]+'. K: '+K[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/README.md b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/README.md index 9cf84e3e486d..4c3186c0e150 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/README.md @@ -147,6 +147,106 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/hypergeometric/stdev.h" +``` + +#### stdlib_base_dists_hypergeometric_stdev( N, K, n ) + +Returns the [standard deviation][standard-deviation] of a [hypergeometric][hypergeometric-distribution] distribution with parameters `N` (population size), `K` (subpopulation size), and `n` (number of draws). + +```c +double out = stdlib_base_dists_hypergeometric_stdev( 16, 11, 4 ); +// returns ~0.829 +``` + +The function accepts the following arguments: + +- **N**: `[in] int32_t` population size. +- **K**: `[in] int32_t` subpopulation size. +- **n**: `[in] int32_t` number of draws. + +```c +double stdlib_base_dists_hypergeometric_stdev( const int32_t N, const int32_t K, const int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/hypergeometric/stdev.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +int main( void ) { + double sd; + int32_t N; + int32_t K; + int32_t n; + int i; + + for ( i = 0; i < 10; i++ ) { + N = stdlib_base_ceil( random_uniform( 2.0, 100.0 ) ); + K = stdlib_base_ceil( random_uniform( 0.0, N ) ); + n = stdlib_base_ceil( random_uniform( 0.0, N ) ); + sd = stdlib_base_dists_hypergeometric_stdev( N, K, n ); + printf( "N: %d, K: %d, n: %d, SD(X;N,K,n): %lf\n", N, K, n, sd ); + } +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.js index 3748de866b14..6083dc09683c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.js @@ -43,9 +43,9 @@ bench( pkg, function benchmark( b ) { K = new Float64Array( len ); n = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - N[ i ] = discreteUniform( 1, 100 ); - K[ i ] = discreteUniform( 1, N[ i ] ); - n[ i ] = discreteUniform( 1, N[ i ] ); + N[ i ] = discreteUniform( 2, 100 ); + n[ i ] = discreteUniform( 0, N[ i ] ); + K[ i ] = discreteUniform( 0, N[ i ] ); } b.tic(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.native.js new file mode 100644 index 000000000000..ce85da0b6356 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/benchmark.native.js @@ -0,0 +1,73 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var stdev = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( stdev instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var len; + var N; + var K; + var n; + var y; + var i; + + len = 100; + N = new Float64Array( len ); + K = new Float64Array( len ); + n = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + N[ i ] = discreteUniform( 2, 100 ); + n[ i ] = discreteUniform( 0, N[ i ] ); + K[ i ] = discreteUniform( 0, N[ i ] ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = stdev( N[ i % len ], K[ i % len ], n[ i % len ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/c/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/c/benchmark.c new file mode 100644 index 000000000000..2fca54278b58 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/benchmark/c/benchmark.c @@ -0,0 +1,143 @@ +/** +* @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/stats/base/dists/hypergeometric/stdev.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include +#include +#include + +#define NAME "hypergeometric-stdev" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; +} + +/** +* Generates a random number on the interval [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + int32_t N[ 100 ]; + int32_t K[ 100 ]; + int32_t n[ 100 ]; + double elapsed; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + N[ i ] = stdlib_base_ceil( random_uniform( 2.0, 100.0 ) ); + K[ i ] = stdlib_base_ceil( random_uniform( 0.0, N[ i ] ) ); + n[ i ] = stdlib_base_ceil( random_uniform( 0.0, N[ i ] ) ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_hypergeometric_stdev( N[ i%100 ], K[ i%100 ], n[ i%100 ] ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i + 1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/binding.gyp @@ -0,0 +1,170 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/examples/c/example.c new file mode 100644 index 000000000000..7bd17ac3f89d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/examples/c/example.c @@ -0,0 +1,44 @@ +/** +* @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/stats/base/dists/hypergeometric/stdev.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +int main( void ) { + double sd; + int32_t N; + int32_t K; + int32_t n; + int i; + + for ( i = 0; i < 10; i++ ) { + N = stdlib_base_ceil( random_uniform( 2.0, 100.0 ) ); + K = stdlib_base_ceil( random_uniform( 0.0, N ) ); + n = stdlib_base_ceil( random_uniform( 0.0, N ) ); + sd = stdlib_base_dists_hypergeometric_stdev( N, K, n ); + printf( "N: %d, K: %d, n: %d, SD(X;N,K,n): %lf\n", N, K, n, sd ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/include.gypi @@ -0,0 +1,53 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' + +/* +* 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 + +/** +* Returns the standard deviation of a hypergeometric distribution. +*/ +double stdlib_base_dists_hypergeometric_stdev( const int32_t N, const int32_t K, const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_STATS_BASE_DISTS_HYPERGEOMETRIC_STDEV_H diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/lib/native.js new file mode 100644 index 000000000000..3d91993f46e0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/lib/native.js @@ -0,0 +1,68 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Returns the standard deviation of a hypergeometric distribution. +* +* @private +* @param {NonNegativeInteger} N - population size +* @param {NonNegativeInteger} K - subpopulation size +* @param {NonNegativeInteger} n - number of draws +* @returns {NonNegativeNumber} standard deviation +* +* @example +* var v = stdev( 16, 11, 4 ); +* // returns ~0.829 +* +* @example +* var v = stdev( 2, 1, 1 ); +* // returns 0.5 +* +* @example +* var v = stdev( 10, 5, 12 ); +* // returns NaN +* +* @example +* var v = stdev( -2, 4, 2 ); +* // returns NaN +* +* @example +* var v = stdev( 20, -2, 10 ); +* // returns NaN +* +* @example +* var v = stdev( 40, 20, -2 ); +* // returns NaN +*/ +function stdev( N, K, n ) { + return addon( N, K, n ); +} + + +// EXPORTS // + +module.exports = stdev; diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/manifest.json new file mode 100644 index 000000000000..4229e8aea358 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/manifest.json @@ -0,0 +1,78 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/ternary", + "@stdlib/math/base/special/sqrt" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/ceil" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/sqrt", + "@stdlib/math/base/special/ceil" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/package.json b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/package.json index 96ea8621b50a..5ae33f59b661 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/package.json +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/Makefile @@ -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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/addon.c new file mode 100644 index 000000000000..45a90cc2da28 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/addon.c @@ -0,0 +1,23 @@ +/** +* @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/stats/base/dists/hypergeometric/stdev.h" +#include "stdlib/math/base/napi/ternary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_III_D( stdlib_base_dists_hypergeometric_stdev ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/main.c new file mode 100644 index 000000000000..41d0ce981fc2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/src/main.c @@ -0,0 +1,45 @@ +/** +* @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/stats/base/dists/hypergeometric/stdev.h" +#include "stdlib/math/base/special/sqrt.h" +#include + +/** +* Returns the standard deviation of a hypergeometric distribution. +* +* @param N population size +* @param K subpopulation size +* @param n number of draws +* @return standard deviation +* +* @example +* double sd = stdlib_base_dists_hypergeometric_stdev( 16, 11, 4 ); +* // returns ~0.829 +*/ +double stdlib_base_dists_hypergeometric_stdev( const int32_t N, const int32_t K, const int32_t n ) { + double variance; + double p; + + if ( N < 0 || K < 0 || n < 0 || K > N || n > N ) { + return 0.0/0.0; // NaN + } + p = (double)K / (double)N; + variance = n * p * ( 1.0-p ) * ( (double)(N-n)/(double)(N-1) ); + return stdlib_base_sqrt( variance ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/test/test.native.js new file mode 100644 index 000000000000..8d25286e7138 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/stdev/test/test.native.js @@ -0,0 +1,113 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); + + +// VARIABLES // + +var stdev = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( stdev instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof stdev, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided an `N` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var v; + + v = stdev( -2, 4, 2 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = stdev( -1, 4, 2 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided an `K` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var y; + + y = stdev( 20, -2, 10 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = stdev( 20, -1, 10 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', opts, function test( t ) { + var y; + + y = stdev( 40, 20, -2 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = stdev( 40, 20, -1 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns the standard deviation of a hypergeometric distribution', opts, function test( t ) { + var expected; + var delta; + var tol; + var N; + var K; + var n; + var y; + var i; + + expected = data.expected; + N = data.N; + K = data.K; + n = data.n; + for ( i = 0; i < n.length; i++ ) { + y = stdev( N[i], K[i], n[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'N: '+N[i]+', K: '+K[i]+', n: '+n[i]+', y: '+y+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 2.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. N: '+N[i]+'. K: '+K[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md index f00b69fe23d3..982acffb5e2c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md @@ -120,6 +120,98 @@ for ( i = 0; i < lambda.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/planck/entropy.h" +``` + +#### stdlib_base_dists_planck_entropy( lambda ) + +Returns the [differential entropy][entropy] of a Planck distribution with shape parameter `lambda` (in [nats][nats]). + +```c +double out = stdlib_base_dists_planck_entropy( 1.5 ); +// returns ~0.6833 +``` + +The function accepts the following arguments: + +- **lambda**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_planck_entropy( const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/planck/entropy.h" +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +int main( void ) { + double lambda; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + lambda = random_uniform( 0.1, 5.0 ); + y = stdlib_base_dists_planck_entropy( lambda ); + printf( "λ: %lf, H(X;λ): %lf\n", lambda, y ); + } +} +``` + +
+ + + +
+ + +