annotate DEPENDENCIES/generic/include/boost/tr1/complex.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // (C) Copyright John Maddock 2005.
Chris@16 2 // Use, modification and distribution are subject to the
Chris@16 3 // Boost Software License, Version 1.0. (See accompanying file
Chris@16 4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5
Chris@16 6 #ifndef BOOST_TR1_COMPLEX_HPP_INCLUDED
Chris@16 7 # define BOOST_TR1_COMPLEX_HPP_INCLUDED
Chris@16 8 # include <boost/tr1/detail/config.hpp>
Chris@16 9 # include <complex>
Chris@16 10
Chris@16 11 #ifndef BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG
Chris@16 12
Chris@16 13 #include <boost/math/complex.hpp>
Chris@16 14
Chris@16 15 namespace std {
Chris@16 16 namespace tr1 {
Chris@16 17
Chris@16 18 using boost::math::acos;
Chris@16 19 using boost::math::asin;
Chris@16 20 using boost::math::atan;
Chris@16 21 using boost::math::acosh;
Chris@16 22 using boost::math::asinh;
Chris@16 23 using boost::math::atanh;
Chris@16 24 using boost::math::fabs;
Chris@16 25
Chris@16 26 } }
Chris@16 27
Chris@16 28 #else
Chris@16 29
Chris@16 30 # if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT)
Chris@16 31 # include_next BOOST_TR1_HEADER(complex)
Chris@16 32 # else
Chris@16 33 # include <boost/tr1/detail/config_all.hpp>
Chris@16 34 # include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(complex))
Chris@16 35 # endif
Chris@16 36
Chris@16 37 #endif
Chris@16 38
Chris@16 39 #ifndef BOOST_HAS_TR1_COMPLEX_OVERLOADS
Chris@16 40
Chris@16 41 #include <boost/tr1/detail/math_overloads.hpp>
Chris@16 42 #include <boost/assert.hpp>
Chris@16 43 #include <boost/detail/workaround.hpp>
Chris@16 44 #include <boost/config/no_tr1/cmath.hpp>
Chris@16 45
Chris@16 46 namespace std{
Chris@16 47
Chris@16 48 #ifdef BOOST_NO_STDC_NAMESPACE
Chris@16 49 using :: atan2;
Chris@16 50 #endif
Chris@16 51
Chris@16 52 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
Chris@16 53 template <class T>
Chris@16 54 inline BOOST_TR1_MATH_RETURN(double) arg(const T& t)
Chris@16 55 {
Chris@16 56 return ::std::atan2(0.0, static_cast<double>(t));
Chris@16 57 }
Chris@16 58 #else
Chris@16 59 inline double arg(const double& t)
Chris@16 60 {
Chris@16 61 return ::std::atan2(0.0, t);
Chris@16 62 }
Chris@16 63 #endif
Chris@16 64 inline long double arg(const long double& t)
Chris@16 65 {
Chris@16 66 return ::std::atan2(0.0L, static_cast<long double>(t));
Chris@16 67 }
Chris@16 68 inline float arg(const float& t)
Chris@16 69 {
Chris@16 70 return ::std::atan2(0.0F, static_cast<float>(t));
Chris@16 71 }
Chris@16 72
Chris@16 73 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
Chris@16 74 template <class T>
Chris@16 75 inline BOOST_TR1_MATH_RETURN(double) norm(const T& t)
Chris@16 76 {
Chris@16 77 double r = static_cast<double>(t);
Chris@16 78 return r*r;
Chris@16 79 }
Chris@16 80 #else
Chris@16 81 inline double norm(const double& t)
Chris@16 82 {
Chris@16 83 return t*t;
Chris@16 84 }
Chris@16 85 #endif
Chris@16 86 inline long double norm(const long double& t)
Chris@16 87 {
Chris@16 88 long double l = t;
Chris@16 89 return l*l;
Chris@16 90 }
Chris@16 91 inline float norm(const float& t)
Chris@16 92 {
Chris@16 93 float f = t;
Chris@16 94 return f*f;
Chris@16 95 }
Chris@16 96
Chris@16 97 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
Chris@16 98 template <class T>
Chris@16 99 inline BOOST_TR1_MATH_RETURN(std::complex<double>) conj(const T& t)
Chris@16 100 {
Chris@16 101 return ::std::conj(std::complex<double>(static_cast<double>(t)));
Chris@16 102 }
Chris@16 103 #else
Chris@16 104 inline std::complex<double> conj(const double& t)
Chris@16 105 {
Chris@16 106 return ::std::conj(std::complex<double>(t));
Chris@16 107 }
Chris@16 108 #endif
Chris@16 109 inline std::complex<long double> conj(const long double& t)
Chris@16 110 {
Chris@16 111 return ::std::conj(std::complex<long double>(t));
Chris@16 112 }
Chris@16 113 inline std::complex<float> conj(const float& t)
Chris@16 114 {
Chris@16 115 std::complex<float> ct(t);
Chris@16 116 ct = ::std::conj(ct);
Chris@16 117 return ct;
Chris@16 118 }
Chris@16 119
Chris@101 120 #if !BOOST_WORKAROUND(__BORLANDC__, <=0x570)
Chris@16 121 inline complex<double> polar(const char& rho, const char& theta = 0)
Chris@16 122 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 123 inline complex<double> polar(const unsigned char& rho, const unsigned char& theta = 0)
Chris@16 124 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 125 inline complex<double> polar(const signed char& rho, const signed char& theta = 0)
Chris@16 126 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 127 inline complex<double> polar(const short& rho, const short& theta = 0)
Chris@16 128 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 129 inline complex<double> polar(const unsigned short& rho, const unsigned short& theta = 0)
Chris@16 130 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 131 inline complex<double> polar(const int& rho, const int& theta = 0)
Chris@16 132 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 133 inline complex<double> polar(const unsigned int& rho, const unsigned int& theta = 0)
Chris@16 134 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 135 inline complex<double> polar(const long& rho, const long& theta = 0)
Chris@16 136 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 137 inline complex<double> polar(const unsigned long& rho, const unsigned long& theta = 0)
Chris@16 138 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 139 #ifdef BOOST_HAS_LONG_LONG
Chris@16 140 inline complex<double> polar(const long long& rho, const long long& theta = 0)
Chris@16 141 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 142 inline complex<double> polar(const unsigned long long& rho, const unsigned long long& theta = 0)
Chris@16 143 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 144 #elif defined(BOOST_HAS_MS_INT64)
Chris@16 145 inline complex<double> polar(const __int64& rho, const __int64& theta = 0)
Chris@16 146 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 147 inline complex<double> polar(const unsigned __int64& rho, const unsigned __int64& theta = 0)
Chris@16 148 { return ::std::polar(static_cast<double>(rho), static_cast<double>(theta)); }
Chris@16 149 #endif
Chris@16 150
Chris@16 151 template<class T, class U>
Chris@16 152 inline complex<typename boost::tr1_detail::promote_to_real<T, U>::type>
Chris@16 153 polar(const T& rho, const U& theta)
Chris@16 154 {
Chris@16 155 typedef typename boost::tr1_detail::promote_to_real<T, U>::type real_type;
Chris@16 156 return std::polar(static_cast<real_type>(rho), static_cast<real_type>(theta));
Chris@16 157 }
Chris@16 158 #endif
Chris@16 159
Chris@16 160 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
Chris@16 161 template <class T>
Chris@16 162 inline BOOST_TR1_MATH_RETURN(double) imag(const T& )
Chris@16 163 {
Chris@16 164 return 0;
Chris@16 165 }
Chris@16 166 #else
Chris@16 167 inline double imag(const double& )
Chris@16 168 {
Chris@16 169 return 0;
Chris@16 170 }
Chris@16 171 #endif
Chris@16 172 inline long double imag(const long double& )
Chris@16 173 {
Chris@16 174 return 0;
Chris@16 175 }
Chris@16 176 inline float imag(const float& )
Chris@16 177 {
Chris@16 178 return 0;
Chris@16 179 }
Chris@16 180
Chris@16 181 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
Chris@16 182 template <class T>
Chris@16 183 inline BOOST_TR1_MATH_RETURN(double) real(const T& t)
Chris@16 184 {
Chris@16 185 return static_cast<double>(t);
Chris@16 186 }
Chris@16 187 #else
Chris@16 188 inline double real(const double& t)
Chris@16 189 {
Chris@16 190 return t;
Chris@16 191 }
Chris@16 192 #endif
Chris@16 193 inline long double real(const long double& t)
Chris@16 194 {
Chris@16 195 return t;
Chris@16 196 }
Chris@16 197 inline float real(const float& t)
Chris@16 198 {
Chris@16 199 return t;
Chris@16 200 }
Chris@16 201
Chris@16 202 template<class T, class U>
Chris@16 203 inline complex<typename boost::tr1_detail::largest_real<T, U>::type>
Chris@16 204 pow(const complex<T>& x, const complex<U>& y)
Chris@16 205 {
Chris@16 206 typedef complex<typename boost::tr1_detail::largest_real<T, U>::type> result_type;
Chris@16 207 typedef typename boost::mpl::if_<boost::is_same<result_type, complex<T> >, result_type const&, result_type>::type cast1_type;
Chris@16 208 typedef typename boost::mpl::if_<boost::is_same<result_type, complex<U> >, result_type const&, result_type>::type cast2_type;
Chris@16 209 cast1_type x1(x);
Chris@16 210 cast2_type y1(y);
Chris@16 211 return std::pow(x1, y1);
Chris@16 212 }
Chris@16 213 template<class T, class U>
Chris@16 214 inline complex<typename boost::tr1_detail::promote_to_real<T, U>::type>
Chris@16 215 pow (const complex<T>& x, const U& y)
Chris@16 216 {
Chris@16 217 typedef typename boost::tr1_detail::promote_to_real<T, U>::type real_type;
Chris@16 218 typedef complex<typename boost::tr1_detail::promote_to_real<T, U>::type> result_type;
Chris@16 219 typedef typename boost::mpl::if_<boost::is_same<result_type, complex<T> >, result_type const&, result_type>::type cast1_type;
Chris@16 220 real_type r = y;
Chris@16 221 cast1_type x1(x);
Chris@16 222 std::complex<real_type> y1(r);
Chris@16 223 return std::pow(x1, y1);
Chris@16 224 }
Chris@16 225
Chris@16 226 template<class T, class U>
Chris@16 227 inline complex<typename boost::tr1_detail::promote_to_real<T, U>::type>
Chris@16 228 pow (const T& x, const complex<U>& y)
Chris@16 229 {
Chris@16 230 typedef typename boost::tr1_detail::promote_to_real<T, U>::type real_type;
Chris@16 231 typedef complex<typename boost::tr1_detail::promote_to_real<T, U>::type> result_type;
Chris@16 232 typedef typename boost::mpl::if_<boost::is_same<result_type, complex<U> >, result_type const&, result_type>::type cast_type;
Chris@16 233 real_type r = x;
Chris@16 234 std::complex<real_type> x1(r);
Chris@16 235 cast_type y1(y);
Chris@16 236 return std::pow(x1, y1);
Chris@16 237 }
Chris@16 238
Chris@16 239 }
Chris@16 240
Chris@16 241 #endif
Chris@16 242
Chris@16 243 #endif
Chris@16 244