1.1 --- a/epoc32/include/stdapis/boost/math/complex/acosh.hpp Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/boost/math/complex/acosh.hpp Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,198 +1,34 @@
1.4 -// boost asinh.hpp header file
1.5 +// (C) Copyright John Maddock 2005.
1.6 +// Use, modification and distribution are subject to the
1.7 +// Boost Software License, Version 1.0. (See accompanying file
1.8 +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.9
1.10 -// (C) Copyright Eric Ford 2001 & Hubert Holin.
1.11 -// Distributed under the Boost Software License, Version 1.0. (See
1.12 -// accompanying file LICENSE_1_0.txt or copy at
1.13 -// http://www.boost.org/LICENSE_1_0.txt)
1.14 +#ifndef BOOST_MATH_COMPLEX_ACOSH_INCLUDED
1.15 +#define BOOST_MATH_COMPLEX_ACOSH_INCLUDED
1.16
1.17 -// See http://www.boost.org for updates, documentation, and revision history.
1.18 +#ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
1.19 +# include <boost/math/complex/details.hpp>
1.20 +#endif
1.21 +#ifndef BOOST_MATH_COMPLEX_ATANH_INCLUDED
1.22 +# include <boost/math/complex/acos.hpp>
1.23 +#endif
1.24
1.25 -#ifndef BOOST_ACOSH_HPP
1.26 -#define BOOST_ACOSH_HPP
1.27 +namespace boost{ namespace math{
1.28
1.29 -
1.30 -#include <cmath>
1.31 -#include <limits>
1.32 -#include <string>
1.33 -#include <stdexcept>
1.34 -
1.35 -
1.36 -#include <boost/config.hpp>
1.37 -
1.38 -
1.39 -// This is the inverse of the hyperbolic cosine function.
1.40 -
1.41 -namespace boost
1.42 +template<class T>
1.43 +inline std::complex<T> acosh(const std::complex<T>& z)
1.44 {
1.45 - namespace math
1.46 - {
1.47 -#if defined(__GNUC__) && (__GNUC__ < 3)
1.48 - // gcc 2.x ignores function scope using declarations,
1.49 - // put them in the scope of the enclosing namespace instead:
1.50 -
1.51 - using ::std::abs;
1.52 - using ::std::sqrt;
1.53 - using ::std::log;
1.54 -
1.55 - using ::std::numeric_limits;
1.56 -#endif
1.57 -
1.58 -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
1.59 - // This is the main fare
1.60 -
1.61 - template<typename T>
1.62 - inline T acosh(const T x)
1.63 - {
1.64 - using ::std::abs;
1.65 - using ::std::sqrt;
1.66 - using ::std::log;
1.67 -
1.68 - using ::std::numeric_limits;
1.69 -
1.70 -
1.71 - T const one = static_cast<T>(1);
1.72 - T const two = static_cast<T>(2);
1.73 -
1.74 - static T const taylor_2_bound = sqrt(numeric_limits<T>::epsilon());
1.75 - static T const taylor_n_bound = sqrt(taylor_2_bound);
1.76 - static T const upper_taylor_2_bound = one/taylor_2_bound;
1.77 -
1.78 - if (x < one)
1.79 - {
1.80 - if (numeric_limits<T>::has_quiet_NaN)
1.81 - {
1.82 - return(numeric_limits<T>::quiet_NaN());
1.83 - }
1.84 - else
1.85 - {
1.86 - ::std::string error_reporting("Argument to atanh is strictly greater than +1 or strictly smaller than -1!");
1.87 - ::std::domain_error bad_argument(error_reporting);
1.88 -
1.89 - throw(bad_argument);
1.90 - }
1.91 - }
1.92 - else if (x >= taylor_n_bound)
1.93 - {
1.94 - if (x > upper_taylor_2_bound)
1.95 - {
1.96 - // approximation by laurent series in 1/x at 0+ order from -1 to 0
1.97 - return( log( x*two) );
1.98 - }
1.99 - else
1.100 - {
1.101 - return( log( x + sqrt(x*x-one) ) );
1.102 - }
1.103 - }
1.104 - else
1.105 - {
1.106 - T y = sqrt(x-one);
1.107 -
1.108 - // approximation by taylor series in y at 0 up to order 2
1.109 - T result = y;
1.110 -
1.111 - if (y >= taylor_2_bound)
1.112 - {
1.113 - T y3 = y*y*y;
1.114 -
1.115 - // approximation by taylor series in y at 0 up to order 4
1.116 - result -= y3/static_cast<T>(12);
1.117 - }
1.118 -
1.119 - return(sqrt(static_cast<T>(2))*result);
1.120 - }
1.121 - }
1.122 -#else
1.123 - // These are implementation details (for main fare see below)
1.124 -
1.125 - namespace detail
1.126 - {
1.127 - template <
1.128 - typename T,
1.129 - bool QuietNanSupported
1.130 - >
1.131 - struct acosh_helper2_t
1.132 - {
1.133 - static T get_NaN()
1.134 - {
1.135 - return(::std::numeric_limits<T>::quiet_NaN());
1.136 - }
1.137 - }; // boost::detail::acosh_helper2_t
1.138 -
1.139 -
1.140 - template<typename T>
1.141 - struct acosh_helper2_t<T, false>
1.142 - {
1.143 - static T get_NaN()
1.144 - {
1.145 - ::std::string error_reporting("Argument to acosh is greater than or equal to +1!");
1.146 - ::std::domain_error bad_argument(error_reporting);
1.147 -
1.148 - throw(bad_argument);
1.149 - }
1.150 - }; // boost::detail::acosh_helper2_t
1.151 -
1.152 - } // boost::detail
1.153 -
1.154 -
1.155 - // This is the main fare
1.156 -
1.157 - template<typename T>
1.158 - inline T acosh(const T x)
1.159 - {
1.160 - using ::std::abs;
1.161 - using ::std::sqrt;
1.162 - using ::std::log;
1.163 -
1.164 - using ::std::numeric_limits;
1.165 -
1.166 - typedef detail::acosh_helper2_t<T, std::numeric_limits<T>::has_quiet_NaN> helper2_type;
1.167 -
1.168 -
1.169 - T const one = static_cast<T>(1);
1.170 - T const two = static_cast<T>(2);
1.171 -
1.172 - static T const taylor_2_bound = sqrt(numeric_limits<T>::epsilon());
1.173 - static T const taylor_n_bound = sqrt(taylor_2_bound);
1.174 - static T const upper_taylor_2_bound = one/taylor_2_bound;
1.175 -
1.176 - if (x < one)
1.177 - {
1.178 - return(helper2_type::get_NaN());
1.179 - }
1.180 - else if (x >= taylor_n_bound)
1.181 - {
1.182 - if (x > upper_taylor_2_bound)
1.183 - {
1.184 - // approximation by laurent series in 1/x at 0+ order from -1 to 0
1.185 - return( log( x*two) );
1.186 - }
1.187 - else
1.188 - {
1.189 - return( log( x + sqrt(x*x-one) ) );
1.190 - }
1.191 - }
1.192 - else
1.193 - {
1.194 - T y = sqrt(x-one);
1.195 -
1.196 - // approximation by taylor series in y at 0 up to order 2
1.197 - T result = y;
1.198 -
1.199 - if (y >= taylor_2_bound)
1.200 - {
1.201 - T y3 = y*y*y;
1.202 -
1.203 - // approximation by taylor series in y at 0 up to order 4
1.204 - result -= y3/static_cast<T>(12);
1.205 - }
1.206 -
1.207 - return(sqrt(static_cast<T>(2))*result);
1.208 - }
1.209 - }
1.210 -#endif /* defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) */
1.211 - }
1.212 + //
1.213 + // We use the relation acosh(z) = +-i acos(z)
1.214 + // Choosing the sign of multiplier to give real(acosh(z)) >= 0
1.215 + // as well as compatibility with C99.
1.216 + //
1.217 + std::complex<T> result = boost::math::acos(z);
1.218 + if(!detail::test_is_nan(result.imag()) && result.imag() <= 0)
1.219 + return detail::mult_i(result);
1.220 + return detail::mult_minus_i(result);
1.221 }
1.222
1.223 -#endif /* BOOST_ACOSH_HPP */
1.224 +} } // namespaces
1.225
1.226 -
1.227 +#endif // BOOST_MATH_COMPLEX_ACOSH_INCLUDED