sigma  1.0.0
Loading...
Searching...
No Matches
apply_unary.hpp
Go to the documentation of this file.
1#pragma once
2#include <utility>
3
10
11namespace sigma {
12
13template<typename IntervalType>
14class Triplex;
15
16namespace detail_ {
17
18// Defined in make_triplex.hpp, which is included at the end of this file. It
19// is declared here instead so that apply_unary_ is defined no matter which
20// header is included first: make_triplex.hpp pulls in the operations, and they
21// call apply_unary_.
22template<typename IntervalType>
23Triplex<IntervalType> make_triplex_(IntervalType bounds,
24 typename IntervalType::value_t nominal);
25
47template<typename IntervalType, typename BoundsFunction,
48 typename NominalFunction>
50 BoundsFunction&& bounds_fxn,
51 NominalFunction&& nominal_fxn) {
52 using value_t = typename IntervalType::value_t;
53 if(a.empty()) { return Triplex<IntervalType>(); }
54 auto bounds = bounds_fxn(a.interval());
55 value_t nominal = nominal_fxn(a.nominal());
56 return make_triplex_(std::move(bounds), nominal);
57}
58
59} // namespace detail_
60} // namespace sigma
61
Models an interval together with a best estimate inside it.
Definition triplex.hpp:42
bool empty() const
Is *this the empty triplex?
Definition triplex.hpp:139
const interval_t & interval() const
Returns the bounds, discarding the nominal value.
Definition triplex.hpp:225
value_t nominal() const
Returns the nominal value.
Definition triplex.hpp:163
Defines the function every triplex operation uses to build its result.
The namespace that contains the implementation details of the library.
Definition convert.hpp:18
Triplex< IntervalType > apply_unary_(const Triplex< IntervalType > &a, BoundsFunction &&bounds_fxn, NominalFunction &&nominal_fxn)
Applies a unary function to a triplex.
Definition apply_unary.hpp:49
Triplex< IntervalType > make_triplex_(IntervalType bounds, typename IntervalType::value_t nominal)
Assembles a triplex from the result of an operation.
Definition make_triplex.hpp:44
The primary namespace for the sigma library.
Definition affine.hpp:12