Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef max
4#undef max
5#endif
6
7#ifdef min
8#undef min
9#endif
10
11#include <cstdint>
12#include <limits>
13#include <string>
14
15#include <map>
16#include <vector>
17
19
20namespace storm {
21
22// Forward-declare MatrixEntry class.
23namespace storage {
24template<typename IndexType, typename ValueType>
25class MatrixEntry;
26}
27
28template<typename RationalType>
29struct NumberTraits;
30
31namespace utility {
32
33namespace detail {
34template<typename ValueType>
36 typedef std::less<ValueType> type;
37};
38
39struct DoubleLess {
40 bool operator()(double a, double b) const {
41 return (a == 0.0 && b > 0.0) || (b - a > 1e-17);
42 }
43};
44
45template<>
46struct ElementLess<double> {
48};
49
50template<typename ValueType>
52 typedef std::greater<ValueType> type;
53};
54
56 bool operator()(double a, double b) const {
57 return (b == 0.0 && a > 0.0) || (a - b > 1e-17);
58 }
59};
60
61template<>
62struct ElementGreater<double> {
64};
65} // namespace detail
66
67template<typename ValueType>
69
70template<typename ValueType>
72
73template<typename ValueType>
74ValueType one();
75
76template<typename ValueType>
77ValueType zero();
78
79template<typename ValueType>
80ValueType infinity();
81
82template<typename ValueType>
83bool isApproxEqual(ValueType const& a, ValueType const& b, ValueType const& precision, bool relative);
84
85template<typename ValueType>
86bool isPositive(ValueType const& a);
87
88template<typename ValueType>
89bool isNonNegative(ValueType const& a);
90
94template<typename ValueType>
95bool isBetween(ValueType const& a, ValueType const& b, ValueType const& c, bool strict = false);
96
97template<typename ValueType>
98bool isOne(ValueType const& a);
99
100template<typename ValueType>
101bool isZero(ValueType const& a);
102
103template<typename ValueType>
104bool isNan(ValueType const& a);
105
106template<typename ValueType>
107bool isAlmostZero(ValueType const& a);
108
109template<typename ValueType>
110bool isAlmostOne(ValueType const& a);
111
112template<typename ValueType>
113bool isConstant(ValueType const& a);
114
115template<typename ValueType>
116bool isInfinity(ValueType const& a);
117
118template<typename ValueType>
119bool isInteger(ValueType const& number);
120
121template<typename TargetType, typename SourceType>
122TargetType convertNumber(SourceType const& number);
123
124template<typename ValueType>
125std::pair<ValueType, ValueType> asFraction(ValueType const& number);
126
127template<typename ValueType>
128ValueType simplify(ValueType value);
129
130template<typename IndexType, typename ValueType>
132
133template<typename IndexType, typename ValueType>
135
136template<typename ValueType>
137std::pair<ValueType, ValueType> minmax(std::vector<ValueType> const& values);
138
139template<typename ValueType>
140ValueType minimum(std::vector<ValueType> const& values);
141
142template<typename ValueType>
143ValueType maximum(std::vector<ValueType> const& values);
144
145template<typename K, typename ValueType>
146std::pair<ValueType, ValueType> minmax(std::map<K, ValueType> const& values);
147
148template<typename K, typename ValueType>
149ValueType minimum(std::map<K, ValueType> const& values);
150
151template<typename K, typename ValueType>
152ValueType maximum(std::map<K, ValueType> const& values);
153
154template<typename ValueType>
155ValueType pow(ValueType const& value, int_fast64_t exponent);
156
157template<typename ValueType>
158ValueType max(ValueType const& first, ValueType const& second);
159
160template<typename ValueType>
161ValueType min(ValueType const& first, ValueType const& second);
162
163template<typename ValueType>
164ValueType sqrt(ValueType const& number);
165
166template<typename ValueType>
167ValueType abs(ValueType const& number);
168
169template<typename ValueType>
170ValueType floor(ValueType const& number);
171
172template<typename ValueType>
173ValueType ceil(ValueType const& number);
174
175template<typename ValueType>
176ValueType round(ValueType const& number);
177
178template<typename ValueType>
179ValueType log(ValueType const& number);
180
181template<typename ValueType>
182ValueType log10(ValueType const& number);
183
184template<typename ValueType>
185ValueType cos(ValueType const& number);
186
187template<typename ValueType>
188ValueType sin(ValueType const& number);
189
190template<typename ValueType>
191uint64_t numDigits(ValueType const& number);
192
193template<typename ValueType>
194typename NumberTraits<ValueType>::IntegerType trunc(ValueType const& number);
195
196template<typename RationalType>
197typename NumberTraits<RationalType>::IntegerType numerator(RationalType const& number);
198
199template<typename RationalType>
200typename NumberTraits<RationalType>::IntegerType denominator(RationalType const& number);
201
205template<typename IntegerType>
206std::pair<IntegerType, IntegerType> divide(IntegerType const& dividend, IntegerType const& divisor);
207
208template<typename IntegerType>
209IntegerType mod(IntegerType const& first, IntegerType const& second);
210
211template<typename ValueType>
212std::string to_string(ValueType const& value);
213} // namespace utility
214} // namespace storm
ValueType max(ValueType const &first, ValueType const &second)
bool isPositive(ValueType const &a)
Definition constants.cpp:64
bool isOne(ValueType const &a)
Definition constants.cpp:34
NumberTraits< RationalType >::IntegerType denominator(RationalType const &number)
NumberTraits< RationalType >::IntegerType numerator(RationalType const &number)
bool isConstant(ValueType const &)
ValueType simplify(ValueType value)
bool isBetween(ValueType const &a, ValueType const &b, ValueType const &c, bool strict)
Compare whether a <= b <= c or a < b < c, based on the strictness parameter.
Definition constants.cpp:82
ValueType min(ValueType const &first, ValueType const &second)
ValueType sin(ValueType const &number)
bool isApproxEqual(ValueType const &a, ValueType const &b, ValueType const &precision, bool relative)
Definition constants.cpp:54
bool isAlmostZero(ValueType const &a)
Definition constants.cpp:93
bool isAlmostOne(ValueType const &a)
Definition constants.cpp:98
ValueType floor(ValueType const &number)
std::pair< ValueType, ValueType > asFraction(ValueType const &number)
bool isZero(ValueType const &a)
Definition constants.cpp:39
ValueType minimum(std::vector< ValueType > const &values)
ValueType ceil(ValueType const &number)
bool isInteger(ValueType const &number)
ValueType abs(ValueType const &number)
ValueType zero()
Definition constants.cpp:24
ValueType infinity()
Definition constants.cpp:29
bool isNan(ValueType const &)
Definition constants.cpp:44
std::string to_string(ValueType const &value)
std::pair< ValueType, ValueType > minmax(std::vector< ValueType > const &values)
typename detail::ElementLess< ValueType >::type ElementLess
Definition constants.h:68
typename detail::ElementGreater< ValueType >::type ElementGreater
Definition constants.h:71
bool isNonNegative(ValueType const &a)
Definition constants.cpp:69
NumberTraits< ValueType >::IntegerType trunc(ValueType const &number)
std::pair< IntegerType, IntegerType > divide(IntegerType const &dividend, IntegerType const &divisor)
(Integer-)Divides the dividend by the divisor and returns the result plus the remainder.
IntegerType mod(IntegerType const &first, IntegerType const &second)
ValueType pow(ValueType const &value, int_fast64_t exponent)
ValueType one()
Definition constants.cpp:19
ValueType log(ValueType const &number)
ValueType maximum(std::vector< ValueType > const &values)
ValueType cos(ValueType const &number)
ValueType sqrt(ValueType const &number)
uint64_t numDigits(ValueType const &number)
bool isInfinity(ValueType const &a)
ValueType log10(ValueType const &number)
ValueType round(ValueType const &number)
TargetType convertNumber(SourceType const &number)
bool operator()(double a, double b) const
Definition constants.h:56
bool operator()(double a, double b) const
Definition constants.h:40
std::greater< ValueType > type
Definition constants.h:52
std::less< ValueType > type
Definition constants.h:36