Subject: Re: [boost] Boost.Math and Math Constants
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-12-07 11:30:32
On Wed, Dec 7, 2011 at 7:33 AM, Paul A. Bristow <pbristow_at_[hidden]>wrote:
> Boost.Math has always had an inconspicuous collection of useful math
> constants, mainly those that
> are used internally.
> The presentation of these was as a function-template, called for example,
> as pi<double>().
> using namespace boost::math::constants;
> return pi<Real>() * r * r;
> This leads to some rather ugly equations and is most unpopular with
> scientific and engineering
> John Maddock has now added a new cunning feature that allows the vast
> majority of users who just
> want a built-in double to get the constants quickly as plain variables. So
> in non-template code,
> users can write
> using boost::math::double_constants;
> double area = pi * r * r;
> and users can read the equations easily.
> (Float and long double are similarly available in their own namespaces).
It seems like this isn't a huge improvement over
double const pi = boost::math::constants::pi< double >();
double area = pi * r * r;
...except when one wishes to use several constants (but I wouldn't think
that would be all that common...).
The original mechanism which can be used for higher multiprecision
> user-defined floating-point types
> appears unchanged but has been improved to work better with UDTs and high
> precision types.
> Some draft detailed docs about just these new proposals are at
> We would like to be sure that
> 1 This additional mechanism of presenting constants is acceptable.
> 2 It is acceptable to add more constants (current new list is about 60
> Are there important constants that you think we have missed?
> Do we need a mini-review?
> Other views?
> 1 Are there important constants that you think we have missed?
> 2 Please tell me of mistakes and typos in the draft docs.
I'll probably look over the draft docs when I get a chance.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk