namespace for math function and statistics distributions

John Maddock and I have been beavering away on the many math function and statistics distributions but are uncertain if and how best to use namespaces, so we are asking for views because we need to make rather pervasive decisions now (that we should have done before ;-). There are existing math functions (octonions, quaternions, acosh) in namespace boost::math:: and John has added many more, for example: #include <boost/math/special_functions/beta.hpp> // for ibeta(a, b, x) == Ix(a, b). so users can write using boost::math::ibeta_invb; ibeta_invb(r, p, P); So far, so good. Each statistical probability distribution, like negative_binomial includes a typedef typedef negative_binomial_distribution<double> negative_binomial; // Reserved name of type double. so that users have the great convenience (when using double - 99% of use?) of specifiying distributions thus using boost::math::negative_binomial; // default type is double. negative_binomial mydist(8., 0.25); rather than having to use the rather long full, type specified name: negative_binomial_distribution<double> my8dist(8., 0.25); This seems neat, except that there are functions beta, gamma and binomial :-(( So there is a name clash when using thus: using boost::math::binomial; binomial mydist(2., 0.5); // is it a function or a probability distribution? We are therefore considering to use namespaces to separate the math functions from the stats distributions into namespace boost::math::distributions, or ? so users would write: using boost::math::distributions::binomial; binomial mydist(8., 0.25); Or should it be in namespace boost::statistics; or boost::statistics::distributions or should all the functions be in namespace boost::math::functions - changing much existing code :-(( or ???? Views please. Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

Paul A Bristow wrote:
Each statistical probability distribution, like negative_binomial includes a typedef
typedef negative_binomial_distribution<double> negative_binomial; // Reserved name of type double.
so that users have the great convenience (when using double - 99% of use?)
of specifiying distributions thus
using boost::math::negative_binomial; // default type is double. negative_binomial mydist(8., 0.25);
rather than having to use the rather long full, type specified name:
negative_binomial_distribution<double> my8dist(8., 0.25);
There's also the option of negative_binomial_distribution<> my8dist(8., 0.25);

| -----Original Message----- | From: boost-bounces@lists.boost.org | [mailto:boost-bounces@lists.boost.org] On Behalf Of Peter Dimov | Sent: 18 October 2006 17:35 | To: boost@lists.boost.org | Subject: Re: [boost] namespace for math function and | statistics distributions | | Paul A Bristow wrote: | | > Each statistical probability distribution, like negative_binomial | > includes a typedef | > | > typedef negative_binomial_distribution<double> | negative_binomial; // | > Reserved name of type double. | > | > so that users have the great convenience (when using | double - 99% of | > use?) | > | > of specifiying distributions thus | > | > using boost::math::negative_binomial; // default type is double. | > negative_binomial mydist(8., 0.25); | > | > rather than having to use the rather long full, type | specified name: | > | > negative_binomial_distribution<double> my8dist(8., 0.25); | | There's also the option of | | negative_binomial_distribution<> my8dist(8., 0.25); Thanks for this suggestion. It has prompted us to think again and conclude that a new namespace would be too big a hammer for such a small nut. A default RealType = double would be generally convenient, and we will just have to make an exceptionor the 3 cases of name clash when users will have to use the form binomial_distribution<> mydist(8., 0.25); rather than binomial mydist(8., 0.25); and similarly: beta_distribution<> mydist(8., 0.25); gamma_distribution<> mydist(8., 0.25); An acceptable nuisance to users, we think. Thanks Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com
participants (2)
-
Paul A Bristow
-
Peter Dimov