-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add error functions (erf
, erfc
) to the f32
/f64
API.
#352
Comments
erf
, erfc
) to the f32
/f64
API.
IMO the only reason to add extern "C" {
fn erf(x: f64) -> f64;
}
...
impl f64 {
pub fn erf(self) -> Self {
unsafe { cmath::erf(self) }
}
} POSIX also defined the Bessel functions ( The gamma functions (rust-lang/rust#99842) are still not stable yet. But rust-lang/rust#26350 explicitly mentioned |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@kennytm all valid points. |
Cc @workingjubilee, since you usually have useful opinions on floating point stuff. :) |
Can someone offer a clarifying explanation of why I admit that I agree that |
Elementary functions like
IMO if we accept (stabilize) |
👀 this ACP should better be closed as duplicate of #89. |
Proposal
Problem statement
The
f32
/f64
APIs are missing some useful functions, namelyerf
anderfc
, such as inlibm
(where the currentgamma
function is from I believe) or the C++ Faddeeva library.Motivating examples or use cases
The error function is used in numerous areas of scientific computing, such as statistics where the CDF of the Normal Distribution can be written in terms of it:
Solution sketch
As far as I can tell, the float functions are already from the libm crate, and
erf
,erfc
have just been skipped for some reason.Alternatives
There are obviously multiple ways to implement integrals numerically, but if the gamma function from libm was good enough, I don't see why the error function wouldn't be.
Another alternative is to port the Faddeeva library from C++ (released under an MIT licence).
Links and related work
f32
andf64
libm
cratelibm
error functionThe text was updated successfully, but these errors were encountered: