Subject: Re: [boost] [mpl-cf] [RFC] MPL Real Numbers using Continued Fractions
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2010-12-01 04:16:13
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of Hal Finkel
> Sent: Tuesday, November 30, 2010 7:12 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] [mpl-cf] [RFC] MPL Real Numbers using Continued
> That was also my original assumption, but I found it worked pretty well in
> practice. For one thing, I've chosen a convention such that all of the
> integers have the same sign, This means that there is no "catastrophic
> cancellation," and also makes implementing the comparison ops relatively
> simple (comparison is cheap compared to arithmetic).
> To be fair, my original use case was the generation of ratios of pi for
use in FFT
> kernels, and as you've noted above, all of the integers in the pi
> fairly small (and there are a lot of 1s), so maybe it is not entirely
> but I've yet to encounter a case where this has caused a problem. That
> been said, I've not really tried to find such a case either. I can
> about this more carefully.
I'm not sure what the OP really wanted to calculate,
(if he really needed MPL calculation or MPL was just convenient)
but I thought I would just add that if the need is something as simple as
ratios of pi, or indeed fractions, one might like to consider using NTL
www.shoup.net or GMP which have
far higher precision reals (100+ decimal digits), enough to allow
calculation of values to be pasted or cast into C++ builtin types,
ensuring the accuracy of the float/double/long double value in C++.
This method was used for the Boost.Math tables (many using continued
fractions) and for the small
number of constants, including pi, and its fractions and multiples. (The
necessary patches and info to use NTL
are in the Boost.Math package).
Finally, John Maddock and I are currently giving some thought how to make
these Boost.Math constants
(and perhaps others - like a bigger collection of pi fractions for FFT for
more 'user friendly' for wider use (and perhaps providing more of them).
We will expose these ideas to discussion fairly soon.
--- 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