33 const bool is_odd = (n % 2 != 0);
37 if(a.
upper() <= T(0)) {
42 if(!is_odd) { std::swap(left_open, right_open); }
43 }
else if(a.
lower() < T(0)) {
48 const T abs_lower = -a.
lower();
51 if(abs_lower > a.
upper()) {
53 }
else if(abs_lower < a.
upper()) {
62 return {left_open, right_open};
73 if(a.
lower() < T(0)) {
74 throw std::domain_error(
"Interval has negative values.");
97 throw std::domain_error(
"Interval has non-positive values.");
107template<
typename T,
typename U>
115 throw std::domain_error(
116 "Can not raise an interval containing 0 to a negative power.");
126 if(a.
lower() < T(0)) {
127 throw std::domain_error(
"Can not raise an interval with negative "
128 "values to a non-integer power.");
133 boost::numeric::log(x));
141 const auto power =
static_cast<long long>(
exp);
142 auto [left_open, right_open] =
146 if(power < 0) { std::swap(left_open, right_open); }
149 boost::numeric::pow(x,
static_cast<int>(power)), left_open, right_open);
161 if(exponent.
width() == T(0)) {
return pow(a, exponent.
lower()); }
Models an interval whose bounds may be open.
Definition general_interval.hpp:36
value_t width() const
Returns the distance between the interval's bounds.
Definition general_interval.hpp:103
bool contains(value_t value) const
Whether a scalar lies in this interval.
Definition general_interval.hpp:492
bool empty() const
Is *this the empty interval?
Definition general_interval.hpp:127
bool left_open() const
Is lower() NOT contained in the interval?
Definition general_interval.hpp:136
bool right_open() const
Is upper() NOT contained in the interval?
Definition general_interval.hpp:153
bool left_closed() const
Is lower() contained in the interval?
Definition general_interval.hpp:144
value_t lower() const
Returns the lower bound of the interval.
Definition general_interval.hpp:169
value_t upper() const
Returns the upper bound of the interval.
Definition general_interval.hpp:177
Conversions between sigma::GeneralInterval and the boost interval its closure wraps.
Exponent operations for interval variables.
The namespace that contains the implementation details of the library.
Definition convert.hpp:18
boost_interval_t< T > exponent_interval_(const U &exp)
The exponent of a non-integer pow(), as an interval.
Definition exponents.ipp:28
GeneralInterval< T > general_from_boost_(const boost_interval_t< T > &x, bool left_open=false, bool right_open=false)
Convert a boost interval into a sigma::GeneralInterval.
Definition general_convert.hpp:65
boost_interval_t< T > to_boost_(const Interval< T > &a)
Convert a sigma::Interval into the boost interval it wraps.
Definition convert.hpp:31
std::pair< bool, bool > integer_pow_openness_(const GeneralInterval< T > &a, long long n)
The openness of the bounds of pow(a, n) for a positive integer n.
Definition exponents.ipp:31
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:31
Affine< T > pow(const Affine< T > &a, const U &exp)
Calculate the power of an affine form.
Definition exponents.ipp:72
Affine< T > log(const Affine< T > &a)
Calculate the natural logarithm of an affine form.
Definition exponents.ipp:51
Affine< T > sqrt(const Affine< T > &a)
Calculate the square root of an affine form.
Definition exponents.ipp:9
Small numeric helpers shared across Sigma's representations.
bool is_integer_exponent(const U &exp)
True if exp has no fractional part.
Definition numeric.hpp:27