sigma  1.0.0
Loading...
Searching...
No Matches
basic.ipp
1#pragma once
2#include <cmath>
4
5namespace sigma {
6
7template<typename T>
9 if(a.empty()) { return a; }
10 auto a_range = a.range();
11 if(a_range.lower() >= T(0.0)) {
12 return a;
13 } else if(a_range.upper() <= T(0.0)) {
14 return -a;
15 }
16 auto new_center = std::abs(a.center()) / 2.0;
17 auto new_error_terms = a.error_terms();
18 for(auto&& [error_symbol, error_term_i] : new_error_terms) {
19 error_term_i = error_term_i / 2.0;
20 }
21 return Affine<T>(new_center, new_error_terms);
22}
23
24template<typename T>
26 return abs(a);
27}
28
29} // namespace sigma
Defines the Affine class.
Implements affine arithmetic.
Definition affine.hpp:48
const error_terms_t & error_terms() const
Returns the error terms of the affine form.
Definition affine.hpp:213
value_t center() const
Returns the center of the affine form.
Definition affine.hpp:194
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:824
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:8
Affine< T > fabs(const Affine< T > &a)
Absolute Value of an affine form.
Definition basic.ipp:25