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));
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;
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++];
100 for (
auto position : positions) {
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);
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]];
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) {
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) {
410template<
class InValueType1,
class InValueType2,
class OutValueType>
411void subtractVectors(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
422template<
class InValueType1,
class InValueType2,
class OutValueType>
424 std::vector<OutValueType>& target) {
435template<
class InValueType1,
class InValueType2,
class OutValueType>
436void divideVectorsPointwise(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
446template<
class ValueType1,
class ValueType2>
459template<
class InValueType1,
class InValueType2,
class InValueType3>
460void addScaledVector(std::vector<InValueType1>& firstOperand, std::vector<InValueType2>
const& secondOperand, InValueType3
const& factor) {
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);
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;
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) {
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) {
712 std::vector<uint_fast64_t>
const& rowGrouping, std::vector<uint_fast64_t>* choices =
nullptr) {
713 if (dir == storm::solver::OptimizationDirection::Minimize) {
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)) {
847 for (
auto const& element :
vector) {
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;
873 auto b1It = b1.begin();
874 auto b1Ite = b1.end();
875 auto b2It = b2.begin();
877 for (; b1It != b1Ite; ++b1It, ++b2It) {
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) {
984template<
typename TargetType,
typename SourceType>
986 assert(inputVector.size() == targetVector.size());
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()) {
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;
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) {
1059template<
typename Type>
1061 std::vector<Type> result;
1062 result.reserve(
filter.getNumberOfSetBits());
1063 for (
auto index :
filter) {
1064 result.push_back(in[index]);
1070template<
typename Type>
1072 STORM_LOG_ASSERT(v.size() ==
filter.size(),
"The filter size does not match the size of the input vector");
1073 uint_fast64_t size = v.size();
1075 uint_fast64_t firstUnsetIndex =
filter.getNextUnsetIndex(0);
1076 if (firstUnsetIndex < size) {
1077 auto vIt = v.begin() + firstUnsetIndex;
1078 for (uint_fast64_t index =
filter.getNextSetIndex(firstUnsetIndex + 1); index != size; index =
filter.getNextSetIndex(index + 1)) {
1079 *vIt = std::move(v[index]);
1082 v.resize(vIt - v.begin());
1103 <<
") must match the size of the input vector ("
1104 <<
vector.size() <<
").");
1105 auto readPos =
vector.size();
1106 vector.resize(positions.
size(), defaultValue);
1108 while (writePos > 0) {
1110 if (positions.
get(writePos)) {
1112 if (readPos != writePos) {
1113 STORM_LOG_ASSERT(readPos < writePos,
"We shall not write to positions that we later still have to read from.");
1117 vector[writePos] = defaultValue;
1124 return std::any_of(v.begin(), v.end(), [](T value) { return value < storm::utility::zero<T>(); });
1129 return std::any_of(v.begin(), v.end(), [](T value) { return value > storm::utility::zero<T>(); });
1134 return std::any_of(v.begin(), v.end(), [](T value) { return !storm::utility::isZero(value); });
1139 return std::any_of(v.begin(), v.end(), [](T value) { return storm::utility::isZero(value); });
1144 return std::any_of(v.begin(), v.end(), [](T value) { return storm::utility::isInfinity(value); });
1149 std::vector<T> result;
1150 result.reserve(source.size());
1151 for (uint64_t sourceIndex : inversePermutation) {
1152 result.push_back(source[sourceIndex]);
1159 std::vector<uint64_t>
const& rowGroupIndices) {
1160 STORM_LOG_ASSERT(inversePermutation.size() == rowGroupIndices.size() - 1,
"Inverse permutation and row group indices do not match.");
1161 std::vector<T> result;
1162 result.reserve(source.size());
1163 for (
auto sourceGroupIndex : inversePermutation) {
1164 for (uint64_t sourceIndex = rowGroupIndices[sourceGroupIndex]; sourceIndex < rowGroupIndices[sourceGroupIndex + 1]; ++sourceIndex) {
1165 result.push_back(source[sourceIndex]);
1168 STORM_LOG_ASSERT(result.size() == source.size(),
"result has unexpected length.");
1178template<
typename ValueType>
1180 std::stringstream stream;
1181 stream <<
"vector (" <<
vector.size() <<
") [ ";
1183 for (uint_fast64_t i = 0; i <
vector.size() - 1; ++i) {
1184 stream <<
vector[i] <<
", ";
1189 return stream.str();
A bit vector that is internally represented as a vector of 64-bit values.
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.
uint64_t getStartOfZeroSequenceBefore(uint64_t endIndex) const
Retrieves the smallest index i such that all bits in the range [i,endIndex) are 0.
size_t size() const
Retrieves the number of bits this bit vector can store.
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
#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 blowUpVectorInPlace(std::vector< T > &vector, storm::storage::BitVector const &positions, T const &defaultValue=storm::utility::zero< T >())
Gets as input a vector with size n and a BitVector with size m>=n and exactly n set bits.
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)
bool isOne(ValueType const &a)
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)
ValueType pow(ValueType const &value, int_fast64_t exponent)
bool isInfinity(ValueType const &a)
TargetType convertNumber(SourceType const &number)
size_t operator()(std::vector< ValueType > const &vec) const