sigma  1.0.0
Loading...
Searching...
No Matches
basic.ipp
1#pragma once
2#include <algorithm>
3#include <cmath>
5
6namespace sigma {
7
8template<typename T>
10 if(a.empty()) { return a; }
11 auto a_range = a.range();
12 if(a_range.lower() >= T(0.0)) {
13 return a;
14 } else if(a_range.upper() <= T(0.0)) {
15 return -a;
16 }
17 auto m = std::max(std::abs(a_range.lower()), a_range.upper());
18 return Affine<T>(typename Affine<T>::interval_t(T(0.0), m));
19}
20
21template<typename T>
23 return abs(a);
24}
25
26} // namespace sigma
Defines the Affine class.
Implements affine arithmetic.
Definition affine.hpp:48
Interval< value_t > interval_t
Type of an interval.
Definition affine.hpp:63
bool empty() const noexcept
Checks if this affine form is representing an empty interval.
Definition affine.hpp:313
interval_t range() const
Returns the interval represented by the affine form.
Definition affine.hpp:856
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