4#include <boost/optional.hpp>
20template<
typename ValueType>
22 size_t operator()(std::vector<ValueType>
const& vec)
const {
23 std::hash<ValueType> hasher;
25 for (ValueType
const& element : vec) {
26 seed ^= hasher(element) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
46 std::size_t position = std::find(
vector.begin(),
vector.end(), element) -
vector.begin();
47 if (position ==
vector.size()) {
48 vector.emplace_back(std::forward<T>(element));
57 vec.resize(positions.
size(), positiveValue);
59 while (index < positions.
size()) {
60 vec[index] = negativeValue;
64 vec.resize(positions.
size(), negativeValue);
65 for (uint64_t index : positions) {
66 vec[index] = positiveValue;
78template<
class T,
class S>
82 <<
") exceeds the size of the input vector ("
83 << values.size() <<
").");
84 uint_fast64_t oldPosition = 0;
85 for (uint64_t position : positions) {
86 vector[position] = values[oldPosition++];
98template<
class T,
class S>
101 for (uint64_t position : positions) {
109 for (uint64_t i = 0; i < vec.size(); ++i) {
121template<
class OutputIterator,
class Size,
class Assignable>
122void iota_n(OutputIterator first, Size n, Assignable value) {
123 std::generate_n(first, n, [&value]() {
return value++; });
135 iota_n(std::back_inserter(v), diff,
min);
147 std::sort(res.begin(), res.end(), [&v](uint_fast64_t index1, uint_fast64_t index2) { return v[index1] > v[index2]; });
160 auto indexIt = sortedIndices.begin();
161 T
const* previous = &v[*indexIt];
162 for (++indexIt; indexIt != sortedIndices.end(); ++indexIt) {
163 T
const& current = v[*indexIt];
164 if (current == *previous) {
172template<
typename T,
typename Comparator>
173bool compareElementWise(std::vector<T>
const& left, std::vector<T>
const& right, Comparator comp = std::less<T>()) {
174 STORM_LOG_ASSERT(left.size() == right.size(),
"Expected that vectors for comparison have equal size.");
175 return std::equal(left.begin(), left.end(), right.begin(), comp);
187 <<
") exceeds the size of the target vector ("
188 <<
vector.size() <<
").");
190 "Size mismatch of the positions vector (" << positions.
size() <<
") and the values vector (" << values.size() <<
").");
191 auto targetIt =
vector.begin();
192 for (uint64_t position : positions) {
193 *targetIt = values[position];
208 std::vector<T>
const& values) {
209 auto targetIt =
vector.begin();
210 for (uint64_t position : positions) {
211 for (uint_fast64_t i = rowGrouping[position]; i < rowGrouping[position + 1]; ++i, ++targetIt) {
212 *targetIt = values[i];
227void selectVectorValues(std::vector<T>&
vector, std::vector<uint_fast64_t>
const& rowGroupToRowIndexMapping, std::vector<uint_fast64_t>
const& rowGrouping,
228 std::vector<T>
const& values) {
229 auto targetIt =
vector.begin();
230 for (uint_fast64_t i = 0; i <
vector.size(); ++i, ++targetIt) {
231 *targetIt = values[rowGrouping[i] + rowGroupToRowIndexMapping[i]];
245 "The number of selected positions (" << indexSequence.size() <<
") exceeds the size of the target vector (" <<
vector.size() <<
").");
247 for (uint_fast64_t vectorIndex = 0; vectorIndex <
vector.size(); ++vectorIndex) {
248 vector[vectorIndex] = values[indexSequence[vectorIndex]];
263 std::vector<T>
const& values) {
264 auto targetIt =
vector.begin();
265 for (uint64_t position : positions) {
266 for (uint_fast64_t i = rowGrouping[position]; i < rowGrouping[position + 1]; ++i, ++targetIt) {
267 *targetIt = values[position];
279 for (
auto& element :
vector) {
286 std::vector<uint_fast64_t>
const& rowGroupIndices) {
287 auto targetIt = target.begin();
288 for (uint64_t group :
filter) {
289 auto it = source.cbegin() + rowGroupIndices[group];
290 auto ite = source.cbegin() + rowGroupIndices[group + 1];
291 for (; it != ite; ++targetIt, ++it) {
306void addVectorToGroupedVector(std::vector<T>& target, std::vector<T>
const& source, std::vector<uint_fast64_t>
const& rowGroupIndices) {
307 auto targetIt = target.begin();
308 auto sourceIt = source.cbegin();
309 auto sourceIte = source.cend();
310 auto rowGroupIt = rowGroupIndices.cbegin();
312 for (; sourceIt != sourceIte; ++sourceIt) {
313 uint_fast64_t current = *rowGroupIt;
315 uint_fast64_t next = *rowGroupIt;
316 for (; current < next; ++targetIt, ++current) {
317 *targetIt += *sourceIt;
332 std::vector<uint_fast64_t>
const& rowGroupIndices) {
333 auto targetIt = target.begin();
334 for (uint64_t group :
filter) {
335 uint_fast64_t current = rowGroupIndices[group];
336 uint_fast64_t next = rowGroupIndices[group + 1];
337 for (; current < next; ++current, ++targetIt) {
338 *targetIt += source[group];
351template<
class InValueType1,
class InValueType2,
class OutValueType,
class Operation>
352void applyPointwiseTernary(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target,
353 Operation f = Operation()) {
354 auto firstIt = firstOperand.begin();
355 auto firstIte = firstOperand.end();
356 auto secondIt = secondOperand.begin();
357 auto targetIt = target.begin();
358 while (firstIt != firstIte) {
359 *targetIt = f(*firstIt, *secondIt, *targetIt);
374template<
class InValueType1,
class InValueType2,
class OutValueType,
class Operation>
375void applyPointwise(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target,
376 Operation f = Operation()) {
377 std::transform(firstOperand.begin(), firstOperand.end(), secondOperand.begin(), target.begin(), f);
387template<
class InValueType,
class OutValueType,
class Operation>
388void applyPointwise(std::vector<InValueType>
const& operand, std::vector<OutValueType>& target, Operation f = Operation()) {
389 std::transform(operand.begin(), operand.end(), target.begin(), f);
399template<
class InValueType1,
class InValueType2,
class OutValueType>
400void addVectors(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
411template<
class InValueType1,
class InValueType2,
class OutValueType>
412void subtractVectors(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
423template<
class InValueType1,
class InValueType2,
class OutValueType>
425 std::vector<OutValueType>& target) {
436template<
class InValueType1,
class InValueType2,
class OutValueType>
437void divideVectorsPointwise(std::vector<InValueType1>
const& firstOperand, std::vector<InValueType2>
const& secondOperand, std::vector<OutValueType>& target) {
447template<
class ValueType1,
class ValueType2>
460template<
class InValueType1,
class InValueType2,
class InValueType3>
461void addScaledVector(std::vector<InValueType1>& firstOperand, std::vector<InValueType2>
const& secondOperand, InValueType3
const& factor) {
463 firstOperand, secondOperand, firstOperand, [&](InValueType1
const& val1, InValueType2
const& val2) -> InValueType1 {
return val1 + (factor * val2); });
474T
dotProduct(std::vector<T>
const& firstOperand, std::vector<T>
const& secondOperand) {
475 return std::inner_product(firstOperand.begin(), firstOperand.end(), secondOperand.begin(),
storm::utility::zero<T>());
490 uint_fast64_t currentIndex = 0;
491 for (
auto const& value : values) {
492 if (function(value)) {
493 result.
set(currentIndex,
true);
556 for (uint64_t pos :
filter) {
576 VT current = values[*it];
579 for (; it != ite; ++it) {
580 current = std::max(values[*it], current);
599 VT current = values[*it];
602 for (; it != ite; ++it) {
603 current = std::min(values[*it], current);
618template<
class T,
class Filter>
619void reduceVector(std::vector<T>
const& source, std::vector<T>& target, std::vector<uint_fast64_t>
const& rowGrouping, std::vector<uint_fast64_t>* choices) {
621 typename std::vector<T>::iterator targetIt = target.begin();
622 typename std::vector<T>::iterator targetIte = target.end();
623 typename std::vector<uint_fast64_t>::const_iterator rowGroupingIt = rowGrouping.begin();
624 typename std::vector<T>::const_iterator sourceIt = source.begin();
625 typename std::vector<T>::const_iterator sourceIte;
626 typename std::vector<uint_fast64_t>::iterator choiceIt;
628 choiceIt = choices->begin();
632 T oldSelectedChoiceValue;
633 uint64_t selectedChoice;
635 uint64_t currentRow = 0;
636 for (; targetIt != targetIte; ++targetIt, ++rowGroupingIt, ++choiceIt) {
638 if (*rowGroupingIt != *(rowGroupingIt + 1)) {
639 *targetIt = *sourceIt;
643 if (*choiceIt == 0) {
644 oldSelectedChoiceValue = *targetIt;
651 for (sourceIte = source.begin() + *(rowGroupingIt + 1); sourceIt != sourceIte; ++sourceIt, ++currentRow) {
652 if (choices && *rowGroupingIt + *choiceIt == currentRow) {
653 oldSelectedChoiceValue = *sourceIt;
656 if (f(*sourceIt, *targetIt)) {
657 *targetIt = *sourceIt;
659 selectedChoice = std::distance(source.begin(), sourceIt) - *rowGroupingIt;
664 if (choices && f(*targetIt, oldSelectedChoiceValue)) {
665 *choiceIt = selectedChoice;
683void reduceVectorMin(std::vector<T>
const& source, std::vector<T>& target, std::vector<uint_fast64_t>
const& rowGrouping,
684 std::vector<uint_fast64_t>* choices =
nullptr) {
697void reduceVectorMax(std::vector<T>
const& source, std::vector<T>& target, std::vector<uint_fast64_t>
const& rowGrouping,
698 std::vector<uint_fast64_t>* choices =
nullptr) {
713 std::vector<uint_fast64_t>
const& rowGrouping, std::vector<uint_fast64_t>* choices =
nullptr) {
714 if (dir == storm::solver::OptimizationDirection::Minimize) {
740 T relDiff = (val1 - val2) / val1;
745 T diff = val1 - val2;
755inline bool equalModuloPrecision(
double const& val1,
double const& val2,
double const& precision,
bool relativeError) {
760 double relDiff = (val1 - val2) / val1;
765 double diff = val1 - val2;
783bool equalModuloPrecision(std::vector<T>
const& vectorLeft, std::vector<T>
const& vectorRight, T
const& precision,
bool relativeError) {
784 STORM_LOG_ASSERT(vectorLeft.size() == vectorRight.size(),
"Lengths of vectors does not match.");
786 auto leftIt = vectorLeft.begin();
787 auto leftIte = vectorLeft.end();
788 auto rightIt = vectorRight.begin();
789 for (; leftIt != leftIte; ++leftIt, ++rightIt) {
811 bool relativeError) {
812 STORM_LOG_ASSERT(vectorLeft.size() == vectorRight.size(),
"Lengths of vectors does not match.");
814 for (uint64_t position : positions) {
815 if (!
equalModuloPrecision(vectorLeft[position], vectorRight[position], precision, relativeError)) {
835bool equalModuloPrecision(std::vector<T>
const& vectorLeft, std::vector<T>
const& vectorRight, std::vector<uint_fast64_t>
const& positions, T
const& precision,
836 bool relativeError) {
837 STORM_LOG_ASSERT(vectorLeft.size() == vectorRight.size(),
"Lengths of vectors does not match.");
839 for (uint_fast64_t position : positions) {
840 if (!
equalModuloPrecision(vectorLeft[position], vectorRight[position], precision, relativeError)) {
851 for (
auto const& element :
vector) {
860 auto leftIt = vectorLeft.begin();
861 auto leftIte = vectorLeft.end();
862 auto rightIt = vectorRight.begin();
863 for (; leftIt != leftIte; ++leftIt, ++rightIt) {
864 T diff = *leftIt - *rightIt;
866 maxDiff = maxDiff < possDiff ? possDiff : maxDiff;
877 auto b1It = b1.begin();
878 auto b1Ite = b1.end();
879 auto b2It = b2.begin();
881 for (; b1It != b1Ite; ++b1It, ++b2It) {
891template<
typename ValueType>
892void clip(std::vector<ValueType>& x, boost::optional<ValueType>
const& lowerBound, boost::optional<ValueType>
const& upperBound) {
893 for (
auto& entry : x) {
894 if (lowerBound && entry < lowerBound.get()) {
895 entry = lowerBound.get();
896 }
else if (upperBound && entry > upperBound.get()) {
897 entry = upperBound.get();
905template<
typename ValueType>
906void clip(std::vector<ValueType>& x, ValueType
const& bound,
bool boundFromBelow) {
907 for (
auto& entry : x) {
908 if (boundFromBelow && entry < bound) {
910 }
else if (!boundFromBelow && entry > bound) {
919template<
typename ValueType>
920void clip(std::vector<ValueType>& x, std::vector<ValueType>
const& bounds,
bool boundFromBelow) {
921 auto boundsIt = bounds.begin();
922 for (
auto& entry : x) {
923 if (boundFromBelow && entry < *boundsIt) {
925 }
else if (!boundFromBelow && entry > *boundsIt) {
944 uint_fast64_t currentRowCount = 0;
945 uint_fast64_t currentIndexCount = 1;
952 for (uint64_t index : constraint) {
953 subVector[currentIndexCount] = currentRowCount + offsetVector[index + 1] - offsetVector[index];
954 currentRowCount += offsetVector[index + 1] - offsetVector[index];
969template<
typename TargetType,
typename SourceType>
971 std::vector<TargetType> resultVector;
972 resultVector.reserve(oldVector.size());
973 for (
auto const& oldValue : oldVector) {
988template<
typename TargetType,
typename SourceType>
990 STORM_LOG_ASSERT(inputVector.size() == targetVector.size(),
"Vector size mismatch.");
997template<
typename NewValueType,
typename ValueType>
998std::vector<NewValueType>
toValueType(std::vector<ValueType>
const& oldVector) {
999 std::vector<NewValueType> resultVector;
1000 resultVector.reserve(oldVector.size());
1001 for (
auto const& oldValue : oldVector) {
1002 resultVector.push_back(
static_cast<NewValueType
>(oldValue));
1004 return resultVector;
1007template<
typename ValueType,
typename TargetValueType>
1008typename std::enable_if<std::is_same<ValueType, storm::RationalNumber>::value, std::pair<std::vector<TargetValueType>, ValueType>>::type
toIntegralVector(
1009 std::vector<ValueType>
const& vec) {
1011 std::set<ValueType> occurringNonZeroNumbers;
1012 for (
auto const& v : vec) {
1014 occurringNonZeroNumbers.insert(v);
1020 if (occurringNonZeroNumbers.empty()) {
1022 }
else if (occurringNonZeroNumbers.size() == 1) {
1023 factor = *occurringNonZeroNumbers.begin();
1028 auto numberIt = occurringNonZeroNumbers.begin();
1030 for (++numberIt; numberIt != occurringNonZeroNumbers.end(); ++numberIt) {
1034 numberIt = occurringNonZeroNumbers.begin();
1036 "Number '" << *numberIt <<
"' is not integral.");
1038 for (++numberIt; numberIt != occurringNonZeroNumbers.end(); ++numberIt) {
1040 "Number '" << *numberIt <<
"' is not integral.");
1048 std::vector<TargetValueType> result;
1049 result.reserve(vec.size());
1050 for (
auto const& v : vec) {
1051 ValueType vScaled = v / factor;
1055 return std::make_pair(std::move(result), std::move(factor));
1058template<
typename ValueType,
typename TargetValueType>
1059typename std::enable_if<!std::is_same<ValueType, storm::RationalNumber>::value, std::pair<std::vector<TargetValueType>, ValueType>>::type
toIntegralVector(
1060 std::vector<ValueType>
const& vec) {
1068template<
typename Type>
1070 std::vector<Type> result;
1071 result.reserve(
filter.getNumberOfSetBits());
1072 for (uint64_t index :
filter) {
1073 result.push_back(in[index]);
1079template<
typename Type>
1081 STORM_LOG_ASSERT(v.size() ==
filter.size(),
"The filter size does not match the size of the input vector.");
1082 uint_fast64_t size = v.size();
1084 uint_fast64_t firstUnsetIndex =
filter.getNextUnsetIndex(0);
1085 if (firstUnsetIndex < size) {
1086 auto vIt = v.begin() + firstUnsetIndex;
1087 for (uint_fast64_t index =
filter.getNextSetIndex(firstUnsetIndex + 1); index != size; index =
filter.getNextSetIndex(index + 1)) {
1088 *vIt = std::move(v[index]);
1091 v.resize(vIt - v.begin());
1112 <<
") must match the size of the input vector ("
1113 <<
vector.size() <<
").");
1114 auto readPos =
vector.size();
1115 vector.resize(positions.
size(), defaultValue);
1117 while (writePos > 0) {
1119 if (positions.
get(writePos)) {
1121 if (readPos != writePos) {
1122 STORM_LOG_ASSERT(readPos < writePos,
"We shall not write to positions that we later still have to read from.");
1126 vector[writePos] = defaultValue;
1133 return std::any_of(v.begin(), v.end(), [](T value) { return value < storm::utility::zero<T>(); });
1138 return std::any_of(v.begin(), v.end(), [](T value) { return value > storm::utility::zero<T>(); });
1143 return std::any_of(v.begin(), v.end(), [](T value) { return !storm::utility::isZero(value); });
1148 return std::any_of(v.begin(), v.end(), [](T value) { return storm::utility::isZero(value); });
1153 return std::any_of(v.begin(), v.end(), [](T value) { return storm::utility::isInfinity(value); });
1158 std::vector<T> result;
1159 result.reserve(source.size());
1160 for (uint64_t sourceIndex : inversePermutation) {
1161 result.push_back(source[sourceIndex]);
1168 std::vector<uint64_t>
const& rowGroupIndices) {
1169 STORM_LOG_ASSERT(inversePermutation.size() == rowGroupIndices.size() - 1,
"Inverse permutation and row group indices do not match.");
1170 std::vector<T> result;
1171 result.reserve(source.size());
1172 for (
auto sourceGroupIndex : inversePermutation) {
1173 for (uint64_t sourceIndex = rowGroupIndices[sourceGroupIndex]; sourceIndex < rowGroupIndices[sourceGroupIndex + 1]; ++sourceIndex) {
1174 result.push_back(source[sourceIndex]);
1177 STORM_LOG_ASSERT(result.size() == source.size(),
"Result has unexpected length.");
1187template<
typename ValueType>
1189 std::stringstream stream;
1190 stream <<
"vector (" <<
vector.size() <<
") [ ";
1192 for (uint_fast64_t i = 0; i <
vector.size() - 1; ++i) {
1193 stream <<
vector[i] <<
", ";
1198 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.
bool compareElementWise(std::vector< T > const &left, std::vector< T > const &right, Comparator comp=std::less< T >())
void setVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< S > const &values)
Sets the provided values at the provided positions in the given vector.
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)
NumberTraits< RationalType >::IntegerType denominator(RationalType const &number)
bool isFinite(ExtendedNumber< ValueType > const &value)
NumberTraits< RationalType >::IntegerType numerator(RationalType const &number)
ValueType min(ValueType const &first, ValueType const &second)
bool isAlmostZero(ValueType const &a)
IntegerType lcm(IntegerType const &first, IntegerType const &second)
bool isZero(ValueType const &a)
bool isInteger(ValueType const &number)
ValueType abs(ValueType const &number)
IntegerType gcd(IntegerType const &first, IntegerType const &second)
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