diff --git a/CommonLibs/BitVector.cpp b/CommonLibs/BitVector.cpp index b77a4c4a..3b556b99 100644 --- a/CommonLibs/BitVector.cpp +++ b/CommonLibs/BitVector.cpp @@ -30,6 +30,7 @@ #include #include #include +#include using namespace std; @@ -268,7 +269,7 @@ SoftVector::SoftVector(const BitVector& source) resize(source.size()); for (size_t i=0; i0.5F) newSig[i]=1; + if (mStart[i]>0.0F) newSig[i]=1; else newSig[i] = 0; } return newSig; @@ -291,8 +292,7 @@ float SoftVector::getEnergy(float *plow) const int len = vec.size(); float avg = 0; float low = 1; for (int i = 0; i < len; i++) { - float bit = vec[i]; - float energy = 2*((bit < 0.5) ? (0.5-bit) : (bit-0.5)); + float energy = fabsf(vec[i]); if (energy < low) low = energy; avg += energy/len; } @@ -304,12 +304,12 @@ float SoftVector::getEnergy(float *plow) const ostream& operator<<(ostream& os, const SoftVector& sv) { for (size_t i=0; i0.75) os << "1"; - else if (sv[i]>0.6) os << "|"; - else if (sv[i]>0.5) os << "'"; + if (sv[i]<-0.5) os << "0"; + else if (sv[i]<-0.25) os << "o"; + else if (sv[i]<0.0) os << "."; + else if (sv[i]>0.5) os << "1"; + else if (sv[i]>0.25) os << "|"; + else if (sv[i]>0.0) os << "'"; else os << "-"; } return os; diff --git a/CommonLibs/BitVector.h b/CommonLibs/BitVector.h index 7473c329..d2acb5f1 100644 --- a/CommonLibs/BitVector.h +++ b/CommonLibs/BitVector.h @@ -290,19 +290,19 @@ class SoftVector: public Vector { //@} // How good is the SoftVector in the sense of the bits being solid? - // Result of 1 is perfect and 0 means all the bits were 0.5 + // Result of 1 is perfect and 0 means all the bits were 0.0 // If plow is non-NULL, also return the lowest energy bit. float getEnergy(float *low=0) const; /** Fill with "unknown" values. */ - void unknown() { fill(0.5F); } + void unknown() { fill(0.0F); } /** Return a hard bit value from a given index by slicing. */ bool bit(size_t index) const { const float *dp = mStart+index; assert(dp0.5F; + return (*dp)>0.0F; } /** Slice the whole signal into bits. */