Boost logo

Boost :

Subject: [boost] Boost.Math and Math Constants
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2011-12-07 10:33:21


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
users.

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).

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

  http://boost-sandbox.sourceforge.net/libs/math_constants/doc/html/index.html

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 constants).

Are there important constants that you think we have missed?

Do we need a mini-review?

Other views?

Paul

PS

1 Are there important constants that you think we have missed?

2 Please tell me of mistakes and typos in the draft docs.

---
Paul A. Bristow,
Prizet Farmhouse, Kendal LA8 8AB  UK
+44 1539 561830  07714330204
pbristow_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk