Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for erf and erfc for f16, f32, f64, f128 #136321

Open
4 tasks
tgross35 opened this issue Jan 30, 2025 · 7 comments
Open
4 tasks

Tracking Issue for erf and erfc for f16, f32, f64, f128 #136321

tgross35 opened this issue Jan 30, 2025 · 7 comments
Assignees
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

tgross35 commented Jan 30, 2025

Feature gate: #![feature(float_erf)]

This is a tracking issue for the error function (erf) and complementary error function (erfc) in std. These functions are provided by libm and are also exposed in C's math.h (reference).

Public API

// in std, for now

impl f16 {
    pub fn erf(self) -> Self;
    pub fn erfc(self)-> Self;
}

impl f32 {
    pub fn erf(self) -> Self;
    pub fn erfc(self)-> Self;
}

impl f64 {
    pub fn erf(self) -> Self;
    pub fn erfc(self)-> Self;
}

impl f128 {
    pub fn erf(self) -> Self;
    pub fn erfc(self)-> Self;
}   

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@tgross35 tgross35 added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 30, 2025
@tgross35
Copy link
Contributor Author

If anyone is interested in adding these, feel free to do so. The extern functions need to be added at https://github.com/rust-lang/rust/blob/6ac88786155774da429213a1362d4cb085047af3/library/std/src/sys/cmath.rs, then the API at https://github.com/rust-lang/rust/blob/6ac88786155774da429213a1362d4cb085047af3/library/std/src/f64.rs (and other float files) will call them, similar to gamma.

@rustbot label +E-easy

@rustbot rustbot added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jan 30, 2025
@GrigorenkoPV
Copy link
Contributor

The signatures look very wrong. I guess the functions in impl f64 should take an f64 and not an f32, etc. Those just look like a typo.

A less trivial question is, shouldn't they all take self instead of x: Self? To be consistent with gamma and the rest.

Anyways, don't mind if I do,
@rustbot claim

@tgross35
Copy link
Contributor Author

Oh woah yeah, I was looking at math.h and confused myself on the signatures. Updated.

@kennytm
Copy link
Member

kennytm commented Jan 31, 2025

As I mentioned in the other ACP (rust-lang/libs-team#352), stabilization of {f32, f64}::{erf, erfc} should also consider the status of {f32, f64}::{gamma, ln_gamma} #99842. Both features are going to link to libm (or contains of copy of its implementation) and thus subject to #26350.

@foxtrotactive
Copy link

Hi, could I take a stab at this? Would be happy to help out where needed

@tgross35
Copy link
Contributor Author

@GrigorenkoPV already has a PR up at #136324 (commenting @rustbot claim assigns the PR to you) so there won't be much left to do here. But thank you for the interest! If you are looking to get involved, looking at issues labeled E-easy and/or E-help-wanted that don't have anyone assigned is the best way to find something to do.

@foxtrotactive
Copy link

foxtrotactive commented Jan 31, 2025

Great thanks a lot @tgross35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants