Storm 1.14.0.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
18namespace storm {
19
20// Forward-declare MatrixEntry class.
21namespace storage {
22template<typename IndexType, typename ValueType>
23class MatrixEntry;
24}
25
26template<typename RationalType>
27struct NumberTraits;
28
29namespace utility {
30
31namespace detail {
32template<typename ValueType>
34 typedef std::less<ValueType> type;
35};
36
37struct DoubleLess {
38 bool operator()(double a, double b) const {
39 return (a == 0.0 && b > 0.0) || (b - a > 1e-17);
40 }
41};
42
43template<>
44struct ElementLess<double> {
46};
47
48template<typename ValueType>
50 typedef std::greater<ValueType> type;
51};
52
54 bool operator()(double a, double b) const {
55 return (b == 0.0 && a > 0.0) || (a - b > 1e-17);
56 }
57};
58
59template<>
60struct ElementGreater<double> {
62};
63} // namespace detail
64
65template<typename ValueType>
67
68template<typename ValueType>
70
71template<typename ValueType>
72ValueType one();
73
74template<typename ValueType>
75ValueType zero();
76
77template<typename ValueType>
78ValueType infinity();
79
80template<typename ValueType>
81bool isApproxEqual(ValueType const& a, ValueType const& b, ValueType const& precision, bool relative);
82
83template<typename ValueType>
84bool isPositive(ValueType const& a);
85
86template<typename ValueType>
87bool isNonNegative(ValueType const& a);
88
92template<typename ValueType>
93bool isBetween(ValueType const& a, ValueType const& b, ValueType const& c, bool strict = false);
94
95template<typename ValueType>
96bool isOne(ValueType const& a);
97
98template<typename ValueType>
99bool isZero(ValueType const& a);
100
101template<typename ValueType>
102bool isNan(ValueType const& a);
103
104template<typename ValueType>
105bool isAlmostZero(ValueType const& a);
106
107template<typename ValueType>
108bool isAlmostOne(ValueType const& a);
109
110template<typename ValueType>
111bool isConstant(ValueType const& a);
112
113template<typename ValueType>
114bool isInfinity(ValueType const& a);
115
116template<typename ValueType>
117bool isInteger(ValueType const& number);
118
119template<typename TargetType, typename SourceType>
120TargetType convertNumber(SourceType const& number);
121
129template<typename RationalType>
130bool tryParseNumber(std::string const& input, RationalType& result);
131
132template<typename ValueType>
133ValueType simplify(ValueType value);
134
135template<typename IndexType, typename ValueType>
137
138template<typename IndexType, typename ValueType>
140
141template<typename ValueType>
142std::pair<ValueType, ValueType> minmax(std::vector<ValueType> const& values);
143
144template<typename ValueType>
145ValueType minimum(std::vector<ValueType> const& values);
146
147template<typename ValueType>
148ValueType maximum(std::vector<ValueType> const& values);
149
150template<typename K, typename ValueType>
151std::pair<ValueType, ValueType> minmax(std::map<K, ValueType> const& values);
152
153template<typename K, typename ValueType>
154ValueType minimum(std::map<K, ValueType> const& values);
155
156template<typename K, typename ValueType>
157ValueType maximum(std::map<K, ValueType> const& values);
158
159template<typename ValueType>
160ValueType pow(ValueType const& value, int_fast64_t exponent);
161
162template<typename ValueType>
163ValueType max(ValueType const& first, ValueType const& second);
164
165template<typename ValueType>
166ValueType min(ValueType const& first, ValueType const& second);
167
168template<typename ValueType>
169ValueType sqrt(ValueType const& number);
170
171template<typename ValueType>
172ValueType abs(ValueType const& number);
173
174template<typename ValueType>
175ValueType floor(ValueType const& number);
176
177template<typename ValueType>
178ValueType ceil(ValueType const& number);
179
180template<typename ValueType>
181ValueType round(ValueType const& number);
182
183template<typename ValueType>
184ValueType log(ValueType const& number);
185
186template<typename ValueType>
187ValueType log10(ValueType const& number);
188
189template<typename ValueType>
190ValueType cos(ValueType const& number);
191
192template<typename ValueType>
193ValueType sin(ValueType const& number);
194
195template<typename ValueType>
196uint64_t numDigits(ValueType const& number);
197
201template<typename ValueType>
202uint64_t bitsize(ValueType const& number);
203
204template<typename ValueType>
205typename NumberTraits<ValueType>::IntegerType trunc(ValueType const& number);
206
207template<typename RationalType>
208typename NumberTraits<RationalType>::IntegerType numerator(RationalType const& number);
209
210template<typename RationalType>
211typename NumberTraits<RationalType>::IntegerType denominator(RationalType const& number);
212
216template<typename IntegerType>
217std::pair<IntegerType, IntegerType> divide(IntegerType const& dividend, IntegerType const& divisor);
218
219template<typename IntegerType>
220IntegerType mod(IntegerType const& first, IntegerType const& second);
221
222template<typename IntegerType>
223IntegerType gcd(IntegerType const& first, IntegerType const& second);
224
225template<typename IntegerType>
226IntegerType lcm(IntegerType const& first, IntegerType const& second);
227
228template<typename ValueType>
229std::string to_string(ValueType const& value);
230} // namespace utility
231} // namespace storm
ValueType max(ValueType const &first, ValueType const &second)
bool isPositive(ValueType const &a)
Definition constants.cpp:69
bool isOne(ValueType const &a)
Definition constants.cpp:39
NumberTraits< RationalType >::IntegerType denominator(RationalType const &number)
typename detail::ElementGreater< ValueType >::type ElementGreater
Definition constants.h:69
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:87
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:59
bool isAlmostZero(ValueType const &a)
Definition constants.cpp:98
bool isAlmostOne(ValueType const &a)
ValueType floor(ValueType const &number)
IntegerType lcm(IntegerType const &first, IntegerType const &second)
bool isZero(ValueType const &a)
Definition constants.cpp:44
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:26
ValueType infinity()
Definition constants.cpp:31
IntegerType gcd(IntegerType const &first, IntegerType const &second)
bool isNan(ValueType const &)
Definition constants.cpp:49
std::string to_string(ValueType const &value)
std::pair< ValueType, ValueType > minmax(std::vector< ValueType > const &values)
bool isNonNegative(ValueType const &a)
Definition constants.cpp:74
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:21
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)
uint64_t bitsize(ValueType const &number)
Returns the minimum number of bits to represent the given number.
typename detail::ElementLess< ValueType >::type ElementLess
Definition constants.h:66
ValueType log10(ValueType const &number)
ValueType round(ValueType const &number)
bool tryParseNumber(std::string const &input, RationalType &result)
Tries to parse a number from its string representation.
TargetType convertNumber(SourceType const &number)
bool operator()(double a, double b) const
Definition constants.h:54
bool operator()(double a, double b) const
Definition constants.h:38
std::greater< ValueType > type
Definition constants.h:50
std::less< ValueType > type
Definition constants.h:34