From a358af1264707f4e9441036b0613806a3cefe8c1 Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Mon, 14 Sep 2020 14:23:26 -0700 Subject: [PATCH] set entries that are nonzero --- src/storm/utility/vector.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/storm/utility/vector.h b/src/storm/utility/vector.h index b70453aaa..28c267223 100644 --- a/src/storm/utility/vector.h +++ b/src/storm/utility/vector.h @@ -84,6 +84,16 @@ namespace storm { } } + template + void setNonzeroIndices(std::vector const& vec, storm::storage::BitVector& bv) { + STORM_LOG_ASSERT(bv.size() == vec.size(), "Bitvector size should match vector size"); + for (uint64_t i = 0; i < vec.size(); ++i) { + if(!storm::utility::isZero(vec[i])) { + bv.set(i, true); + } + } + } + /*! * Iota function as a helper for efficient creating a range in a vector. * See also http://stackoverflow.com/questions/11965732/set-stdvectorint-to-a-range