Browse Source

Further refactoring of the bit vector class, now including logging output. Renamed it according to the new naming scheme.

tempestpy_adaptions
dehnert 12 years ago
parent
commit
bdfb9b7d72
  1. 2
      src/modelChecker/DtmcPrctlModelChecker.h
  2. 2
      src/models/single_atomic_proposition_labeling.h
  3. 13
      src/storage/BitVector.h
  4. 2
      test/vector/bitvector_test.cpp

2
src/modelChecker/DtmcPrctlModelChecker.h

@ -18,7 +18,7 @@
#include "src/formula/Until.h" #include "src/formula/Until.h"
#include "src/models/dtmc.h" #include "src/models/dtmc.h"
#include "src/vector/bitvector.h"
#include "src/storage/BitVector.h"
#include <vector> #include <vector>
namespace mrmc { namespace mrmc {

2
src/models/single_atomic_proposition_labeling.h

@ -1,7 +1,7 @@
#ifndef MRMC_MODELS_SINGLE_ATOMIC_PROPOSITION_LABELING_H_ #ifndef MRMC_MODELS_SINGLE_ATOMIC_PROPOSITION_LABELING_H_
#define MRMC_MODELS_SINGLE_ATOMIC_PROPOSITION_LABELING_H_ #define MRMC_MODELS_SINGLE_ATOMIC_PROPOSITION_LABELING_H_
#include "src/vector/bitvector.h"
#include "src/storage/BitVector.h"
namespace mrmc { namespace mrmc {

13
src/vector/bitvector.h → src/storage/BitVector.h

@ -58,6 +58,7 @@ public:
BitVector(uint_fast64_t initialLength) { BitVector(uint_fast64_t initialLength) {
// Check whether the given length is valid. // Check whether the given length is valid.
if (initialLength == 0) { if (initialLength == 0) {
LOG4CPLUS_ERROR(logger, "Trying to create bit vector of size 0.");
throw mrmc::exceptions::invalid_argument("Trying to create a bit vector of size 0."); throw mrmc::exceptions::invalid_argument("Trying to create a bit vector of size 0.");
} }
@ -66,6 +67,7 @@ public:
if ((initialLength & mod64mask) != 0) { if ((initialLength & mod64mask) != 0) {
++bucket_count; ++bucket_count;
} }
// Finally, create the full bucket array. This should initialize the array // Finally, create the full bucket array. This should initialize the array
// with 0s (notice the parentheses at the end) for standard conforming // with 0s (notice the parentheses at the end) for standard conforming
// compilers. // compilers.
@ -78,6 +80,7 @@ public:
* @param bv A reference to the bit vector to be copied. * @param bv A reference to the bit vector to be copied.
*/ */
BitVector(const BitVector &bv) : bucket_count(bv.bucket_count) { BitVector(const BitVector &bv) : bucket_count(bv.bucket_count) {
LOG4CPLUS_WARN(logger, "Invoking copy constructor.");
bucket_array = new uint_fast64_t[bucket_count]; bucket_array = new uint_fast64_t[bucket_count];
memcpy(bucket_array, bv.bucket_array, sizeof(uint_fast64_t) * bucket_count); memcpy(bucket_array, bv.bucket_array, sizeof(uint_fast64_t) * bucket_count);
} }
@ -220,13 +223,15 @@ public:
* do not match, only the matching portion is considered and the overlapping bits * do not match, only the matching portion is considered and the overlapping bits
* are set to 0. * are set to 0.
* @param bv A reference to the bit vector to use for the operation. * @param bv A reference to the bit vector to use for the operation.
* @return A bit vector corresponding to the logical "xor" of the two bit vectors.
* @return A bit vector corresponding to the logical "implies" of the two bit vectors.
*/ */
BitVector implies(BitVector& other) {
BitVector implies(BitVector& bv) {
uint_fast64_t minSize = (bv.bucket_count < this->bucket_count) ? bv.bucket_count : this->bucket_count;
// Create resulting bit vector and perform the operation on the individual elements. // Create resulting bit vector and perform the operation on the individual elements.
BitVector result(this->bucket_count << 6);
BitVector result(minSize << 6);
for (uint_fast64_t i = 0; i < this->bucket_count; ++i) { for (uint_fast64_t i = 0; i < this->bucket_count; ++i) {
result.bucket_array[i] = ~this->bucket_array[i] | other.bucket_array[i];
result.bucket_array[i] = ~this->bucket_array[i] | bv.bucket_array[i];
} }
return result; return result;

2
test/vector/bitvector_test.cpp

@ -1,5 +1,5 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "src/vector/bitvector.h"
#include "src/storage/BitVector.h"
#include "src/exceptions/invalid_argument.h" #include "src/exceptions/invalid_argument.h"
TEST(BitVectorTest, GetSetTest) { TEST(BitVectorTest, GetSetTest) {
Loading…
Cancel
Save