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