[phobos] Proposed changes to std.math + introduce std.mathspecial

Andrei Alexandrescu andrei at erdani.com
Wed Nov 17 13:36:56 PST 2010


Plan sounds good to me. Thanks for your great work, Don. A couple of 
comments below.

On 11/17/10 1:09 PM, Don Clugston wrote:
> (1) Add two necessary functions to std.math:
>
> // Rounds x to the nearest int or long using the currently selected
> rounding mode
> // (MUCH faster than cast(int)).
> int rndint(real x)
> long rndlong(real x)

To an uninitiated reader this may look like "random int" and "random 
long". Could we define this instead?

N roundTo(N)(real x) if (isIntegral!N);

Then use will be self-explanatory:

auto m = roundTo!int((a + b) / 2);

Feel free to constrain further to only e.g. int and long, or (at best) 
generalize to unsigned types and to types narrower than int.

> (2) Delete etc.gamma
>
> (3) Create a new module std.mathspecial.
>
> Move the following functions from std.math into std.mathspecial:
> erf()
> erfc()
> lgamma() ----->  name changes to logGamma(real x)
> tgamma() --->  name changes to gamma(real x).
> BTW The 't' in the C name exists for extremely silly historical reasons.
>
> std.math will retain alias for these functions, before they are
> eventually deprecated.

deprecated("Please use the homonym functions in std.mathspecial.")

:o)


Andrei


More information about the phobos mailing list