Skip to content

feat: add C implementation for math/base/special/betaincinv - #15384

Open
Planeshifter wants to merge 2 commits into
philipp/kernel-betaincinv-cfrom
philipp/betaincinv-c
Open

Planeshifter wants to merge 2 commits into
philipp/kernel-betaincinv-cfrom
philipp/betaincinv-c

Conversation

@Planeshifter

@Planeshifter Planeshifter commented Sep 21, 2026

Copy link
Copy Markdown
Member

Resolves stdlib-js/metr-issue-tracker#1234.

Description

What is the purpose of this pull request?

This pull request:

  • adds a C/native implementation for @stdlib/math/base/special/betaincinv

The C implementation delegates to kernel-betaincinv for numerical inversion, mirroring the JavaScript implementation. The public function handles parameter validation (NaN, domain checks, complement handling) and returns the primary inverse value.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written primarily by Claude Code under my direction.


@stdlib-js/reviewers

This commit adds a C/native implementation for the inverse of the
regularized incomplete beta function. The C implementation delegates
to the kernel-betaincinv C implementation for numerical inversion.

The following files are added or modified:
- Public header (betaincinv.h)
- C implementation (src/main.c) delegating to kernel_betaincinv
- Native add-on (src/addon.c)
- Build configuration (binding.gyp, include.gypi, manifest.json)
- Native JavaScript wrapper (lib/native.js)
- Native JavaScript benchmark (benchmark/benchmark.native.js)
- C benchmark (benchmark/c/native/)
- C example (examples/c/)
- Native tests (test/test.native.js)
- README C API documentation
- Updated package.json with gypfile and native directories

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---
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: 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: passed
  - task: lint_c_examples
    status: passed
  - task: lint_c_benchmarks
    status: passed
  - 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 added the Math Issue or pull request specific to math functionality. label Sep 21, 2026
@Planeshifter
Planeshifter added this pull request to stack #15385 September 21, 2026 04:49
@stdlib-bot

stdlib-bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/betaincinv $\\color{green}189/189$
$\\color{green}+0.00\\%$
$\\color{green}17/17$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}189/189$
$\\color{green}+0.00\\%$
math/base/special/kernel-betaincinv $\\color{red}2616/3235$
$\\color{green}+80.87\\%$
$\\color{red}116/170$
$\\color{green}+68.24\\%$
$\\color{red}24/38$
$\\color{green}+63.16\\%$
$\\color{red}2616/3235$
$\\color{green}+80.87\\%$

The above coverage report was generated for the changes in this PR.

@Planeshifter
Planeshifter marked this pull request as ready for review September 21, 2026 04:58
@Planeshifter
Planeshifter requested a review from a team September 21, 2026 04:58
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 21, 2026
- Add missing `@stdlib/constants/float64/eps` to benchmark task
  dependencies in manifest.json (the C benchmark uses it)
- Rename benchmark callback parameter from `b` to `assert` to
  avoid shadowing the shape-parameter variable `b`, matching
  the convention used in sibling packages

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---
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: 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
---
@Planeshifter Planeshifter changed the title feat: add C implementation for math/base/special/betaincinv feat: add C implementation for math/base/special/betaincinv Sep 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add a C implementation for math/base/special/betaincinv

2 participants