1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/tr1/complex.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,243 @@
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_TR1_COMPLEX_HPP_INCLUDED
1.10 +# define BOOST_TR1_COMPLEX_HPP_INCLUDED
1.11 +# include <boost/tr1/detail/config.hpp>
1.12 +# include <complex>
1.13 +
1.14 +#ifndef BOOST_HAS_TR1_COMPLEX_OVERLOADS
1.15 +
1.16 +#include <boost/tr1/detail/math_overloads.hpp>
1.17 +#include <boost/assert.hpp>
1.18 +#include <boost/detail/workaround.hpp>
1.19 +#include <cmath>
1.20 +
1.21 +namespace std{
1.22 +
1.23 +#ifdef BOOST_NO_STDC_NAMESPACE
1.24 + using :: atan2;
1.25 +#endif
1.26 +
1.27 +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
1.28 +template <class T>
1.29 +inline BOOST_TR1_MATH_RETURN(double) arg(const T& t)
1.30 +{
1.31 + return ::std::atan2(0.0, static_cast<double>(t));
1.32 +}
1.33 +#else
1.34 +inline double arg(const double& t)
1.35 +{
1.36 + return ::std::atan2(0.0, t);
1.37 +}
1.38 +#endif
1.39 +inline long double arg(const long double& t)
1.40 +{
1.41 + return ::std::atan2(0.0L, static_cast<long double>(t));
1.42 +}
1.43 +inline float arg(const float& t)
1.44 +{
1.45 + return ::std::atan2(0.0F, static_cast<float>(t));
1.46 +}
1.47 +
1.48 +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
1.49 +template <class T>
1.50 +inline BOOST_TR1_MATH_RETURN(double) norm(const T& t)
1.51 +{
1.52 + double r = static_cast<double>(t);
1.53 + return r*r;
1.54 +}
1.55 +#else
1.56 +inline double norm(const double& t)
1.57 +{
1.58 + return t*t;
1.59 +}
1.60 +#endif
1.61 +inline long double norm(const long double& t)
1.62 +{
1.63 + long double l = t;
1.64 + return l*l;
1.65 +}
1.66 +inline float norm(const float& t)
1.67 +{
1.68 + float f = t;
1.69 + return f*f;
1.70 +}
1.71 +
1.72 +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
1.73 +template <class T>
1.74 +inline BOOST_TR1_MATH_RETURN(std::complex<double>) conj(const T& t)
1.75 +{
1.76 + return ::std::conj(std::complex<double>(static_cast<double>(t)));
1.77 +}
1.78 +#else
1.79 +inline std::complex<double> conj(const double& t)
1.80 +{
1.81 + return ::std::conj(std::complex<double>(t));
1.82 +}
1.83 +#endif
1.84 +inline std::complex<long double> conj(const long double& t)
1.85 +{
1.86 + return ::std::conj(std::complex<long double>(t));
1.87 +}
1.88 +inline std::complex<float> conj(const float& t)
1.89 +{
1.90 + std::complex<float> ct(t);
1.91 + ct = ::std::conj(ct);
1.92 + return ct;
1.93 +}
1.94 +
1.95 +#if !BOOST_WORKAROUND(__BORLANDC__, <=0x570) && !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
1.96 +inline complex<double> polar(const char& rho, const char& theta = 0)
1.97 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.98 +inline complex<double> polar(const unsigned char& rho, const unsigned char& theta = 0)
1.99 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.100 +inline complex<double> polar(const signed char& rho, const signed char& theta = 0)
1.101 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.102 +inline complex<double> polar(const short& rho, const short& theta = 0)
1.103 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.104 +inline complex<double> polar(const unsigned short& rho, const unsigned short& theta = 0)
1.105 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.106 +inline complex<double> polar(const int& rho, const int& theta = 0)
1.107 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.108 +inline complex<double> polar(const unsigned int& rho, const unsigned int& theta = 0)
1.109 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.110 +inline complex<double> polar(const long& rho, const long& theta = 0)
1.111 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.112 +inline complex<double> polar(const unsigned long& rho, const unsigned long& theta = 0)
1.113 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.114 +#ifdef BOOST_HAS_LONG_LONG
1.115 +inline complex<double> polar(const long long& rho, const long long& theta = 0)
1.116 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.117 +inline complex<double> polar(const unsigned long long& rho, const unsigned long long& theta = 0)
1.118 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.119 +#elif defined(BOOST_HAS_MS_INT64)
1.120 +inline complex<double> polar(const __int64& rho, const __int64& theta = 0)
1.121 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.122 +inline complex<double> polar(const unsigned __int64& rho, const unsigned __int64& theta = 0)
1.123 +{ return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
1.124 +#endif
1.125 +
1.126 +template<class T, class U>
1.127 +inline complex<typename boost::tr1_detail::promote_to_real<T, U>::type>
1.128 + polar(const T& rho, const U& theta)
1.129 +{
1.130 + typedef typename boost::tr1_detail::promote_to_real<T, U>::type real_type;
1.131 + return std::polar(static_cast<real_type>(rho), static_cast<real_type>(theta));
1.132 +}
1.133 +#endif
1.134 +
1.135 +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
1.136 +template <class T>
1.137 +inline BOOST_TR1_MATH_RETURN(double) imag(const T& )
1.138 +{
1.139 + return 0;
1.140 +}
1.141 +#else
1.142 +inline double imag(const double& )
1.143 +{
1.144 + return 0;
1.145 +}
1.146 +#endif
1.147 +inline long double imag(const long double& )
1.148 +{
1.149 + return 0;
1.150 +}
1.151 +inline float imag(const float& )
1.152 +{
1.153 + return 0;
1.154 +}
1.155 +
1.156 +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
1.157 +template <class T>
1.158 +inline BOOST_TR1_MATH_RETURN(double) real(const T& t)
1.159 +{
1.160 + return static_cast<double>(t);
1.161 +}
1.162 +#else
1.163 +inline double real(const double& t)
1.164 +{
1.165 + return t;
1.166 +}
1.167 +#endif
1.168 +inline long double real(const long double& t)
1.169 +{
1.170 + return t;
1.171 +}
1.172 +inline float real(const float& t)
1.173 +{
1.174 + return t;
1.175 +}
1.176 +
1.177 +template<class T, class U>
1.178 +inline complex<typename boost::tr1_detail::largest_real<T, U>::type>
1.179 + pow(const complex<T>& x, const complex<U>& y)
1.180 +{
1.181 + typedef complex<typename boost::tr1_detail::largest_real<T, U>::type> result_type;
1.182 + typedef typename boost::mpl::if_<boost::is_same<result_type, complex<T> >, result_type const&, result_type>::type cast1_type;
1.183 + typedef typename boost::mpl::if_<boost::is_same<result_type, complex<U> >, result_type const&, result_type>::type cast2_type;
1.184 + cast1_type x1(x);
1.185 + cast2_type y1(y);
1.186 + return std::pow(x1, y1);
1.187 +}
1.188 +template<class T, class U>
1.189 +inline complex<typename boost::tr1_detail::promote_to_real<T, U>::type>
1.190 + pow (const complex<T>& x, const U& y)
1.191 +{
1.192 + typedef typename boost::tr1_detail::promote_to_real<T, U>::type real_type;
1.193 + typedef complex<typename boost::tr1_detail::promote_to_real<T, U>::type> result_type;
1.194 + typedef typename boost::mpl::if_<boost::is_same<result_type, complex<T> >, result_type const&, result_type>::type cast1_type;
1.195 + real_type r = y;
1.196 + cast1_type x1(x);
1.197 + std::complex<real_type> y1(r);
1.198 + return std::pow(x1, y1);
1.199 +}
1.200 +
1.201 +template<class T, class U>
1.202 +inline complex<typename boost::tr1_detail::promote_to_real<T, U>::type>
1.203 + pow (const T& x, const complex<U>& y)
1.204 +{
1.205 + typedef typename boost::tr1_detail::promote_to_real<T, U>::type real_type;
1.206 + typedef complex<typename boost::tr1_detail::promote_to_real<T, U>::type> result_type;
1.207 + typedef typename boost::mpl::if_<boost::is_same<result_type, complex<U> >, result_type const&, result_type>::type cast_type;
1.208 + real_type r = x;
1.209 + std::complex<real_type> x1(r);
1.210 + cast_type y1(y);
1.211 + return std::pow(x1, y1);
1.212 +}
1.213 +
1.214 +}
1.215 +
1.216 +#endif
1.217 +
1.218 +#ifndef BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG
1.219 +
1.220 +#include <boost/math/complex.hpp>
1.221 +
1.222 +namespace std {
1.223 +namespace tr1 {
1.224 +
1.225 +using boost::math::acos;
1.226 +using boost::math::asin;
1.227 +using boost::math::atan;
1.228 +using boost::math::acosh;
1.229 +using boost::math::asinh;
1.230 +using boost::math::atanh;
1.231 +using boost::math::fabs;
1.232 +
1.233 +} }
1.234 +
1.235 +#else
1.236 +
1.237 +# ifdef BOOST_HAS_INCLUDE_NEXT
1.238 +# include_next BOOST_TR1_HEADER(complex)
1.239 +# else
1.240 +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(complex))
1.241 +# endif
1.242 +
1.243 +#endif
1.244 +
1.245 +#endif
1.246 +