Specifying precision in vector<mpf_class>?

Felix E. Klee felix.klee.gmp@gmx.net
Wed, 16 Jul 2003 19:15:11 +0200


On Wednesday 16 July 2003 14:22, Ballabio Gerardo - Dip. di Scienza dei 
Materiali wrote:
> I used to get issues in particular when trying to mix mpf_classes of
> different precision, the problem being that with the template
> approach, you must anticipate the precision of the result, like this:
>
>    template <int N> class c;
>
>    template <int N, int M>
>    c<(N>M)?N:M> operator+(const c<N> &c1, const c<M> &c2);
>
> I've just tested this and indeed, it works with g++ 3.0.4, but not
> with 2.95.4 (Debian stable). However Debian is to my knowledge the
> only current distribution still based on a pre-3.0 compiler (and
> "current" and "Debian" may be regarded as mutually exclusive words),
> so this might be fine.
>
> A possible difficulty with templates is that we'd lose the
> possibility to resize an mpf_class, and in particular it would be
> impossible to declare an mpf_class without knowing in advance what we
> want its size to be. But probably this is something that will occur
> very rarely.

Thanks for outlining the problems in the template approach. They convince me 
that changing the status quo is probably the best idea. BTW, I'm fine with 
the vector solution (it was stupid of me that I didn't think about it at 
first) and I really don't need to define arrays. I made up the array 
example because you asked me to show you why the template approach is 
better (which, again, it probably isn't).

Felix

-- 
To contact me in private don't reply but send mail to
    felix DOT klee AT inka DOT de