
Comparing imaginary and reals seems confusing to me
///Returns true if x equals y
template<typename T> inline bool operator==(const Imaginary<T>& x, const T& y); template<typename T> inline bool operator==(const T& x, const Imaginary<T>& y);
The SL offers comparison between std::complex<T> and T which only compare the real part of the complex number and verifies that its imaginary part is zero. I do the same here: I compare the imaginary part of both arguments and verify that the real part of the complex is zero.
Ummm, yes but an imaginary is not a real, and the comparison works only when both are 0. Is this really useful?
Sorry. I misread your comment. These operators return true only if x==0 and y==0. So, you are right, not very useful. They are just here for the sake of completeness. The same is true for the operator != which almost always return true. What about defining a boost::complex<> class that behaves like the proposed
one.
This could be done. But in my opinion, there isn't any other optimisation available. The only point in doing so would be to allow for these operators. The very nature of complex numbers does not allow compile-time optimisations like what can be done for matrices. bests, Matthieu