Subject: [boost] A Boost.NumericAdaptor library to support big numbers
From: Bruno Lalande (bruno.lalande_at_[hidden])
Date: 2009-03-30 10:55:46
Barend quickly talked about this in the discussion about robustness,
big numbers and GMP. We have discussed about the idea and I'd like to
present it here to see if there's an interest.
The idea started from the need to rely on big numbers in geometry
computations that are sensitive to floating point errors. The most
important points were:
- big numbers are needed for those computations
- it's difficult to develop a Boost Big Numbers library as efficient
as the existing ones
- having a Boost geometry library that *necessarily* depends on an
existing big numbers library would impose to the user the way in which
big numbers must be handled, and would imply a dependency that
apparently disturbs some people
Thus we had the idea of using an adaptor, that is a wrapper that would
have the same semantics as a number, with an underlying implementation
chosen at compile-time, by selecting a policy. There would be a IEEE
policy that doesn't use any big number at all, and other policies that
would be implemented upon the most widely used big numbers libraries.
In the end it appears that this adaptor could become a library on its
own since it can be useful in other libraries than just geometry. It
could thus take the form of a Boost.NumericAdaptor library, aimed to
any library developer who needs to optionally enable the use of big
numbers for the most robustness-sensible operations of his library. He
would just have to take a policy as a template parameter, and
propagate this policy to a Numeric Adaptor used internally. The first
user of this library would obviously be the GGL we're developing.
Libraries like the fixed-size matrix being currently discussed as a
GSoC project could offer take advantage of this kind of library, since
ideally it has to support big numbers.
The sample in attachment shows the numeric_adaptor, a IEEE policy, a
GMP policy and a sample showing the use of the library. The
implementation has to evolve of course, but the main points are here.
Would there be an interest in adding such a library into Boost?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk