1.1 --- a/epoc32/include/stdapis/boost/math/complex/asinh.hpp Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/boost/math/complex/asinh.hpp Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,101 +1,32 @@
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 & Hubert Holin 2001.
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_ASINH_INCLUDED
1.15 +#define BOOST_MATH_COMPLEX_ASINH_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_ASINH_INCLUDED
1.22 +# include <boost/math/complex/asinh.hpp>
1.23 +#endif
1.24
1.25 -#ifndef BOOST_ASINH_HPP
1.26 -#define BOOST_ASINH_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 sine function.
1.40 -
1.41 -namespace boost
1.42 +template<class T>
1.43 +inline std::complex<T> asinh(const std::complex<T>& x)
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 - template<typename T>
1.59 - inline T asinh(const T x)
1.60 - {
1.61 - using ::std::abs;
1.62 - using ::std::sqrt;
1.63 - using ::std::log;
1.64 -
1.65 - using ::std::numeric_limits;
1.66 -
1.67 -
1.68 - T const one = static_cast<T>(1);
1.69 - T const two = static_cast<T>(2);
1.70 -
1.71 - static T const taylor_2_bound = sqrt(numeric_limits<T>::epsilon());
1.72 - static T const taylor_n_bound = sqrt(taylor_2_bound);
1.73 - static T const upper_taylor_2_bound = one/taylor_2_bound;
1.74 - static T const upper_taylor_n_bound = one/taylor_n_bound;
1.75 -
1.76 - if (x >= +taylor_n_bound)
1.77 - {
1.78 - if (x > upper_taylor_n_bound)
1.79 - {
1.80 - if (x > upper_taylor_2_bound)
1.81 - {
1.82 - // approximation by laurent series in 1/x at 0+ order from -1 to 0
1.83 - return( log( x * two) );
1.84 - }
1.85 - else
1.86 - {
1.87 - // approximation by laurent series in 1/x at 0+ order from -1 to 1
1.88 - return( log( x*two + (one/(x*two)) ) );
1.89 - }
1.90 - }
1.91 - else
1.92 - {
1.93 - return( log( x + sqrt(x*x+one) ) );
1.94 - }
1.95 - }
1.96 - else if (x <= -taylor_n_bound)
1.97 - {
1.98 - return(-asinh(-x));
1.99 - }
1.100 - else
1.101 - {
1.102 - // approximation by taylor series in x at 0 up to order 2
1.103 - T result = x;
1.104 -
1.105 - if (abs(x) >= taylor_2_bound)
1.106 - {
1.107 - T x3 = x*x*x;
1.108 -
1.109 - // approximation by taylor series in x at 0 up to order 4
1.110 - result -= x3/static_cast<T>(6);
1.111 - }
1.112 -
1.113 - return(result);
1.114 - }
1.115 - }
1.116 - }
1.117 + //
1.118 + // We use asinh(z) = i asin(-i z);
1.119 + // Note that C99 defines this the other way around (which is
1.120 + // to say asin is specified in terms of asinh), this is consistent
1.121 + // with C99 though:
1.122 + //
1.123 + return ::boost::math::detail::mult_i(::boost::math::asin(::boost::math::detail::mult_minus_i(x)));
1.124 }
1.125
1.126 -#endif /* BOOST_ASINH_HPP */
1.127 +} } // namespaces
1.128 +
1.129 +#endif // BOOST_MATH_COMPLEX_ASINH_INCLUDED