00001 #ifndef MATH_UTILS_H 00002 #define MATH_UTILS_H 00003 00004 /* needed for fabs, sqrt() below */ 00005 #include <cmath> 00006 00007 00008 00009 namespace TNT 00010 { 00017 template <class Real> 00018 Real hypot(const Real &a, const Real &b) 00019 { 00020 00021 if (a== 0) 00022 return abs(b); 00023 else 00024 { 00025 Real c = b/a; 00026 return fabs(a) * sqrt(1 + c*c); 00027 } 00028 } 00029 } /* TNT namespace */ 00030 00031 00032 00033 #endif 00034 /* MATH_UTILS_H */