epoc32/include/stdapis/boost/math/complex/details.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/math/complex/details.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,104 @@
     1.4 +//  (C) Copyright John Maddock 2005.
     1.5 +//  Use, modification and distribution are subject to the
     1.6 +//  Boost Software License, Version 1.0. (See accompanying file
     1.7 +//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     1.8 +
     1.9 +#ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
    1.10 +#define BOOST_MATH_COMPLEX_DETAILS_INCLUDED
    1.11 +//
    1.12 +// This header contains all the support code that is common to the
    1.13 +// inverse trig complex functions, it also contains all the includes
    1.14 +// that we need to implement all these functions.
    1.15 +//
    1.16 +#include <boost/detail/workaround.hpp>
    1.17 +#include <boost/config.hpp>
    1.18 +#include <boost/config/no_tr1/complex.hpp>
    1.19 +#include <boost/limits.hpp>
    1.20 +#include <math.h> // isnan where available
    1.21 +#include <cmath>
    1.22 +
    1.23 +#ifdef BOOST_NO_STDC_NAMESPACE
    1.24 +namespace std{ using ::sqrt; }
    1.25 +#endif
    1.26 +
    1.27 +namespace boost{ namespace math{ namespace detail{
    1.28 +
    1.29 +template <class T>
    1.30 +inline bool test_is_nan(T t)
    1.31 +{
    1.32 +   // Comparisons with Nan's always fail:
    1.33 +   return std::numeric_limits<T>::has_infinity && (!(t <= std::numeric_limits<T>::infinity()) || !(t >= -std::numeric_limits<T>::infinity()));
    1.34 +}
    1.35 +#ifdef isnan
    1.36 +template<> inline bool test_is_nan<float>(float t) { return isnan(t); }
    1.37 +template<> inline bool test_is_nan<double>(double t) { return isnan(t); }
    1.38 +template<> inline bool test_is_nan<long double>(long double t) { return isnan(t); }
    1.39 +#endif
    1.40 +
    1.41 +template <class T>
    1.42 +inline T mult_minus_one(const T& t)
    1.43 +{
    1.44 +   return test_is_nan(t) ? t : -t;
    1.45 +}
    1.46 +
    1.47 +template <class T>
    1.48 +inline std::complex<T> mult_i(const std::complex<T>& t)
    1.49 +{
    1.50 +   return std::complex<T>(mult_minus_one(t.imag()), t.real());
    1.51 +}
    1.52 +
    1.53 +template <class T>
    1.54 +inline std::complex<T> mult_minus_i(const std::complex<T>& t)
    1.55 +{
    1.56 +   return std::complex<T>(t.imag(), mult_minus_one(t.real()));
    1.57 +}
    1.58 +
    1.59 +template <class T>
    1.60 +inline T safe_max(T t)
    1.61 +{
    1.62 +   return std::sqrt((std::numeric_limits<T>::max)()) / t;
    1.63 +}
    1.64 +inline long double safe_max(long double t)
    1.65 +{
    1.66 +   // long double sqrt often returns infinity due to
    1.67 +   // insufficient internal precision:
    1.68 +   return std::sqrt((std::numeric_limits<double>::max)()) / t;
    1.69 +}
    1.70 +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
    1.71 +// workaround for type deduction bug:
    1.72 +inline float safe_max(float t)
    1.73 +{
    1.74 +   return std::sqrt((std::numeric_limits<float>::max)()) / t;
    1.75 +}
    1.76 +inline double safe_max(double t)
    1.77 +{
    1.78 +   return std::sqrt((std::numeric_limits<double>::max)()) / t;
    1.79 +}
    1.80 +#endif
    1.81 +template <class T>
    1.82 +inline T safe_min(T t)
    1.83 +{
    1.84 +   return std::sqrt((std::numeric_limits<T>::min)()) * t;
    1.85 +}
    1.86 +inline long double safe_min(long double t)
    1.87 +{
    1.88 +   // long double sqrt often returns zero due to
    1.89 +   // insufficient internal precision:
    1.90 +   return std::sqrt((std::numeric_limits<double>::min)()) * t;
    1.91 +}
    1.92 +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
    1.93 +// type deduction workaround:
    1.94 +inline double safe_min(double t)
    1.95 +{
    1.96 +   return std::sqrt((std::numeric_limits<double>::min)()) * t;
    1.97 +}
    1.98 +inline float safe_min(float t)
    1.99 +{
   1.100 +   return std::sqrt((std::numeric_limits<float>::min)()) * t;
   1.101 +}
   1.102 +#endif
   1.103 +
   1.104 +} } } // namespaces
   1.105 +
   1.106 +#endif // BOOST_MATH_COMPLEX_DETAILS_INCLUDED
   1.107 +