epoc32/include/stdapis/boost/math/complex/asinh.hpp
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/math/complex/asinh.hpp	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +//    boost asinh.hpp header file
     1.5 +
     1.6 +//  (C) Copyright Eric Ford & Hubert Holin 2001.
     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_ASINH_HPP
    1.14 +#define BOOST_ASINH_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 sine 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 +        template<typename T>
    1.44 +        inline T    asinh(const T x)
    1.45 +        {
    1.46 +            using    ::std::abs;
    1.47 +            using    ::std::sqrt;
    1.48 +            using    ::std::log;
    1.49 +            
    1.50 +            using    ::std::numeric_limits;
    1.51 +            
    1.52 +            
    1.53 +            T const            one = static_cast<T>(1);
    1.54 +            T const            two = static_cast<T>(2);
    1.55 +            
    1.56 +            static T const    taylor_2_bound = sqrt(numeric_limits<T>::epsilon());
    1.57 +            static T const    taylor_n_bound = sqrt(taylor_2_bound);
    1.58 +            static T const    upper_taylor_2_bound = one/taylor_2_bound;
    1.59 +            static T const    upper_taylor_n_bound = one/taylor_n_bound;
    1.60 +            
    1.61 +            if        (x >= +taylor_n_bound)
    1.62 +            {
    1.63 +                if        (x > upper_taylor_n_bound)
    1.64 +                {
    1.65 +                    if        (x > upper_taylor_2_bound)
    1.66 +                    {
    1.67 +                        // approximation by laurent series in 1/x at 0+ order from -1 to 0
    1.68 +                        return( log( x * two) );
    1.69 +                    }
    1.70 +                    else
    1.71 +                    {
    1.72 +                        // approximation by laurent series in 1/x at 0+ order from -1 to 1
    1.73 +                        return( log( x*two + (one/(x*two)) ) );
    1.74 +                    }
    1.75 +                }
    1.76 +                else
    1.77 +                {
    1.78 +                    return( log( x + sqrt(x*x+one) ) );
    1.79 +                }
    1.80 +            }
    1.81 +            else if    (x <= -taylor_n_bound)
    1.82 +            {
    1.83 +                return(-asinh(-x));
    1.84 +            }
    1.85 +            else
    1.86 +            {
    1.87 +                // approximation by taylor series in x at 0 up to order 2
    1.88 +                T    result = x;
    1.89 +                
    1.90 +                if    (abs(x) >= taylor_2_bound)
    1.91 +                {
    1.92 +                    T    x3 = x*x*x;
    1.93 +                    
    1.94 +                    // approximation by taylor series in x at 0 up to order 4
    1.95 +                    result -= x3/static_cast<T>(6);
    1.96 +                }
    1.97 +                
    1.98 +                return(result);
    1.99 +            }
   1.100 +        }
   1.101 +    }
   1.102 +}
   1.103 +
   1.104 +#endif /* BOOST_ASINH_HPP */