4#include <boost/optional.hpp>
19template<
typename ValueType>
21 size_t operator()(std::vector<ValueType>
const& vec)
const {
22 std::hash<ValueType> hasher;
24 for (ValueType
const& element : vec) {
25 seed ^= hasher(element) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
45 std::size_t position = std::find(vector.begin(), vector.end(), element) - vector.begin();
46 if (position == vector.size()) {
47 vector.emplace_back(std::move(element));
54 T
const& negativeValue = storm::utility::zero<T>()) {
56 vec.resize(positions.
size(), positiveValue);
58 while (index < positions.
size()) {
59 vec[index] = negativeValue;
63 vec.resize(positions.
size(), negativeValue);
64 for (uint64_t index : positions) {
65 vec[index] = positiveValue;
79 STORM_LOG_ASSERT(positions.
size() <= vector.size(),
"We cannot set positions that have not been initialized");
81 <<
") exceeds the size of the input vector ("
82 << values.size() <<
").");
83 uint_fast64_t oldPosition = 0;
84 for (
auto position : positions) {
85 vector[position] = values[oldPosition++];
99 STORM_LOG_ASSERT(positions.
size() <= vector.size(),
"We cannot set positions that have not been initialized");
100 for (
auto position : positions) {
101 vector[position] = value;
108 for (uint64_t i = 0; i < vec.size(); ++i) {
120template<
class OutputIterator,
class Size,
class Assignable>
121void iota_n(OutputIterator first, Size n, Assignable value) {
122 std::generate_n(first, n, [&value]() {
return value++; });
134 iota_n(std::back_inserter(v), diff,
min);
145 std::vector<uint_fast64_t> res = buildVectorForRange<uint_fast64_t>(0, v.size());
146 std::sort(res.begin(), res.end(), [&v](uint_fast64_t index1, uint_fast64_t index2) { return v[index1] > v[index2]; });
159 auto indexIt = sortedIndices.begin();
160 T
const* previous = &v[*indexIt];
161 for (++indexIt; indexIt != sortedIndices.end(); ++indexIt) {
162 T
const& current = v[*indexIt];
163 if (current == *previous) {
171template<
typename T,
typename Comparator>
172bool compareElementWise(std::vector<T>
const& left, std::vector<T>
const& right, Comparator comp = std::less<T>()) {
173 STORM_LOG_ASSERT(left.size() == right.size(),
"Expected that vectors for comparison have equal size");
174 return std::equal(left.begin(), left.end(), right.begin(), comp);
186 <<
") exceeds the size of the target vector ("
187 << vector.size() <<
").");
189 "Size mismatch of the positions vector (" << positions.
size() <<
") and the values vector (" << values.size() <<
").");
190 auto targetIt = vector.begin();
191 for (
auto position : positions) {
192 *targetIt = values[position];
207 std::vector<T>
const& values) {
208 auto targetIt = vector.begin();
209 for (
auto position : positions) {
210 for (uint_fast64_t i = rowGrouping[position]; i < rowGrouping[position + 1]; ++i, ++targetIt) {
211 *targetIt = values[i];
226void selectVectorValues(std::vector<T>& vector, std::vector<uint_fast64_t>
const& rowGroupToRowIndexMapping, std::vector<uint_fast64_t>
const& rowGrouping,
227 std::vector<T>
const& values) {
228 auto targetIt = vector.begin();
229 for (uint_fast64_t i = 0; i < vector.size(); ++i, ++targetIt) {
230 *targetIt = values[rowGrouping[i] + rowGroupToRowIndexMapping[i]];
242void selectVectorValues(std::vector<T>& vector, std::vector<uint_fast64_t>
const& indexSequence, std::vector<T>
const& values) {
244 "The number of selected positions (" << indexSequence.size() <<
") exceeds the size of the target vector (" << vector.size() <<
").");
246 for (uint_fast64_t vectorIndex = 0; vectorIndex < vector.size(); ++vectorIndex) {
247 vector[vectorIndex] = values[indexSequence[vectorIndex]];
262 std::vector<T>
const& values) {
263 auto targetIt = vector.begin();
264 for (
auto position : positions) {
265 for (uint_fast64_t i = rowGrouping[position]; i < rowGrouping[position + 1]; ++i, ++targetIt) {
266 *targetIt = values[position];
278 for (
auto& element : vector) {
279 element = storm::utility::one<T>() - element;
285 std::vector<uint_fast64_t>
const& rowGroupIndices) {
286 auto targetIt = target.begin();
287 for (
auto group :
filter) {
288 auto it = source.cbegin() + rowGroupIndices[group];
289 auto ite = source.cbegin() + rowGroupIndices[group + 1];
290 for (; it != ite; ++targetIt, ++it) {
305void addVectorToGroupedVector(std::vector<T>& target, std::vector<T>
const& source, std::vector<uint_fast64_t>
const& rowGroupIndices) {
306 auto targetIt = target.begin();
307 auto sourceIt = source.cbegin();
308 auto sourceIte = source.cend();
309 auto rowGroupIt = rowGroupIndices.cbegin();
311 for (; sourceIt != sourceIte; ++sourceIt) {
312 uint_fast64_t current = *rowGroupIt;
314 uint_fast64_t next = *rowGroupIt;
315 for (; current < next; ++targetIt, ++current) {
316 *targetIt += *sourceIt;
331 std::vector<uint_fast64_t>
const& rowGroupIndices) {
332 auto targetIt = target.begin();
333 for (
auto group :
filter) {
334 uint_fast64_t current = rowGroupIndices[group];
335 uint_fast64_t next = rowGroupIndices[group + 1];
336 for (; current < next; ++current, ++targetIt) {
337 *targetIt += source[group];
350template<
class InValueType1,
class InValueType2,
class OutValueType,
class Operation>
351void applyPointwiseTernary(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target,
352 Operation f = Operation()) {
353 auto firstIt = firstOperand.begin();
354 auto firstIte = firstOperand.end();
355 auto secondIt = secondOperand.begin();
356 auto targetIt = target.begin();
357 while (firstIt != firstIte) {
358 *targetIt = f(*firstIt, *secondIt, *targetIt);
373template<
class InValueType1,
class InValueType2,
class OutValueType,
class Operation>
374void applyPointwise(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target,
375 Operation f = Operation()) {
376 std::transform(firstOperand.begin(), firstOperand.end(), secondOperand.begin(), target.begin(), f);
386template<
class InValueType,
class OutValueType,
class Operation>
387void applyPointwise(std::vector<InValueType>
const& operand, std::vector<OutValueType>& target, Operation f = Operation()) {
388 std::transform(operand.begin(), operand.end(), target.begin(), f);
398template<
class InValueType1,
class InValueType2,
class OutValueType>
399void addVectors(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
400 applyPointwise<InValueType1, InValueType2, OutValueType, std::plus<>>(firstOperand, secondOperand, target);
410template<
class InValueType1,
class InValueType2,
class OutValueType>
411void subtractVectors(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
412 applyPointwise<InValueType1, InValueType2, OutValueType, std::minus<>>(firstOperand, secondOperand, target);
422template<
class InValueType1,
class InValueType2,
class OutValueType>
424 std::vector<OutValueType>& target) {
425 applyPointwise<InValueType1, InValueType2, OutValueType, std::multiplies<>>(firstOperand, secondOperand, target);
435template<
class InValueType1,
class InValueType2,
class OutValueType>
436void divideVectorsPointwise(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
437 applyPointwise<InValueType1, InValueType2, OutValueType, std::divides<>>(firstOperand, secondOperand, target);
446template<
class ValueType1,
class ValueType2>
448 applyPointwise<ValueType1, ValueType1>(target, target, [&](ValueType1
const& argument) -> ValueType1 {
return argument * factor; });
459template<
class InValueType1,
class InValueType2,
class InValueType3>
460void addScaledVector(std::vector<InValueType1>& firstOperand, std::vector<InValueType2>
const& secondOperand, InValueType3
const& factor) {
461 applyPointwise<InValueType1, InValueType2, InValueType1>(
462 firstOperand, secondOperand, firstOperand, [&](InValueType1
const& val1, InValueType2
const& val2) -> InValueType1 {
return val1 + (factor * val2); });
473T
dotProduct(std::vector<T>
const& firstOperand, std::vector<T>
const& secondOperand) {
474 return std::inner_product(firstOperand.begin(), firstOperand.end(), secondOperand.begin(), storm::utility::zero<T>());
489 uint_fast64_t currentIndex = 0;
490 for (
auto const& value : values) {
491 if (function(value)) {
492 result.
set(currentIndex,
true);
509 return filter<T>(values, [](T
const& value) ->
bool {
return value > storm::utility::zero<T>(); });
520 return filter<T>(values, storm::utility::isZero<T>);
531 return filter<T>(values, storm::utility::isOne<T>);
542 return filter<T>(values, storm::utility::isInfinity<T>);
554 VT sum = storm::utility::zero<VT>();
575 VT current = values[*it];
578 for (; it != ite; ++it) {
579 current = std::max(values[*it], current);
598 VT current = values[*it];
601 for (; it != ite; ++it) {
602 current = std::min(values[*it], current);
617template<
class T,
class Filter>
618void reduceVector(std::vector<T>
const& source, std::vector<T>& target, std::vector<uint_fast64_t>
const& rowGrouping, std::vector<uint_fast64_t>* choices) {
620 typename std::vector<T>::iterator targetIt = target.begin();
621 typename std::vector<T>::iterator targetIte = target.end();
622 typename std::vector<uint_fast64_t>::const_iterator rowGroupingIt = rowGrouping.begin();
623 typename std::vector<T>::const_iterator sourceIt = source.begin();
624 typename std::vector<T>::const_iterator sourceIte;
625 typename std::vector<uint_fast64_t>::iterator choiceIt;
627 choiceIt = choices->begin();
631 T oldSelectedChoiceValue;
632 uint64_t selectedChoice;
634 uint64_t currentRow = 0;
635 for (; targetIt != targetIte; ++targetIt, ++rowGroupingIt, ++choiceIt) {
637 if (*rowGroupingIt != *(rowGroupingIt + 1)) {
638 *targetIt = *sourceIt;
642 if (*choiceIt == 0) {
643 oldSelectedChoiceValue = *targetIt;
650 for (sourceIte = source.begin() + *(rowGroupingIt + 1); sourceIt != sourceIte; ++sourceIt, ++currentRow) {
651 if (choices && *rowGroupingIt + *choiceIt == currentRow) {
652 oldSelectedChoiceValue = *sourceIt;
655 if (f(*sourceIt, *targetIt)) {
656 *targetIt = *sourceIt;
658 selectedChoice = std::distance(source.begin(), sourceIt) - *rowGroupingIt;
663 if (choices && f(*targetIt, oldSelectedChoiceValue)) {
664 *choiceIt = selectedChoice;
668 *targetIt = storm::utility::zero<T>();
682void reduceVectorMin(std::vector<T>
const& source, std::vector<T>& target, std::vector<uint_fast64_t>
const& rowGrouping,
683 std::vector<uint_fast64_t>* choices =
nullptr) {
684 reduceVector<T, storm::utility::ElementLess<T>>(source, target, rowGrouping, choices);
696void reduceVectorMax(std::vector<T>
const& source, std::vector<T>& target, std::vector<uint_fast64_t>
const& rowGrouping,
697 std::vector<uint_fast64_t>* choices =
nullptr) {
698 reduceVector<T, storm::utility::ElementGreater<T>>(source, target, rowGrouping, choices);
712 std::vector<uint_fast64_t>
const& rowGrouping, std::vector<uint_fast64_t>* choices =
nullptr) {
713 if (dir == storm::solver::OptimizationDirection::Minimize) {
733 if (storm::utility::isZero<T>(val1)) {
736 T relDiff = (val1 - val2) / val1;
741 T diff = val1 - val2;
751inline bool equalModuloPrecision(
double const& val1,
double const& val2,
double const& precision,
bool relativeError) {
756 double relDiff = (val1 - val2) / val1;
761 double diff = val1 - val2;
779bool equalModuloPrecision(std::vector<T>
const& vectorLeft, std::vector<T>
const& vectorRight, T
const& precision,
bool relativeError) {
780 STORM_LOG_ASSERT(vectorLeft.size() == vectorRight.size(),
"Lengths of vectors does not match.");
782 auto leftIt = vectorLeft.begin();
783 auto leftIte = vectorLeft.end();
784 auto rightIt = vectorRight.begin();
785 for (; leftIt != leftIte; ++leftIt, ++rightIt) {
807 bool relativeError) {
808 STORM_LOG_ASSERT(vectorLeft.size() == vectorRight.size(),
"Lengths of vectors does not match.");
810 for (
auto position : positions) {
811 if (!
equalModuloPrecision(vectorLeft[position], vectorRight[position], precision, relativeError)) {
831bool equalModuloPrecision(std::vector<T>
const& vectorLeft, std::vector<T>
const& vectorRight, std::vector<uint_fast64_t>
const& positions, T
const& precision,
832 bool relativeError) {
833 STORM_LOG_ASSERT(vectorLeft.size() == vectorRight.size(),
"Lengths of vectors does not match.");
835 for (uint_fast64_t position : positions) {
836 if (!
equalModuloPrecision(vectorLeft[position], vectorRight[position], precision, relativeError)) {
846 T res = storm::utility::zero<T>();
847 for (
auto const& element : vector) {
855 T maxDiff = storm::utility::zero<T>();
856 auto leftIt = vectorLeft.begin();
857 auto leftIte = vectorLeft.end();
858 auto rightIt = vectorRight.begin();
859 for (; leftIt != leftIte; ++leftIt, ++rightIt) {
860 T diff = *leftIt - *rightIt;
862 maxDiff = maxDiff < possDiff ? possDiff : maxDiff;
871 T result = storm::utility::zero<T>();
873 auto b1It = b1.begin();
874 auto b1Ite = b1.end();
875 auto b2It = b2.begin();
877 for (; b1It != b1Ite; ++b1It, ++b2It) {
878 result += storm::utility::pow<T>(*b1It - *b2It, 2);
887template<
typename ValueType>
888void clip(std::vector<ValueType>& x, boost::optional<ValueType>
const& lowerBound, boost::optional<ValueType>
const& upperBound) {
889 for (
auto& entry : x) {
890 if (lowerBound && entry < lowerBound.get()) {
891 entry = lowerBound.get();
892 }
else if (upperBound && entry > upperBound.get()) {
893 entry = upperBound.get();
901template<
typename ValueType>
902void clip(std::vector<ValueType>& x, ValueType
const& bound,
bool boundFromBelow) {
903 for (
auto& entry : x) {
904 if (boundFromBelow && entry < bound) {
906 }
else if (!boundFromBelow && entry > bound) {
915template<
typename ValueType>
916void clip(std::vector<ValueType>& x, std::vector<ValueType>
const& bounds,
bool boundFromBelow) {
917 auto boundsIt = bounds.begin();
918 for (
auto& entry : x) {
919 if (boundFromBelow && entry < *boundsIt) {
921 }
else if (!boundFromBelow && entry > *boundsIt) {
940 uint_fast64_t currentRowCount = 0;
941 uint_fast64_t currentIndexCount = 1;
948 for (
auto index : constraint) {
949 subVector[currentIndexCount] = currentRowCount + offsetVector[index + 1] - offsetVector[index];
950 currentRowCount += offsetVector[index + 1] - offsetVector[index];
965template<
typename TargetType,
typename SourceType>
967 std::vector<TargetType> resultVector;
968 resultVector.reserve(oldVector.size());
969 for (
auto const& oldValue : oldVector) {
970 resultVector.push_back(storm::utility::convertNumber<TargetType>(oldValue));
984template<
typename TargetType,
typename SourceType>
986 assert(inputVector.size() == targetVector.size());
987 applyPointwise(inputVector, targetVector, [](SourceType
const& v) {
return storm::utility::convertNumber<TargetType>(v); });
993template<
typename NewValueType,
typename ValueType>
994std::vector<NewValueType>
toValueType(std::vector<ValueType>
const& oldVector) {
995 std::vector<NewValueType> resultVector;
996 resultVector.reserve(oldVector.size());
997 for (
auto const& oldValue : oldVector) {
998 resultVector.push_back(
static_cast<NewValueType
>(oldValue));
1000 return resultVector;
1003template<
typename ValueType,
typename TargetValueType>
1004typename std::enable_if<std::is_same<ValueType, storm::RationalNumber>::value, std::pair<std::vector<TargetValueType>, ValueType>>::type
toIntegralVector(
1005 std::vector<ValueType>
const& vec) {
1007 std::set<ValueType> occurringNonZeroNumbers;
1008 for (
auto const& v : vec) {
1010 occurringNonZeroNumbers.insert(v);
1016 if (occurringNonZeroNumbers.empty()) {
1017 factor = storm::utility::one<ValueType>();
1018 }
else if (occurringNonZeroNumbers.size() == 1) {
1019 factor = *occurringNonZeroNumbers.begin();
1023 auto numberIt = occurringNonZeroNumbers.begin();
1025 for (++numberIt; numberIt != occurringNonZeroNumbers.end(); ++numberIt) {
1029 numberIt = occurringNonZeroNumbers.begin();
1030 ValueType gcd = *numberIt * lcm;
1031 for (++numberIt; numberIt != occurringNonZeroNumbers.end(); ++numberIt) {
1032 gcd = carl::gcd(gcd,
static_cast<ValueType
>(*numberIt * lcm));
1039 std::vector<TargetValueType> result;
1040 result.reserve(vec.size());
1041 for (
auto const& v : vec) {
1042 ValueType vScaled = v / factor;
1044 result.push_back(storm::utility::convertNumber<TargetValueType, ValueType>(vScaled));
1046 return std::make_pair(std::move(result), std::move(factor));
1049template<
typename ValueType,
typename TargetValueType>
1050typename std::enable_if<!std::is_same<ValueType, storm::RationalNumber>::value, std::pair<std::vector<TargetValueType>, ValueType>>::type
toIntegralVector(
1051 std::vector<ValueType>
const& vec) {
1053 auto rationalNumberVec = convertNumericVector<storm::RationalNumber>(vec);
1054 auto rationalNumberResult = toIntegralVector<storm::RationalNumber, TargetValueType>(rationalNumberVec);
1056 return std::make_pair(std::move(rationalNumberResult.first), storm::utility::convertNumber<ValueType>(rationalNumberResult.second));
1059template<
typename Type>
1061 std::vector<Type> result;
1063 for (
auto index :
filter) {
1064 result.push_back(in[index]);
1070template<
typename Type>
1073 uint_fast64_t size = v.size();
1076 if (firstUnsetIndex < size) {
1077 auto vIt = v.begin() + firstUnsetIndex;
1079 *vIt = std::move(v[index]);
1082 v.resize(vIt - v.begin());
1090 return std::any_of(v.begin(), v.end(), [](T value) { return value < storm::utility::zero<T>(); });
1095 return std::any_of(v.begin(), v.end(), [](T value) { return value > storm::utility::zero<T>(); });
1100 return std::any_of(v.begin(), v.end(), [](T value) { return !storm::utility::isZero(value); });
1105 return std::any_of(v.begin(), v.end(), [](T value) { return storm::utility::isZero(value); });
1110 return std::any_of(v.begin(), v.end(), [](T value) { return storm::utility::isInfinity(value); });
1115 std::vector<T> result;
1116 result.reserve(source.size());
1117 for (uint64_t sourceIndex : inversePermutation) {
1118 result.push_back(source[sourceIndex]);
1125 std::vector<uint64_t>
const& rowGroupIndices) {
1126 STORM_LOG_ASSERT(inversePermutation.size() == rowGroupIndices.size() - 1,
"Inverse permutation and row group indices do not match.");
1127 std::vector<T> result;
1128 result.reserve(source.size());
1129 for (
auto sourceGroupIndex : inversePermutation) {
1130 for (uint64_t sourceIndex = rowGroupIndices[sourceGroupIndex]; sourceIndex < rowGroupIndices[sourceGroupIndex + 1]; ++sourceIndex) {
1131 result.push_back(source[sourceIndex]);
1134 STORM_LOG_ASSERT(result.size() == source.size(),
"result has unexpected length.");
1144template<
typename ValueType>
1145std::string
toString(std::vector<ValueType>
const& vector) {
1146 std::stringstream stream;
1147 stream <<
"vector (" << vector.size() <<
") [ ";
1148 if (!vector.empty()) {
1149 for (uint_fast64_t i = 0; i < vector.size() - 1; ++i) {
1150 stream << vector[i] <<
", ";
1152 stream << vector.back();
1155 return stream.str();
A bit vector that is internally represented as a vector of 64-bit values.
uint64_t getNextSetIndex(uint64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to true in the bit vector.
const_iterator end() const
Returns an iterator pointing at the element past the back of the bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
uint64_t getNextUnsetIndex(uint64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to false in the bit vector.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
const_iterator begin() const
Returns an iterator to the indices of the set bits in the bit vector.
size_t size() const
Retrieves the number of bits this bit vector can store.
#define STORM_LOG_ASSERT(cond, message)
std::size_t findOrInsert(std::vector< T > &vector, T &&element)
Finds the given element in the given vector.
std::vector< TargetType > convertNumericVector(std::vector< SourceType > const &oldVector)
Converts the given vector to the given ValueType Assumes that both, TargetType and SourceType are num...
storm::storage::BitVector filter(std::vector< T > const &values, std::function< bool(T const &value)> const &function)
Retrieves a bit vector containing all the indices for which the value at this position makes the give...
void applyPointwiseTernary(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target, Operation f=Operation())
Applies the given operation pointwise on the two given vectors and writes the result to the third vec...
VT min_if(std::vector< VT > const &values, storm::storage::BitVector const &filter)
Computes the minimum of the entries from the values that are selected by the (non-empty) filter.
void addVectors(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Adds the two given vectors and writes the result to the target vector.
void divideVectorsPointwise(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Divides the two given vectors (pointwise) and writes the result to the target vector.
T dotProduct(std::vector< T > const &firstOperand, std::vector< T > const &secondOperand)
Computes the dot product (aka scalar product) and returns the result.
std::vector< NewValueType > toValueType(std::vector< ValueType > const &oldVector)
Converts the given vector to the given ValueType.
bool hasInfinityEntry(std::vector< T > const &v)
void addVectorToGroupedVector(std::vector< T > &target, std::vector< T > const &source, std::vector< uint_fast64_t > const &rowGroupIndices)
Adds the source vector to the target vector in a way such that the i-th entry is added to all element...
void setNonzeroIndices(std::vector< T > const &vec, storm::storage::BitVector &bv)
VT max_if(std::vector< VT > const &values, storm::storage::BitVector const &filter)
Computes the maximum of the entries from the values that are selected by the (non-empty) filter.
void setVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Sets the provided values at the provided positions in the given vector.
bool compareElementWise(std::vector< T > const &left, std::vector< T > const &right, Comparator comp=std::less< T >())
std::vector< T > buildVectorForRange(T min, T max)
Constructs a vector [min, min+1, ...., max-1].
void setAllValues(std::vector< T > &vec, storm::storage::BitVector const &positions, T const &positiveValue=storm::utility::one< T >(), T const &negativeValue=storm::utility::zero< T >())
void addFilteredVectorGroupsToGroupedVector(std::vector< T > &target, std::vector< T > const &source, storm::storage::BitVector const &filter, std::vector< uint_fast64_t > const &rowGroupIndices)
bool equalModuloPrecision(T const &val1, T const &val2, T const &precision, bool relativeError=true)
Compares the given elements and determines whether they are equal modulo the given precision.
void selectVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Selects the elements from a vector at the specified positions and writes them consecutively into anot...
T computeSquaredNorm2Difference(std::vector< T > const &b1, std::vector< T > const &b2)
bool isUnique(std::vector< T > const &v)
Returns true iff every element in the given vector is unique, i.e., there are no i,...
T maximumElementDiff(std::vector< T > const &vectorLeft, std::vector< T > const &vectorRight)
void reduceVectorMinOrMax(storm::solver::OptimizationDirection dir, std::vector< T > const &source, std::vector< T > &target, std::vector< uint_fast64_t > const &rowGrouping, std::vector< uint_fast64_t > *choices=nullptr)
Reduces the given source vector by selecting either the smallest or the largest out of each row group...
storm::storage::BitVector filterGreaterZero(std::vector< T > const &values)
Retrieves a bit vector containing all the indices for which the value at this position is greater tha...
void reduceVector(std::vector< T > const &source, std::vector< T > &target, std::vector< uint_fast64_t > const &rowGrouping, std::vector< uint_fast64_t > *choices)
Reduces the given source vector by selecting an element according to the given filter out of each row...
void addScaledVector(std::vector< InValueType1 > &firstOperand, std::vector< InValueType2 > const &secondOperand, InValueType3 const &factor)
Computes x:= x + a*y, i.e., adds each element of the first vector and (the corresponding element of t...
std::string toString(std::vector< ValueType > const &vector)
Output vector as string.
void multiplyVectorsPointwise(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Multiplies the two given vectors (pointwise) and writes the result to the target vector.
bool hasPositiveEntry(std::vector< T > const &v)
storm::storage::BitVector filterOne(std::vector< T > const &values)
Retrieves a bit vector containing all the indices for which the value at this position is equal to on...
bool hasNegativeEntry(std::vector< T > const &v)
T maximumElementAbs(std::vector< T > const &vector)
void clip(std::vector< ValueType > &x, boost::optional< ValueType > const &lowerBound, boost::optional< ValueType > const &upperBound)
Takes the input vector and ensures that all entries conform to the bounds.
void addFilteredVectorToGroupedVector(std::vector< T > &target, std::vector< T > const &source, storm::storage::BitVector const &filter, std::vector< uint_fast64_t > const &rowGroupIndices)
Adds the source vector to the target vector in a way such that the i-th selected entry is added to al...
void selectVectorValuesRepeatedly(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< uint_fast64_t > const &rowGrouping, std::vector< T > const &values)
Selects values from a vector at the specified positions and writes them into another vector as often ...
void applyPointwise(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target, Operation f=Operation())
Applies the given operation pointwise on the two given vectors and writes the result to the third vec...
void reduceVectorMin(std::vector< T > const &source, std::vector< T > &target, std::vector< uint_fast64_t > const &rowGrouping, std::vector< uint_fast64_t > *choices=nullptr)
Reduces the given source vector by selecting the smallest element out of each row group.
VT sum_if(std::vector< VT > const &values, storm::storage::BitVector const &filter)
Sum the entries from values that are set to one in the filter vector.
storm::storage::BitVector filterInfinity(std::vector< T > const &values)
Retrieves a bit vector containing all the indices for which the value at this position is equal to on...
std::vector< T > applyInversePermutation(std::vector< uint64_t > const &inversePermutation, std::vector< T > const &source)
void filterVectorInPlace(std::vector< Type > &v, storm::storage::BitVector const &filter)
void iota_n(OutputIterator first, Size n, Assignable value)
Iota function as a helper for efficient creating a range in a vector.
void subtractVectors(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Subtracts the two given vectors and writes the result to the target vector.
std::vector< uint_fast64_t > getSortedIndices(std::vector< T > const &v)
Returns a list of indices such that the first index refers to the highest entry of the given vector,...
bool hasZeroEntry(std::vector< T > const &v)
storm::storage::BitVector filterZero(std::vector< T > const &values)
Retrieves a bit vector containing all the indices for which the value at this position is equal to ze...
void scaleVectorInPlace(std::vector< ValueType1 > &target, ValueType2 const &factor)
Multiplies each element of the given vector with the given factor and writes the result into the vect...
std::vector< T > applyInversePermutationToGroupedVector(std::vector< uint64_t > const &inversePermutation, std::vector< T > const &source, std::vector< uint64_t > const &rowGroupIndices)
std::vector< T > getConstrainedOffsetVector(std::vector< T > const &offsetVector, storm::storage::BitVector const &constraint)
Takes the given offset vector and applies the given contraint.
bool hasNonZeroEntry(std::vector< T > const &v)
void subtractFromConstantOneVector(std::vector< T > &vector)
Subtracts the given vector from the constant one-vector and writes the result to the input vector.
void reduceVectorMax(std::vector< T > const &source, std::vector< T > &target, std::vector< uint_fast64_t > const &rowGrouping, std::vector< uint_fast64_t > *choices=nullptr)
Reduces the given source vector by selecting the largest element out of each row group.
std::enable_if< std::is_same< ValueType, storm::RationalNumber >::value, std::pair< std::vector< TargetValueType >, ValueType > >::type toIntegralVector(std::vector< ValueType > const &vec)
std::vector< Type > filterVector(std::vector< Type > const &in, storm::storage::BitVector const &filter)
ValueType max(ValueType const &first, ValueType const &second)
ValueType min(ValueType const &first, ValueType const &second)
bool isAlmostZero(ValueType const &a)
std::pair< ValueType, ValueType > asFraction(ValueType const &number)
bool isZero(ValueType const &a)
bool isInteger(ValueType const &number)
ValueType abs(ValueType const &number)
size_t operator()(std::vector< ValueType > const &vec) const