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

add more mathematical functions to the standard library #17007

Closed
vks opened this issue Sep 5, 2014 · 6 comments
Closed

add more mathematical functions to the standard library #17007

vks opened this issue Sep 5, 2014 · 6 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@vks
Copy link
Contributor

vks commented Sep 5, 2014

The following special functions are essential for basic statistics. See [1] for an argumentation why they should be included in any standard library. They are implemented in the Cephes library [2]:

/* Regularized incomplete beta function */
double incbet(double a, double b, double x);

/* Inverse of incomplete beta integral */
double incbi(double a, double b, double y);

/* Regularized incomplete gamma integral */
double igam(double a, double x);

/* Complemented incomplete gamma integral */
double igamc(double a, double x);

/* Inverse of complemented incomplete gamma integral */
double igami(double a, double p);

/* Normal distribution function */
double ndtr(double x);

/* Inverse of Normal distribution function */
double ndtri(double y);

/* Bessel function of non-integer order */
double jv(double v, double x);

We could just link against Cephes, the library is very stable and changes only every few years. The license is not specified in the distribution or on the website, however the author of the library has agreed to distribute Cephes using the BSD license in the past. [3]

(For more special functions that could be implemented see [4], however that might be to extensive.)

[1] http://www.evanmiller.org/statistical-shortcomings-in-standard-math-libraries.html
[2] http://www.moshier.net/#Cephes
[3] https://lists.debian.org/debian-legal/2004/12/msg00295.html
[4] http://open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1422.html

@thestinger
Copy link
Contributor

I don't think the standard library should take on more external dependencies, especially one that's a dead project without clear licensing. It would make sense to expose the full C99 math library but I don't think going beyond that is within the scope of the standard library for the time being. There are still a few functions that are provided by C but not Rust.

@vks
Copy link
Contributor Author

vks commented Sep 5, 2014

I don't think it is dead, it seems more like it is done. And it is a tiny dependency, compared to most others.

@ghost
Copy link

ghost commented Oct 24, 2014

The author of Cephes allowed the torch-cephes library to distribute Cephes under the BSD license, so it would be acceptable to use that distribution of Cephes instead if there are any licensing concerns with the original Cephes.

See https://github.com/jucor/torch-cephes/blob/master/LICENSE.txt

@huonw
Copy link
Member

huonw commented Oct 24, 2014

This is something that can be used as an external library, due to Cargo. Furthermore, Cargo is actively improving with respect to compiling external deps (e.g. rust-lang/rfcs#403) so this will only get easier and easier. It makes sense for external libraries/bindings to be developed, iterated on and improved, and then, in future, we can evaluate the option of pulling in the best one (or best parts of each).

In any case, a good first step in getting this added would be writing that external lib.

@vks
Copy link
Contributor Author

vks commented Oct 24, 2014

@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#785

lnicola pushed a commit to lnicola/rust that referenced this issue Apr 7, 2024
lnicola pushed a commit to lnicola/rust that referenced this issue Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants