acosh.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. #ifndef BOOST_MATH_COMPLEX_ACOSH_INCLUDED
  6. #define BOOST_MATH_COMPLEX_ACOSH_INCLUDED
  7. #ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
  8. # include <boost/math/complex/details.hpp>
  9. #endif
  10. #ifndef BOOST_MATH_COMPLEX_ATANH_INCLUDED
  11. # include <boost/math/complex/acos.hpp>
  12. #endif
  13. namespace boost{ namespace math{
  14. template<class T>
  15. inline std::complex<T> acosh(const std::complex<T>& z)
  16. {
  17. //
  18. // We use the relation acosh(z) = +-i acos(z)
  19. // Choosing the sign of multiplier to give real(acosh(z)) >= 0
  20. // as well as compatibility with C99.
  21. //
  22. std::complex<T> result = boost::math::acos(z);
  23. if(!(boost::math::isnan)(result.imag()) && signbit(result.imag()))
  24. return detail::mult_i(result);
  25. return detail::mult_minus_i(result);
  26. }
  27. } } // namespaces
  28. #endif // BOOST_MATH_COMPLEX_ACOSH_INCLUDED