sigma  1.0.0
Loading...
Searching...
No Matches
hyperbolic.ipp
1#pragma once
3#include <stdexcept>
4
5namespace sigma {
6
7template<typename T>
9 if(a.empty()) { return Interval<T>(); }
10 return detail_::from_boost_(boost::numeric::sinh(detail_::to_boost_(a)));
11}
12
13template<typename T>
15 if(a.empty()) { return Interval<T>(); }
16
17 // Over an argument spanning zero, boost takes the minimum at the interior
18 // point cosh(0) == 1.
19 return detail_::from_boost_(boost::numeric::cosh(detail_::to_boost_(a)));
20}
21
22template<typename T>
24 if(a.empty()) { return Interval<T>(); }
25 return detail_::from_boost_(boost::numeric::tanh(detail_::to_boost_(a)));
26}
27
28template<typename T>
30 if(a.empty()) { return Interval<T>(); }
31 return detail_::from_boost_(boost::numeric::asinh(detail_::to_boost_(a)));
32}
33
34template<typename T>
36 if(a.empty()) { return Interval<T>(); }
37 // Trimming the argument back to the domain would answer a narrower
38 // question than the one asked. Boost would clamp the lower bound to one.
39 if(a.lower() < T(1)) {
40 throw std::domain_error("Interval has values less than 1.");
41 }
42 return detail_::from_boost_(boost::numeric::acosh(detail_::to_boost_(a)));
43}
44
45template<typename T>
47 if(a.empty()) { return Interval<T>(); }
48 // The domain is open, so a bound AT plus or minus one is out of domain.
49 detail_::assert_within_unit_(a, true, "inverse hyperbolic tangent");
50 return detail_::from_boost_(boost::numeric::atanh(detail_::to_boost_(a)));
51}
52
53} // namespace sigma
Models a closed numeric interval.
Definition interval.hpp:29
value_t lower() const
Returns the lower bound of the interval.
Definition interval.hpp:116
bool empty() const
Is *this the empty interval?
Definition interval.hpp:108
Conversions between sigma::Interval and the boost interval it wraps.
Interval< T > from_boost_(const boost_interval_t< T > &x)
Convert a boost interval into a sigma::Interval.
Definition convert.hpp:48
void assert_within_unit_(const Interval< T > &a, bool open, const std::string &name)
Throws unless every value in a lies in the unit interval.
Definition convert.hpp:74
boost_interval_t< T > to_boost_(const Interval< T > &a)
Convert a sigma::Interval into the boost interval it wraps.
Definition convert.hpp:31
The primary namespace for the sigma library.
Definition affine.hpp:12
GeneralInterval< T > atanh(const GeneralInterval< T > &a)
Calculate the inverse hyperbolic tangent of a general interval.
Definition hyperbolic.ipp:75
GeneralInterval< T > tanh(const GeneralInterval< T > &a)
Calculate the hyperbolic tangent of a general interval.
Definition hyperbolic.ipp:45
GeneralInterval< T > cosh(const GeneralInterval< T > &a)
Calculate the hyperbolic cosine of a general interval.
Definition hyperbolic.ipp:17
GeneralInterval< T > acosh(const GeneralInterval< T > &a)
Calculate the inverse hyperbolic cosine of a general interval.
Definition hyperbolic.ipp:61
GeneralInterval< T > asinh(const GeneralInterval< T > &a)
Calculate the inverse hyperbolic sine of a general interval.
Definition hyperbolic.ipp:53
GeneralInterval< T > sinh(const GeneralInterval< T > &a)
Calculate the hyperbolic sine of a general interval.
Definition hyperbolic.ipp:9