Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:33

0001 //  (C) Copyright John Maddock 2005.
0002 //  Use, modification and distribution are subject to the
0003 //  Boost Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
0007 #define BOOST_MATH_COMPLEX_DETAILS_INCLUDED
0008 //
0009 // This header contains all the support code that is common to the
0010 // inverse trig complex functions, it also contains all the includes
0011 // that we need to implement all these functions.
0012 //
0013 
0014 #include <cmath>
0015 #include <complex>
0016 #include <limits>
0017 #include <boost/math/special_functions/sign.hpp>
0018 #include <boost/math/special_functions/fpclassify.hpp>
0019 #include <boost/math/constants/constants.hpp>
0020 
0021 namespace boost{ namespace math{ namespace detail{
0022 
0023 template <class T>
0024 inline T mult_minus_one(const T& t)
0025 {
0026    return (boost::math::isnan)(t) ? t : (boost::math::changesign)(t);
0027 }
0028 
0029 template <class T>
0030 inline std::complex<T> mult_i(const std::complex<T>& t)
0031 {
0032    return std::complex<T>(mult_minus_one(t.imag()), t.real());
0033 }
0034 
0035 template <class T>
0036 inline std::complex<T> mult_minus_i(const std::complex<T>& t)
0037 {
0038    return std::complex<T>(t.imag(), mult_minus_one(t.real()));
0039 }
0040 
0041 template <class T>
0042 inline T safe_max(T t)
0043 {
0044    return std::sqrt((std::numeric_limits<T>::max)()) / t;
0045 }
0046 inline long double safe_max(long double t)
0047 {
0048    // long double sqrt often returns infinity due to
0049    // insufficient internal precision:
0050    return std::sqrt((std::numeric_limits<double>::max)()) / t;
0051 }
0052 
0053 template <class T>
0054 inline T safe_min(T t)
0055 {
0056    return std::sqrt((std::numeric_limits<T>::min)()) * t;
0057 }
0058 inline long double safe_min(long double t)
0059 {
0060    // long double sqrt often returns zero due to
0061    // insufficient internal precision:
0062    return std::sqrt((std::numeric_limits<double>::min)()) * t;
0063 }
0064 
0065 } } } // namespaces
0066 
0067 #endif // BOOST_MATH_COMPLEX_DETAILS_INCLUDED
0068