sigma  1.0.0
Loading...
Searching...
No Matches
basic.ipp
1#pragma once
3#include <algorithm>
4#include <cmath>
5
6namespace sigma {
7
8template<typename T>
10 if(a.empty()) { return Interval<T>(); }
11 // If interval is positive already, just return it.
12 if(a.lower() >= 0) { return a; }
13
14 // If interval is completely negative, return the negative of it.
15 if(a.upper() <= 0) { return -a; }
16
17 // We know it straddles zero, so the minimum is the interior point zero.
18 return Interval<T>(0, std::max(std::abs(a.lower()), std::abs(a.upper())));
19}
20
21template<typename T>
23 return abs(a);
24}
25
26} // namespace sigma
Models a closed numeric interval.
Definition interval.hpp:29
value_t upper() const
Returns the upper bound of the interval.
Definition interval.hpp:127
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
Defines the Interval class.
The primary namespace for the sigma library.
Definition affine.hpp:12
Affine< T > abs(const Affine< T > &a)
Absolute Value of an affine form.
Definition basic.ipp:9
Affine< T > fabs(const Affine< T > &a)
Absolute Value of an affine form.
Definition basic.ipp:22