Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // boost asinh.hpp header file
3 // (C) Copyright Eric Ford 2001 & Hubert Holin.
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org for updates, documentation, and revision history.
10 #ifndef BOOST_ACOSH_HPP
11 #define BOOST_ACOSH_HPP
20 #include <boost/config.hpp>
23 // This is the inverse of the hyperbolic cosine function.
29 #if defined(__GNUC__) && (__GNUC__ < 3)
30 // gcc 2.x ignores function scope using declarations,
31 // put them in the scope of the enclosing namespace instead:
37 using ::std::numeric_limits;
40 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
41 // This is the main fare
44 inline T acosh(const T x)
50 using ::std::numeric_limits;
53 T const one = static_cast<T>(1);
54 T const two = static_cast<T>(2);
56 static T const taylor_2_bound = sqrt(numeric_limits<T>::epsilon());
57 static T const taylor_n_bound = sqrt(taylor_2_bound);
58 static T const upper_taylor_2_bound = one/taylor_2_bound;
62 if (numeric_limits<T>::has_quiet_NaN)
64 return(numeric_limits<T>::quiet_NaN());
68 ::std::string error_reporting("Argument to atanh is strictly greater than +1 or strictly smaller than -1!");
69 ::std::domain_error bad_argument(error_reporting);
74 else if (x >= taylor_n_bound)
76 if (x > upper_taylor_2_bound)
78 // approximation by laurent series in 1/x at 0+ order from -1 to 0
79 return( log( x*two) );
83 return( log( x + sqrt(x*x-one) ) );
90 // approximation by taylor series in y at 0 up to order 2
93 if (y >= taylor_2_bound)
97 // approximation by taylor series in y at 0 up to order 4
98 result -= y3/static_cast<T>(12);
101 return(sqrt(static_cast<T>(2))*result);
105 // These are implementation details (for main fare see below)
111 bool QuietNanSupported
113 struct acosh_helper2_t
117 return(::std::numeric_limits<T>::quiet_NaN());
119 }; // boost::detail::acosh_helper2_t
123 struct acosh_helper2_t<T, false>
127 ::std::string error_reporting("Argument to acosh is greater than or equal to +1!");
128 ::std::domain_error bad_argument(error_reporting);
132 }; // boost::detail::acosh_helper2_t
137 // This is the main fare
140 inline T acosh(const T x)
146 using ::std::numeric_limits;
148 typedef detail::acosh_helper2_t<T, std::numeric_limits<T>::has_quiet_NaN> helper2_type;
151 T const one = static_cast<T>(1);
152 T const two = static_cast<T>(2);
154 static T const taylor_2_bound = sqrt(numeric_limits<T>::epsilon());
155 static T const taylor_n_bound = sqrt(taylor_2_bound);
156 static T const upper_taylor_2_bound = one/taylor_2_bound;
160 return(helper2_type::get_NaN());
162 else if (x >= taylor_n_bound)
164 if (x > upper_taylor_2_bound)
166 // approximation by laurent series in 1/x at 0+ order from -1 to 0
167 return( log( x*two) );
171 return( log( x + sqrt(x*x-one) ) );
178 // approximation by taylor series in y at 0 up to order 2
181 if (y >= taylor_2_bound)
185 // approximation by taylor series in y at 0 up to order 4
186 result -= y3/static_cast<T>(12);
189 return(sqrt(static_cast<T>(2))*result);
192 #endif /* defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) */
196 #endif /* BOOST_ACOSH_HPP */