brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 0a3d353 Raw
69 lines · plain
1//  (C) Copyright John Maddock 2005.2//  Use, modification and distribution are subject to the3//  Boost Software License, Version 1.0. (See accompanying file4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED7#define BOOST_MATH_COMPLEX_DETAILS_INCLUDED8//9// This header contains all the support code that is common to the10// inverse trig complex functions, it also contains all the includes11// 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 21namespace boost{ namespace math{ namespace detail{22 23template <class T>24inline T mult_minus_one(const T& t)25{26   return (boost::math::isnan)(t) ? t : (boost::math::changesign)(t);27}28 29template <class T>30inline 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 35template <class T>36inline 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 41template <class T>42inline T safe_max(T t)43{44   return std::sqrt((std::numeric_limits<T>::max)()) / t;45}46inline long double safe_max(long double t)47{48   // long double sqrt often returns infinity due to49   // insufficient internal precision:50   return std::sqrt((std::numeric_limits<double>::max)()) / t;51}52 53template <class T>54inline T safe_min(T t)55{56   return std::sqrt((std::numeric_limits<T>::min)()) * t;57}58inline long double safe_min(long double t)59{60   // long double sqrt often returns zero due to61   // insufficient internal precision:62   return std::sqrt((std::numeric_limits<double>::min)()) * t;63}64 65} } } // namespaces66 67#endif // BOOST_MATH_COMPLEX_DETAILS_INCLUDED68 69