Skip to content

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

Draft
Neerajpathak07 wants to merge 1 commit intostdlib-js:developfrom
Neerajpathak07:add-betainc
Draft

feat: add C implementation for math/base/special/betainc#4037
Neerajpathak07 wants to merge 1 commit intostdlib-js:developfrom
Neerajpathak07:add-betainc

Conversation

@Neerajpathak07
Copy link
Copy Markdown
Member

@Neerajpathak07 Neerajpathak07 commented Dec 18, 2024

Progresses #649
Resolves #3423

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
Copy link
Copy Markdown
Contributor

Hey @Neerajpathak07, was reviewing this since it depends on kernel-betainc which I have 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!

3 similar comments
@rautelaKamal
Copy link
Copy Markdown
Contributor

Hey @Neerajpathak07, was reviewing this since it depends on kernel-betainc which I have 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
Copy link
Copy Markdown
Contributor

Hey @Neerajpathak07, was reviewing this since it depends on kernel-betainc which I have 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
Copy link
Copy Markdown
Contributor

Hey @Neerajpathak07, was reviewing this since it depends on kernel-betainc which I have 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!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

⚠️ 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
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.

[RFC]: Add C implementation for @stdlib/stats/base/dists/beta/cdf

4 participants