From: Amitha Perera <perera@cs...>  20020904 16:37:18

Fred asked a pertinent question which shows I don't really know what I'm talking about: :) Frederik Schaffalitzky wrote: > Sorry, I don't understand what you mean by "long double constants"... > Exactly how does the implementation of the VCx.y sqrt(double) cause long > doubles to be passed to the constructor of vnl_bignum? Investigating further, the problem is not with the sqrt or abs overrides per se. It's with instantiating complex<bignum>. In particular, with instantiating abs( complex<bignum> ). VC70 implements abs(complex<Ty>) with a complicated, and presumably efficient and accurate, routine. In one branch of the routine, there is a statement (Ty)0.423423....545345L which asks for a conversion from a long double to Ty. (It's a high precision representation of sqrt(2), FWIW.) This fails for vnl_bignum, and also fails for vnl_rational when we try to explicitly instantiate abs(complex<rational>). There is no problem with VC60, because there is a "fix" in vcl/win32/vcl_complex.h that defines T abs( complex<T> z ) { return sqrt( norm(z) ); } Now, this "fix" shouldn't be in place for VC70 because the library *does* provide abs(complex<T>). It may not be implemented as we like, but then, the implementation details are not ours to dictate. I think in general, there is trouble when trying to create a userdefined type that acts like a standard numeric type. As Fred mentioned earlier, it is undefined to overload std::sqrt because that is adding to namespace std. Perhaps the solution is to go back to vnl_sqrt for vnl stuff. Has there been previous discussion about this issue? Amitha. 