sigma  1.0.0
Loading...
Searching...
No Matches
exponents.ipp
1#pragma once
3#include <cmath>
4
5namespace sigma {
6
7template<typename T>
9 if(a.empty()) { return Interval<T>(); }
10 auto low = std::sqrt(a.lower());
11 auto high = std::sqrt(a.upper());
12 return Interval<T>(low, high, a.left_open(), a.right_open());
13}
14
15template<typename T>
17 if(a.empty()) { return Interval<T>(); }
18 auto low = std::exp(a.lower());
19 auto high = std::exp(a.upper());
20 return Interval<T>(low, high, a.left_open(), a.right_open());
21}
22
23template<typename T>
25 if(a.empty()) { return Interval<T>(); }
26 auto low = std::log(a.lower());
27 auto high = std::log(a.upper());
28 return Interval<T>(low, high, a.left_open(), a.right_open());
29}
30
31template<typename T, typename U>
32Interval<T> pow(const Interval<T>& a, const U& exp) {
33 if(a.empty()) { return Interval<T>(); }
34 auto low = std::pow(a.lower(), exp);
35 auto high = std::pow(a.upper(), exp);
36 if(low > high) {
37 return Interval<T>(high, low, a.right_open(), a.left_open());
38 }
39 return Interval<T>(low, high, a.left_open(), a.right_open());
40}
41
42} // namespace sigma
Models a numeric interval.
Definition interval.hpp:23
value_t upper() const
Returns the upper bound of the interval.
Definition interval.hpp:157
bool left_open() const
Is lower() NOT contained in the interval?
Definition interval.hpp:114
value_t lower() const
Returns the lower bound of the interval.
Definition interval.hpp:146
bool right_open() const
Is upper() NOT contained in the interval?
Definition interval.hpp:130
bool empty() const
Is *this the empty interval?
Definition interval.hpp:106
Defines the Interval class.
The primary namespace for the sigma library.
Definition affine.hpp:12
Affine< T > exp(const Affine< T > &a)
Calculate the exponential of an affine form.
Definition exponents.ipp:30
Affine< T > pow(const Affine< T > &a, const U &exp)
Calculate the power of an affine form.
Definition exponents.ipp:71
Affine< T > log(const Affine< T > &a)
Calculate the natural logarithm of an affine form.
Definition exponents.ipp:50
Affine< T > sqrt(const Affine< T > &a)
Calculate the square root of an affine form.
Definition exponents.ipp:8