Alexander Chemeris has submitted this change and it was merged.

Change subject: BitVector: Convert SoftVector from 0..1 to -1..+1 soft bits.
......................................................................


BitVector: Convert SoftVector from 0..1 to -1..+1 soft bits.

This makes code simpler and will allow us send -127..127 soft bits towards
osmo-bts instead of 0..255 bits.

Change-Id: I16ecc3d4c829dcf0f619ad995bc9d4a4ed8af0a4
---
M CommonLibs/BitVector.cpp
M CommonLibs/BitVector.h
2 files changed, 13 insertions(+), 13 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/CommonLibs/BitVector.cpp b/CommonLibs/BitVector.cpp
index b77a4c4..3b556b9 100644
--- a/CommonLibs/BitVector.cpp
+++ b/CommonLibs/BitVector.cpp
@@ -30,6 +30,7 @@
 #include <iostream>
 #include <stdio.h>
 #include <sstream>
+#include <math.h>
 
 using namespace std;
 
@@ -268,7 +269,7 @@
        resize(source.size());
        for (size_t i=0; i<size(); i++) {
                if (source.bit(i)) mStart[i]=1.0F;
-               else mStart[i]=0.0F;
+               else mStart[i]=-1.0F;
        }
 }
 
@@ -278,7 +279,7 @@
        size_t sz = size();
        BitVector newSig(sz);
        for (size_t i=0; i<sz; i++) {
-               if (mStart[i]>0.5F) newSig[i]=1;
+               if (mStart[i]>0.0F) newSig[i]=1;
                else newSig[i] = 0;
        }
        return newSig;
@@ -291,8 +292,7 @@
        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 @@
 ostream& operator<<(ostream& os, const SoftVector& sv)
 {
        for (size_t i=0; i<sv.size(); i++) {
-               if (sv[i]<0.25) os << "0";
-               else if (sv[i]<0.4) os << "o";
-               else if (sv[i]<0.5) os << ".";
-               else if (sv[i]>0.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 7473c32..d2acb5f 100644
--- a/CommonLibs/BitVector.h
+++ b/CommonLibs/BitVector.h
@@ -290,19 +290,19 @@
        //@}
 
        // 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(dp<mEnd);
-               return (*dp)>0.5F;
+               return (*dp)>0.0F;
        }
 
        /** Slice the whole signal into bits. */

-- 
To view, visit https://gerrit.osmocom.org/2142
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I16ecc3d4c829dcf0f619ad995bc9d4a4ed8af0a4
Gerrit-PatchSet: 3
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Alexander Chemeris <alexander.cheme...@gmail.com>
Gerrit-Reviewer: Alexander Chemeris <alexander.cheme...@gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Tom Tsou <t...@tsou.cc>

Reply via email to