Skip to content

feat: add C implementation for math/base/special/betainc - #4037

Merged
Planeshifter merged 14 commits into
stdlib-js:developfrom
Neerajpathak07:add-betainc
Jul 22, 2026
Merged

Planeshifter merged 14 commits into
stdlib-js:developfrom
Neerajpathak07:add-betainc

Conversation

@Neerajpathak07

@Neerajpathak07 Neerajpathak07 commented Dec 18, 2024 •

Copy link
Copy Markdown
Member

Progresses #649

Description

What is the purpose of this pull request?

This pull request:

  • adds C implementation for math/base/special/betainc

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Dec 18, 2024
@Neerajpathak07

Copy link
Copy Markdown
Member Author

This PR will need the C implementation for math/base/special/kernel-betainc to be merged to develop.

@Neerajpathak07

Copy link
Copy Markdown
Member Author

Reference:-
image

@rautelaKamal

Copy link
Copy Markdown
Contributor

Hey @Neerajpathak07, was reviewing this since it depends on kernel-betainc which I've been following closely. Found a few things in src/main.c that might block compilation:

Line 52 uses double out = [ 0.0, 0.0 ] which is JS syntax - in C this would need to be separate variable declarations like double out; double deriv;

Lines 53-54 redeclare regularized and upper, which are already function parameters - compiler will error there.

Line 55 calls stdlib_base_kernelBetainc but the actual C function in #10279 is stdlib_base_kernel_betainc (snake_case), and it expects pointer arguments (&out, &deriv) rather than array and stride.

The header include on line 27 should be kernel_betainc.h instead of kernelbetainc.h.

Also minor - the @returns JSDoc says "natural logarithm of beta function" but the function returns the incomplete beta value, worth updating to avoid confusion.

Hope this helps move things forward!

@rautelaKamal

This comment was marked as duplicate.

3 similar comments
@rautelaKamal

This comment was marked as duplicate.

@rautelaKamal

This comment was marked as duplicate.

@rautelaKamal

This comment was marked as duplicate.

@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

⚠️ Issue Reference Review

An automated check found a potentially unrelated issue/PR reference in this PR:

Reference Assessment Reasoning
#3423 suspicious PR adds math/base/special/betainc (the regularized incomplete beta function), but #3423 is an RFC specifically requesting a C implementation for the stats/base/dists/beta/cdf package (different directory, different RFC requirements). While betainc is the underlying mathematical implementation of the beta CDF, the RFC requires adding C source, native addon, tests, benchmarks, and examples to the stats/base/dists/beta/cdf package itself — which this PR does not appear to do.

Why this matters: GitHub automatically closes issues referenced with closing keywords (Resolves, Closes, Fixes) when the PR is merged. If Resolves #3423 is merged, the stats/base/dists/beta/cdf RFC would be automatically closed even though that package's C implementation hasn't been added yet.

What to do:

  • If this PR truly resolves the stats/base/dists/beta/cdf RFC in full (i.e., it also adds C implementation, native addon, benchmarks, and examples to that package), then no action is needed.
  • If this PR only adds math/base/special/betainc (a prerequisite/dependency of stats/base/dists/beta/cdf), consider changing Resolves #3423 to Progresses #3423 or Related to #3423 to avoid accidentally closing the RFC.

This assessment was generated by an AI model and is informational only.

Generated by Check PR Issue References · ◷

@github-actions github-actions Bot mentioned this pull request Apr 5, 2026
@Neerajpathak07

Copy link
Copy Markdown
Member Author

@rautelaKamal why do we have multiple duplicate comments here correct me if I am mistaken here but are you using any LLM's to perform code reviews?

Comment thread lib/node_modules/@stdlib/math/base/special/betainc/src/main.c Outdated
@0PrashantYadav0

Copy link
Copy Markdown
Member

Hi @Neerajpathak07 , since PR #10279 is merged now I think you can move ahead with implementation of math/base/special/betainc. Few of my PR depends on these.

Neerajpathak07 and others added 7 commits July 10, 2026 11:58
---
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: 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
---
---
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: 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
---
---
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: 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
---
---
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: 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
---
The current file contents are non-standard and caused an infinite loop: when node-gyp processed binding.gyp, it included include.gypi, which included include.gypi...

Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
@Planeshifter

Copy link
Copy Markdown
Member

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jul 17, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jul 17, 2026
@Neerajpathak07
Neerajpathak07 marked this pull request as ready for review July 17, 2026 05:29
@Neerajpathak07
Neerajpathak07 requested a review from a team July 17, 2026 05:29
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jul 17, 2026
@Neerajpathak07

Neerajpathak07 commented Jul 17, 2026 •

Copy link
Copy Markdown
Member Author

@Planeshifter accidently marked this open. I am on the changes and testing those to resolve the 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: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: 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
---
@stdlib-bot

stdlib-bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/betainc $\\color{green}170/170$
$\\color{green}+0.00\\%$
$\\color{green}13/13$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}170/170$
$\\color{green}+0.00\\%$

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_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: 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
---
@Neerajpathak07

Copy link
Copy Markdown
Member Author

Since Lint failure is not related to changes in this PR. I'll go ahead and request a review.

@Neerajpathak07

Copy link
Copy Markdown
Member Author

@Planeshifter Can we try and land this in the following week so as to unblock beta and binomial distributions.

Comment thread lib/node_modules/@stdlib/math/base/special/betainc/src/main.c Outdated
Comment thread lib/node_modules/@stdlib/math/base/special/betainc/src/main.c Outdated
- fix invalid arity in main.c doc example and use const bool params
- remove dead no-op boolean coercion in main.c
- use scalar out variable instead of 2-element array in main.c
- fix TAP label (c::cephes -> c::native) and benchmark default variant in C benchmark
- add explicit-variant benchmarks to benchmark.native.js matching labels
- remove stale wasm fields from manifest.json
- fix README C example annotation and signature, remove stray blank line
- reorder VARIABLES/FIXTURES sections and use t.strictEqual in test.native.js
- mirror main.js boolean coercion semantics in native.js
- add missing blank line after include guard in header

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to do significant clean-up, but should be good to go now.

Note: We need to ensure the license comments are accurate; in this case, since this package is a thin wrapper around kernel-betainc, I removed the license comment and LICENSE file. But notice they were inconsistent with each other and incorrect.

Also, the EditorConfig lint failures were due to the changes in this PR, see a77b061 which caused the checkmark to turn green.

@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jul 22, 2026
@stdlib-bot

stdlib-bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Commit Message

feat: add C implementation for `math/base/special/betainc`

PR-URL: https://github.com/stdlib-js/stdlib/pull/4037
Ref: https://github.com/stdlib-js/stdlib/issues/649

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Co-authored-by: stdlib-bot <noreply@stdlib.io>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>

Please review the above commit message and make any necessary adjustments.

⚠️ Action Required: This PR references tracking issues. Please update the PR description to replace any "Closes", "Fixes", or "Resolves" keywords with "Ref" when referencing these issues.

@Planeshifter
Planeshifter merged commit 455dad2 into stdlib-js:develop Jul 22, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants