From a2e9559fafbeee5b6b131a2c2ba70b78376806cd Mon Sep 17 00:00:00 2001 From: TimQu Date: Wed, 1 Jun 2016 14:10:51 +0200 Subject: [PATCH] some auxiliary functions for vectors Former-commit-id: f53dcdb883c05b12859070d711d6906065062a6c --- src/utility/vector.h | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/utility/vector.h b/src/utility/vector.h index 0403f86f7..8fc12959c 100644 --- a/src/utility/vector.h +++ b/src/utility/vector.h @@ -6,12 +6,13 @@ #include "tbb/tbb.h" #endif -#include "constants.h" #include #include #include +#include #include "src/storage/BitVector.h" +#include "src/utility/constants.h" #include "src/utility/macros.h" #include "src/solver/OptimizationDirection.h" @@ -347,32 +348,15 @@ namespace storm { } /*! - * Converts the numbers in the given vector to the target representation - * - * @param target The target vector in which the resulting numbers are written. - * @param source The source vector whose numbers are converted - */ - template - void convertVector(std::vector const& source, std::vector& target) { - applyPointwise(source, target, [&] (SourceType const& argument) -> TargetType { return convertNumber(argument); }); - } - - /*! - * Multiplies the two given vectors (scalar product) and returns the result + * Computes the dot product (aka scalar product) and returns the result * * @param firstOperand The first operand. * @param secondOperand The second operand * @return firstOperand*secondOperand */ template - T multiplyVectors(std::vector const& firstOperand, std::vector const& secondOperand) { - T res = storm::utility::zero(); - auto it1 = firstOperand.begin(); - auto it2 = secondOperand.begin(); - for(; it1 const& firstOperand, std::vector const& secondOperand) { + return std::inner_product(firstOperand.begin(), firstOperand.end(), secondOperand.begin(), storm::utility::zero()); } /*! @@ -733,6 +717,11 @@ namespace storm { return result; } + template + bool hasNegativeEntries(std::vector const& v){ + return std::any_of(v.begin(), v.end(), [](T value){return value < storm::utility::zero();}); + } + /*! * Output vector as string. *