author | William Roberts <williamr@symbian.org> |
Wed, 31 Mar 2010 12:27:01 +0100 | |
branch | Symbian2 |
changeset 3 | e1b950c65cb4 |
permissions | -rw-r--r-- |
williamr@2 | 1 |
// (C) Copyright John Maddock 2005. |
williamr@2 | 2 |
// Use, modification and distribution are subject to the |
williamr@2 | 3 |
// Boost Software License, Version 1.0. (See accompanying file |
williamr@2 | 4 |
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
williamr@2 | 5 |
|
williamr@2 | 6 |
#ifndef BOOST_MATH_COMPLEX_ATAN_INCLUDED |
williamr@2 | 7 |
#define BOOST_MATH_COMPLEX_ATAN_INCLUDED |
williamr@2 | 8 |
|
williamr@2 | 9 |
#ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED |
williamr@2 | 10 |
# include <boost/math/complex/details.hpp> |
williamr@2 | 11 |
#endif |
williamr@2 | 12 |
#ifndef BOOST_MATH_COMPLEX_ATANH_INCLUDED |
williamr@2 | 13 |
# include <boost/math/complex/atanh.hpp> |
williamr@2 | 14 |
#endif |
williamr@2 | 15 |
|
williamr@2 | 16 |
namespace boost{ namespace math{ |
williamr@2 | 17 |
|
williamr@2 | 18 |
template<class T> |
williamr@2 | 19 |
std::complex<T> atan(const std::complex<T>& x) |
williamr@2 | 20 |
{ |
williamr@2 | 21 |
// |
williamr@2 | 22 |
// We're using the C99 definition here; atan(z) = -i atanh(iz): |
williamr@2 | 23 |
// |
williamr@2 | 24 |
if(x.real() == 0) |
williamr@2 | 25 |
{ |
williamr@2 | 26 |
if(x.imag() == 1) |
williamr@2 | 27 |
return std::complex<T>(0, std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : static_cast<T>(HUGE_VAL)); |
williamr@2 | 28 |
if(x.imag() == -1) |
williamr@2 | 29 |
return std::complex<T>(0, std::numeric_limits<T>::has_infinity ? -std::numeric_limits<T>::infinity() : -static_cast<T>(HUGE_VAL)); |
williamr@2 | 30 |
} |
williamr@2 | 31 |
return ::boost::math::detail::mult_minus_i(::boost::math::atanh(::boost::math::detail::mult_i(x))); |
williamr@2 | 32 |
} |
williamr@2 | 33 |
|
williamr@2 | 34 |
} } // namespaces |
williamr@2 | 35 |
|
williamr@2 | 36 |
#endif // BOOST_MATH_COMPLEX_ATAN_INCLUDED |