Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
VectorTest.cpp
Go to the documentation of this file.
1#include "storm-config.h"
2#include "test/storm_gtest.h"
3
7
8TEST(VectorTest, sum_if) {
9 std::vector<double> a = {1.0, 2.0, 4.0, 8.0, 16.0};
10 storm::storage::BitVector f1(5, {2, 4});
11 storm::storage::BitVector f2(5, {3, 4});
12
13 ASSERT_EQ(20.0, storm::utility::vector::sum_if(a, f1));
14 ASSERT_EQ(24.0, storm::utility::vector::sum_if(a, f2));
15}
16
17TEST(VectorTest, max_if) {
18 std::vector<double> a = {1.0, 2.0, 34.0, 8.0, 16.0};
19 storm::storage::BitVector f1(5, {2, 4});
20 storm::storage::BitVector f2(5, {3, 4});
21
22 ASSERT_EQ(34.0, storm::utility::vector::max_if(a, f1));
23 ASSERT_EQ(16.0, storm::utility::vector::max_if(a, f2));
24}
25
26TEST(VectorTest, min_if) {
27 std::vector<double> a = {1.0, 2.0, 34.0, 8.0, 16.0};
28 storm::storage::BitVector f1(5, {2, 4});
29 storm::storage::BitVector f2(5, {3, 4});
30
31 ASSERT_EQ(16.0, storm::utility::vector::min_if(a, f1));
32 ASSERT_EQ(8.0, storm::utility::vector::min_if(a, f2));
33}
34
35TEST(VectorTest, inverse_permute) {
36 std::vector<double> a = {1.0, 2.0, 3.0, 4.0};
37 std::vector<uint64_t> inversePermutation = {0, 3, 1, 2};
38 std::vector<double> aperm = storm::utility::vector::applyInversePermutation(inversePermutation, a);
39 EXPECT_EQ(aperm[0], a[0]);
40 EXPECT_EQ(aperm[1], a[3]);
41 EXPECT_EQ(aperm[2], a[1]);
42 EXPECT_EQ(aperm[3], a[2]);
43}
44
45TEST(VectorTest, grouped_inverse_permute) {
46 std::vector<double> a = {1.0, 2.0, 3.0, 4.0, 5.0};
47 std::vector<uint64_t> groupIndices = {0, 3, 5, 5}; // last group empty
48 std::vector<uint64_t> inversePermutation = {1, 2, 0};
49 std::vector<double> aperm = storm::utility::vector::applyInversePermutationToGroupedVector(inversePermutation, a, groupIndices);
50 std::vector<double> expected = {4.0, 5.0, 1.0, 2.0, 3.0};
51 EXPECT_EQ(aperm, expected);
52}
TEST(VectorTest, sum_if)
Definition VectorTest.cpp:8
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
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.
Definition vector.h:595
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.
Definition vector.h:572
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.
Definition vector.h:556
std::vector< T > applyInversePermutation(std::vector< uint64_t > const &inversePermutation, std::vector< T > const &source)
Definition vector.h:1118
std::vector< T > applyInversePermutationToGroupedVector(std::vector< uint64_t > const &inversePermutation, std::vector< T > const &source, std::vector< uint64_t > const &rowGroupIndices)
Definition vector.h:1128