Boost logo

Boost :

Subject: Re: [boost] Arbitrary precision arithmetic
From: Scott Johnson (engineerscotty_at_[hidden])
Date: 2009-08-18 17:29:58


I tend to agree--if we do it, we ought to do a reasonable reference
implementation. (If it gets standardized eventually, then compiler vendors
can tune it up, after all).

On Tue, Aug 18, 2009 at 2:25 PM, Stephen Nuchia <snuchia_at_[hidden]>wrote:

> I had drafted an earlier reply but perhaps I botched sending it as I've
> not seen it come through. My opinion then was that this (a bignum
> library) is a poor fit for the boost community, considering the amount
> and kind of platform-specific microoptimization that goes on in the GMP
> library camp.
>
> But today I'm writing unit tests for some tricky floating-point
> calculation sequences and it occurs to me that a reliable
> arbitrary-precision library with a very good API would be just the thing
> for calculating the "should be" values. Support for crypto and
> calculator demo programs round out the justification.
>
> A bignum library focused primarily on portable, provably correct
> "reference implementations" of the algorithms rather than on performance
> would have a lot of value.
>
> My toolbag for writing tests like these includes testing properties of
> the answers rather than checking their values against predictions,
> choosing input data for which the output is easy to calculate, or
> writing a model of the calculation in Mathematica, executing it manually
> for pre-selected values, and pasting the answers into an expected value
> table.
>
> The way Mathematica answers the questions "what is the value of this
> expression, rounded to 53 bits?" is to evaluate the expression using a
> heuristically determined amount of extra precision and interval
> arithmetic. If both ends of the result interval round to the same
> number we have an answer, otherwise the calculation is repeated with
> increasing precision until the results converge.
>
> Having just recently taken a look at the boost::proto stuff I think it
> might be possible to directly implement this concept with expressions
> written in C++. Now that would be a trip!
>
> The boost community is not set up to duplicate what GMP does. But I
> think we could do something else very well if we focus on correctness,
> portability, and metaprogramming API tastiness instead of making the
> tires smoke.
>
> If I grok the proto stuff correctly it should be possible to write
> expressions that can be evaluated in different contexts. One could be
> native hardware FP arithmetic, one could be the reference bignum
> library, and one could even use GMP. Right?
>
> -swn
>
> Lambda expressions in a statically typed, compiled language. It's
> actually making me giddy!
>
> Self-identified old fart story: I implemented lambda expressions in C
> using a preprocessor in 1987 or 88, while working in the Sun Windows
> API. It had a very fine-grained callback design and the resulting
> namespace pollution and lack of locality when reading code drove me to
> it. It actually worked really well for that application.
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
engineer_scotty (no, not that one)
If life gives you lemons, drink Hefeweizen

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