This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: compile fails on hypot


larsbj@lyx.org (Lars Gullik Bjønnes) writes:

| ../../../../libstdc++-v3/src/complex.cc: In function `_Tp std::abs(const
|    std::complex<_Tp>&) [with _Tp = double]':
| ../../../../libstdc++-v3/src/complex.cc:54: `hypot' undeclared (first use this
|    function)
| ../../../../libstdc++-v3/src/complex.cc:54: (Each undeclared identifier is
|    reported only once for each function it appears in.)
| make[4]: *** [complex.lo] Error 1                               

Does the following cure your problem?  Please let me know.

-- Gaby
CodeSourcery, LLC                             http://www.codesourcery.com

Index: complex.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/src/complex.cc,v
retrieving revision 1.4
diff -p -r1.4 complex.cc
*** complex.cc	2000/10/30 21:30:30	1.4
--- complex.cc	2000/10/31 07:27:31
***************
*** 45,57 ****
  
  namespace std
  {
    template<>
    FLT
    abs(const complex<FLT>& __x)
    { 
      // We don't use cabs here because some systems (IRIX 6.5, for
      // example) define their own incompatible version.
!     return hypot (__real__ __x._M_value, __imag__ __x._M_value); 
    }
  
    template<>
--- 45,66 ----
  
  namespace std
  {
+   template<typename T>
+   T
+   __cmath_hypot(T x, T y)
+   {
+     T s = abs(x) + abs(y);
+     x /= s; y /= s;
+     return s * sqrt(x * x + y * y);
+   }
+   
    template<>
    FLT
    abs(const complex<FLT>& __x)
    { 
      // We don't use cabs here because some systems (IRIX 6.5, for
      // example) define their own incompatible version.
!     return __cmath_hypot (__real__ __x._M_value, __imag__ __x._M_value); 
    }
  
    template<>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]