|
Boost Users : |
Subject: Re: [Boost-users] [units][ublas] how would i use typedef in units?
From: Ravi (lists_ravi_at_[hidden])
Date: 2009-10-15 10:19:25
On Wednesday 14 October 2009 23:03:10 Matthias Schabel wrote:
> > I thought that the operators for std:;complex can't deduce the
> > return type
> > correctly for Boost.Units. Anyway "The effect of instantiating the
> > template
> > complex for any type other than float, double or long double is
> > unspecified." (26.2)
>
> Right, as usual... Maybe flesh out the more flexible complex type that
> we provided in our example or lobby the standards committee to make
> std::complex less stupid? Is there any good reason to have unspecified
> behavior for std::complex for UDTs?
Yes. This is a huge problem with extended-/finite-precision code where the
type of a + b is different from the type of a or b. In this case,
std::complex<10-bit type> + std::complex<10-bit type>
leads to
std::complex<11-bit type>
and the problem gets much more complicated for multiplication and division. I
work around it currently by specializing std::complex(!) in the std namespace
(against all guidelines) for my fixed-point types. Any better solution would
be greatly welcome. (For the mathematicians here, the problem is that
std::complex<fixed-point type> does not form a ring, much less a field.)
Regards,
Ravi
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net