Debian Codegraph @

third-party/boost-math/include/boost/math/complex/details.hpp

raw
1 // (C) Copyright John Maddock 2005.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
7 #define BOOST_MATH_COMPLEX_DETAILS_INCLUDED
8 //
9 // This header contains all the support code that is common to the
10 // inverse trig complex functions, it also contains all the includes
11 // that we need to implement all these functions.
12 //
13
14 #include <cmath>
15 #include <complex>
16 #include <limits>
17 #include <boost/math/special_functions/sign.hpp>
18 #include <boost/math/special_functions/fpclassify.hpp>
19 #include <boost/math/constants/constants.hpp>
20
21 namespace boost{ namespace math{ namespace detail{
22
23 template <class T>
24 inline T mult_minus_one(const T& t)
25 {
26 return (boost::math::isnan)(t) ? t : (boost::math::changesign)(t);
27 }
28
29 template <class T>
30 inline std::complex<T> mult_i(const std::complex<T>& t)
31 {
32 return std::complex<T>(mult_minus_one(t.imag()), t.real());
33 }
34
35 template <class T>
36 inline std::complex<T> mult_minus_i(const std::complex<T>& t)
37 {
38 return std::complex<T>(t.imag(), mult_minus_one(t.real()));
39 }
40
41 template <class T>
42 inline T safe_max(T t)
43 {
44 return std::sqrt((std::numeric_limits<T>::max)()) / t;
45 }
46 inline long double safe_max(long double t)
47 {
48 // long double sqrt often returns infinity due to
49 // insufficient internal precision:
50 return std::sqrt((std::numeric_limits<double>::max)()) / t;
51 }
52
53 template <class T>
54 inline T safe_min(T t)
55 {
56 return std::sqrt((std::numeric_limits<T>::min)()) * t;
57 }
58 inline long double safe_min(long double t)
59 {
60 // long double sqrt often returns zero due to
61 // insufficient internal precision:
62 return std::sqrt((std::numeric_limits<double>::min)()) * t;
63 }
64
65 } } } // namespaces
66
67 #endif // BOOST_MATH_COMPLEX_DETAILS_INCLUDED
68