feat: add C implementation for stats/base/dists/f/pdf#11201
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
Just a quick heads up regarding the minor coverage drop flagged by Codecov: The native.js file is showing 0% function coverage because the addon.node binary correctly skips compilation during the CI coverage step, which triggers the expected opts.skip = true fallback inside test.native.js. The math logic is fully tested and verified when the native addon actually builds! Also, the drop in ibeta_power_terms.js relates to the original pure JavaScript implementations and was untouched in this PR. @Planeshifter |
|
@rautelaKamal FYI: I think you have misunderstood what we do for adding native implementation. Here we expect to add the corresponding C files for benchmark, examples and the main implementation alongside the relevant dependencies and documentations. |
|
@Neerajpathak07 Thank you for catching this and pointing me to the reference PR! I totally misunderstood the scope, I was focused solely on evaluating the N-API/Node.js boundary and completely neglected the standalone C ecosystem deliverables. I have just pushed an update that adds the benchmark/c/ and examples/c/ directories, the src/Makefile for cleanup, and the full C APIs documentation section in the README.md. Really appreciate you taking the time to explain the standard.Please let me know if there's anything else I missed! |
|
@rautelaKamal Update your commit message
to the following
|
9744905 to
197e55f
Compare
8be84d0 to
4bf98b2
Compare
4bf98b2 to
68e429f
Compare
e73fb48 to
0f35a65
Compare
b97480f to
647e413
Compare
The C usage example in both the README and the `src/main.c` `@example`
annotated `stdlib_base_dists_f_pdf( 2.0, 1.0, 1.0 )` as returning
`~0.127`, but the correct value is `~0.075`. Since CI does not execute
C example comments, the error would otherwise ship. A baseline
assertion mirroring the corrected value is added to the native test to
guard against regressions.
---
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_pkg_readmes
status: passed
- task: lint_markdown_docs
status: na
- 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: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
The native C implementation computes the log-PDF via betaln+exp, which
differs from the JS reference value by 2 ULP for pdf(2,1,1). The baseline
assertion used a 1-ULP tolerance, causing the native test to fail in CI.
---
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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- 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: passed
- 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
---
647e413 to
2ff7ac9
Compare
stats/base/dists/f/pdf
Planeshifter
left a comment
There was a problem hiding this comment.
Last but not least, let's land this PR of yours, @rautelaKamal!
PR Commit MessagePlease review the above commit message and make any necessary adjustments. |
Description
This pull request:
@stdlib/stats/base/dists/f/pdf).include.gypi,binding.gyp, andmanifest.jsondependencies via internal N-API mechanisms (STDLIB_MATH_BASE_NAPI_MODULE_DDD_D).NaN.test.native.jsfixtures to validate the C-port accuracy and benchmarks it.Related Issues
This pull request has no related issues.
Questions
No.
Other
This is a Proof of Concept submission towards my GSoC 2026 application regarding porting distributions and specific math functions to high-performance C native addons.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers