Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
vector.h File Reference
#include <algorithm>
#include <functional>
#include <iosfwd>
#include <numeric>
#include "storm/adapters/IntelTbbAdapter.h"
#include "storm/adapters/RationalNumberAdapter.h"
#include <boost/optional.hpp>
#include "storm/solver/OptimizationDirection.h"
#include "storm/storage/BitVector.h"
#include "storm/utility/constants.h"
#include "storm/utility/macros.h"
#include "storm/exceptions/NotImplementedException.h"
Include dependency graph for vector.h:

Go to the source code of this file.

Classes

struct  storm::utility::vector::VectorHash< ValueType >
 

Namespaces

namespace  storm
 LabParser.cpp.
 
namespace  storm::utility
 
namespace  storm::utility::vector
 

Functions

template<class T >
std::size_t storm::utility::vector::findOrInsert (std::vector< T > &vector, T &&element)
 Finds the given element in the given vector.
 
template<typename T >
void storm::utility::vector::setAllValues (std::vector< T > &vec, storm::storage::BitVector const &positions, T const &positiveValue=storm::utility::one< T >(), T const &negativeValue=storm::utility::zero< T >())
 
template<class T >
void storm::utility::vector::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.
 
template<class T >
void storm::utility::vector::setVectorValues (std::vector< T > &vector, storm::storage::BitVector const &positions, T value)
 Sets the provided value at the provided positions in the given vector.
 
template<typename T >
void storm::utility::vector::setNonzeroIndices (std::vector< T > const &vec, storm::storage::BitVector &bv)
 
template<class OutputIterator , class Size , class Assignable >
void storm::utility::vector::iota_n (OutputIterator first, Size n, Assignable value)
 Iota function as a helper for efficient creating a range in a vector.
 
template<typename T >
std::vector< T > storm::utility::vector::buildVectorForRange (T min, T max)
 Constructs a vector [min, min+1, ...., max-1].
 
template<typename T >
std::vector< uint_fast64_t > storm::utility::vector::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, the second index refers to the entry with the second highest value, ... Example: v={3,8,4,5} yields res={1,3,2,0}.
 
template<typename T >
bool storm::utility::vector::isUnique (std::vector< T > const &v)
 Returns true iff every element in the given vector is unique, i.e., there are no i,j with i!=j and v[i]==v[j].
 
template<typename T , typename Comparator >
bool storm::utility::vector::compareElementWise (std::vector< T > const &left, std::vector< T > const &right, Comparator comp=std::less< T >())
 
template<class T >
void storm::utility::vector::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 another vector.
 
template<class T >
void storm::utility::vector::selectVectorValues (std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< uint_fast64_t > const &rowGrouping, std::vector< T > const &values)
 Selects groups of elements from a vector at the specified positions and writes them consecutively into another vector.
 
template<class T >
void storm::utility::vector::selectVectorValues (std::vector< T > &vector, std::vector< uint_fast64_t > const &rowGroupToRowIndexMapping, std::vector< uint_fast64_t > const &rowGrouping, std::vector< T > const &values)
 Selects one element out of each row group and writes it to the target vector.
 
template<class T >
void storm::utility::vector::selectVectorValues (std::vector< T > &vector, std::vector< uint_fast64_t > const &indexSequence, std::vector< T > const &values)
 Selects values from a vector at the specified sequence of indices and writes them into another vector.
 
template<class T >
void storm::utility::vector::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 as given by the size of the corresponding group of elements.
 
template<class T >
void storm::utility::vector::subtractFromConstantOneVector (std::vector< T > &vector)
 Subtracts the given vector from the constant one-vector and writes the result to the input vector.
 
template<class T >
void storm::utility::vector::addFilteredVectorGroupsToGroupedVector (std::vector< T > &target, std::vector< T > const &source, storm::storage::BitVector const &filter, std::vector< uint_fast64_t > const &rowGroupIndices)
 
template<class T >
void storm::utility::vector::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 elements of the i-th row group in the target vector.
 
template<class T >
void storm::utility::vector::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 all elements of the i-th row group in the target vector.
 
template<class InValueType1 , class InValueType2 , class OutValueType , class Operation >
void storm::utility::vector::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 vector.
 
template<class InValueType1 , class InValueType2 , class OutValueType , class Operation >
void storm::utility::vector::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 vector.
 
template<class InValueType , class OutValueType , class Operation >
void storm::utility::vector::applyPointwise (std::vector< InValueType > const &operand, std::vector< OutValueType > &target, Operation f=Operation())
 Applies the given function pointwise on the given vector.
 
template<class InValueType1 , class InValueType2 , class OutValueType >
void storm::utility::vector::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.
 
template<class InValueType1 , class InValueType2 , class OutValueType >
void storm::utility::vector::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.
 
template<class InValueType1 , class InValueType2 , class OutValueType >
void storm::utility::vector::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.
 
template<class InValueType1 , class InValueType2 , class OutValueType >
void storm::utility::vector::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.
 
template<class ValueType1 , class ValueType2 >
void storm::utility::vector::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 vector.
 
template<class InValueType1 , class InValueType2 , class InValueType3 >
void storm::utility::vector::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 the second vector times the given factor) and writes the result into the first vector.
 
template<class T >
storm::utility::vector::dotProduct (std::vector< T > const &firstOperand, std::vector< T > const &secondOperand)
 Computes the dot product (aka scalar product) and returns the result.
 
template<class T >
storm::storage::BitVector storm::utility::vector::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 given function evaluate to true.
 
template<class T >
storm::storage::BitVector storm::utility::vector::filterGreaterZero (std::vector< T > const &values)
 Retrieves a bit vector containing all the indices for which the value at this position is greater than zero.
 
template<class T >
storm::storage::BitVector storm::utility::vector::filterZero (std::vector< T > const &values)
 Retrieves a bit vector containing all the indices for which the value at this position is equal to zero.
 
template<class T >
storm::storage::BitVector storm::utility::vector::filterOne (std::vector< T > const &values)
 Retrieves a bit vector containing all the indices for which the value at this position is equal to one.
 
template<class T >
storm::storage::BitVector storm::utility::vector::filterInfinity (std::vector< T > const &values)
 Retrieves a bit vector containing all the indices for which the value at this position is equal to one.
 
template<typename VT >
VT storm::utility::vector::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.
 
template<typename VT >
VT storm::utility::vector::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.
 
template<typename VT >
VT storm::utility::vector::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.
 
template<class T , class Filter >
void storm::utility::vector::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 group.
 
template<class T >
void storm::utility::vector::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.
 
template<class T >
void storm::utility::vector::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.
 
template<class T >
void storm::utility::vector::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.
 
template<class T >
bool storm::utility::vector::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.
 
template<>
bool storm::utility::vector::equalModuloPrecision (double const &val1, double const &val2, double const &precision, bool relativeError)
 
template<class T >
bool storm::utility::vector::equalModuloPrecision (std::vector< T > const &vectorLeft, std::vector< T > const &vectorRight, T const &precision, bool relativeError)
 Compares the two vectors and determines whether they are equal modulo the provided precision.
 
template<class T >
bool storm::utility::vector::equalModuloPrecision (std::vector< T > const &vectorLeft, std::vector< T > const &vectorRight, storm::storage::BitVector const &positions, T const &precision, bool relativeError)
 Compares the two vectors at the specified positions and determines whether they are equal modulo the provided precision.
 
template<class T >
bool storm::utility::vector::equalModuloPrecision (std::vector< T > const &vectorLeft, std::vector< T > const &vectorRight, std::vector< uint_fast64_t > const &positions, T const &precision, bool relativeError)
 Compares the two vectors at the specified positions and determines whether they are equal modulo the provided precision.
 
template<class T >
storm::utility::vector::maximumElementAbs (std::vector< T > const &vector)
 
template<class T >
storm::utility::vector::maximumElementDiff (std::vector< T > const &vectorLeft, std::vector< T > const &vectorRight)
 
template<class T >
storm::utility::vector::computeSquaredNorm2Difference (std::vector< T > const &b1, std::vector< T > const &b2)
 
template<typename ValueType >
void storm::utility::vector::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.
 
template<typename ValueType >
void storm::utility::vector::clip (std::vector< ValueType > &x, ValueType const &bound, bool boundFromBelow)
 Takes the input vector and ensures that all entries conform to the bounds.
 
template<typename ValueType >
void storm::utility::vector::clip (std::vector< ValueType > &x, std::vector< ValueType > const &bounds, bool boundFromBelow)
 Takes the input vector and ensures that all entries conform to the bounds.
 
template<class T >
std::vector< T > storm::utility::vector::getConstrainedOffsetVector (std::vector< T > const &offsetVector, storm::storage::BitVector const &constraint)
 Takes the given offset vector and applies the given contraint.
 
template<typename TargetType , typename SourceType >
std::vector< TargetType > storm::utility::vector::convertNumericVector (std::vector< SourceType > const &oldVector)
 Converts the given vector to the given ValueType Assumes that both, TargetType and SourceType are numeric.
 
template<typename TargetType , typename SourceType >
void storm::utility::vector::convertNumericVector (std::vector< SourceType > const &inputVector, std::vector< TargetType > &targetVector)
 Converts the given vector to the given ValueType Assumes that both, TargetType and SourceType are numeric.
 
template<typename NewValueType , typename ValueType >
std::vector< NewValueType > storm::utility::vector::toValueType (std::vector< ValueType > const &oldVector)
 Converts the given vector to the given ValueType.
 
template<typename ValueType , typename TargetValueType >
std::enable_if< std::is_same< ValueType, storm::RationalNumber >::value, std::pair< std::vector< TargetValueType >, ValueType > >::type storm::utility::vector::toIntegralVector (std::vector< ValueType > const &vec)
 
template<typename ValueType , typename TargetValueType >
std::enable_if<!std::is_same< ValueType, storm::RationalNumber >::value, std::pair< std::vector< TargetValueType >, ValueType > >::type storm::utility::vector::toIntegralVector (std::vector< ValueType > const &vec)
 
template<typename Type >
std::vector< Type > storm::utility::vector::filterVector (std::vector< Type > const &in, storm::storage::BitVector const &filter)
 
template<typename Type >
void storm::utility::vector::filterVectorInPlace (std::vector< Type > &v, storm::storage::BitVector const &filter)
 
template<typename T >
bool storm::utility::vector::hasNegativeEntry (std::vector< T > const &v)
 
template<typename T >
bool storm::utility::vector::hasPositiveEntry (std::vector< T > const &v)
 
template<typename T >
bool storm::utility::vector::hasNonZeroEntry (std::vector< T > const &v)
 
template<typename T >
bool storm::utility::vector::hasZeroEntry (std::vector< T > const &v)
 
template<typename T >
bool storm::utility::vector::hasInfinityEntry (std::vector< T > const &v)
 
template<typename T >
std::vector< T > storm::utility::vector::applyInversePermutation (std::vector< uint64_t > const &inversePermutation, std::vector< T > const &source)
 
template<typename T >
std::vector< T > storm::utility::vector::applyInversePermutationToGroupedVector (std::vector< uint64_t > const &inversePermutation, std::vector< T > const &source, std::vector< uint64_t > const &rowGroupIndices)
 
template<typename ValueType >
std::string storm::utility::vector::toString (std::vector< ValueType > const &vector)
 Output vector as string.
 
template<typename PT1 , typename PT2 >
std::string storm::utility::vector::toString (std::vector< std::pair< PT1, PT2 > > const &vector)