Subject: Re: [boost] RFC: Multiprecision arithmetic library
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-12-22 11:32:46
>> * A generic front-end that's capable of wrapping almost any type that's
>> a "number". The front end is expression template enabled and handles all
>> the expression optimization and code reduction. For example it's
>> possible to evaluate a polynomial using Horner's rule without a single
>> temporary variable being created.
> Does it mean you're translating the expression
> result = a0 + x * (a1 + x * (a2 + x * a3));
> to the expression
> result = x,
> result *= a3,
> result += a2,
> result *= x,
> result += a1,
> result *= x,
> result += a0;
In effect, yes.
> This is something we wanted to do as well for MPFR support in the NT2
> library, but we never had the time to think about it properly.
> It would be nice if the logic that did this transformation was
> single-contained and re-usable (unless it's trivial).
> It could probably be generalized to any node that has an in-place
> equivalent, and I can think of some uses beyond integration with libraries
> such as MPFR. It could work with anything where operations are pure and
At present it's tied pretty heavily to the mp_number internals - basically
it's all done inside the expression-template unpacking code. Note that you
need to know what the ultimate target type of the transformation is as not
all combinations of operations can be converted to inplace equivalents, and
there are also some occasions when the out-of-place operations are actually
faster anyway (provided you already have the variables available).