feat: add C implementation for stats/base/dists/negative-binomial/logpmf#10132
feat: add C implementation for stats/base/dists/negative-binomial/logpmf#10132nirmaljb wants to merge 6 commits intostdlib-js:developfrom
stats/base/dists/negative-binomial/logpmf#10132Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- task: lint_c_benchmarks
status: missing_dependencies
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- task: lint_c_benchmarks
status: missing_dependencies
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: missing_dependencies
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
… snippet
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
| result *= sqrt( bgh / STDLIB_CONSTANT_FLOAT64_E ); | ||
| result *= sqrt( agh / cgh ); |
There was a problem hiding this comment.
The header stdlib/math/base/special/sqrt.h is included and @stdlib/math/base/special/sqrt is listed as a dependency, yet the raw sqrt() from libc is called instead of stdlib_base_sqrt.
| result *= sqrt( bgh / STDLIB_CONSTANT_FLOAT64_E ); | |
| result *= sqrt( agh / cgh ); | |
| result *= stdlib_base_sqrt( bgh / STDLIB_CONSTANT_FLOAT64_E ); | |
| result *= stdlib_base_sqrt( agh / cgh ); |
| #include "stdlib/math/base/napi/ternary.h" | ||
|
|
||
| // cppcheck-suppress shadowFunction | ||
| STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_negative_binomial_logpmf ); |
There was a problem hiding this comment.
Drop the trailing semicolon — stdlib convention omits it, as in beta/logpdf/src/addon.c, gamma/logpdf/src/addon.c, etc.
| STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_negative_binomial_logpmf ); | |
| STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_negative_binomial_logpmf ) |
| /** | ||
| * Evaluates the natural logarithm of the probability mass function (PMF) for a negative binomial distribution with number of successes until experiment is stopped `r` and success probability `p`. | ||
| * | ||
| * @param {number} x - input value |
There was a problem hiding this comment.
Missing @private tag. Add it to match the convention used by all other native.js wrappers.
| "@stdlib/math/base/assert/is-nonnegative-integer", | ||
| "@stdlib/math/base/special/ln", | ||
| "@stdlib/constants/float64/ninf" | ||
| ] |
There was a problem hiding this comment.
example.c calls stdlib_base_ceil, but @stdlib/math/base/special/ceil is absent from the examples conf dependencies here. Add it so the example builds correctly.
| int32_t i; | ||
|
|
||
| for ( i = 0; i < 100; i++ ) { | ||
| x[ i ] = random_uniform( 1.0, 100.0 ); |
There was a problem hiding this comment.
logpmf requires a non-negative integer x; random_uniform( 1.0, 100.0 ) produces non-integers, causing every call to return -Infinity — the actual algorithm is never exercised. The y != y guard does not catch -Infinity. Wrap the result in stdlib_base_ceil() and add the corresponding include and manifest dependency, matching poisson/logpmf/benchmark/c/benchmark.c.
| * @private | ||
| * @param {NonNegativeNumber} a - function parameter | ||
| * @param {NonNegativeNumber} b - function parameter | ||
| * @param {Probability} x - function parameter | ||
| * @param {Probability} y - probability equal to `1-x` | ||
| * @param {boolean} normalized - boolean indicating whether to evaluate the power terms of the regularized or non-regularized incomplete beta function | ||
| * @returns {number} power terms |
There was a problem hiding this comment.
This JSDoc block is copied verbatim from the JS source: it uses {type} braces, dash separators, @private, and @returns. Rewrite in C JSDoc style — no type braces, no leading dash, @return (singular), space-aligned parameter descriptions.
| * @param x - input value (0 < x <= 1) | ||
| * @param a - first parameter | ||
| * @param b - second parameter (must be greater than 1) | ||
| * @returns value of the partial derivative |
There was a problem hiding this comment.
The @param and @returns tags use tab characters before the parameter name rather than space alignment, and @returns should be @return (singular). Also remove the - separator between parameter name and description. Same issue applies to the JSDoc block on lines 252–256. Follow the C JSDoc convention used throughout the rest of the codebase.
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves #3762.
Description
This pull request:
Related Issues
This pull request has the following related issues:
@stdlib/stats/base/dists/negative-binomial/logpmf#3762Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers