syncing commonlibs with Many thanks to Michael Iedema for these patches, makes config a lot better.
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@5655 19bc5d8c-e614-43d4-8b26-e1612bc8e597
diff --git a/CommonLibs/BitVector.cpp b/CommonLibs/BitVector.cpp
index 54a3edc..7487834 100644
--- a/CommonLibs/BitVector.cpp
+++ b/CommonLibs/BitVector.cpp
@@ -29,6 +29,7 @@
#include "BitVector.h"
#include <iostream>
#include <stdio.h>
+#include <sstream>
using namespace std;
@@ -274,9 +275,6 @@
-
-
-
ostream& operator<<(ostream& os, const BitVector& hv)
{
for (size_t i=0; i<hv.size(); i++) {
@@ -527,6 +525,22 @@
+// (pat) Added 6-22-2012
+float SoftVector::getEnergy(float *plow) const
+{
+ const SoftVector &vec = *this;
+ 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));
+ if (energy < low) low = energy;
+ avg += energy/len;
+ }
+ if (plow) { *plow = low; }
+ return avg;
+}
+
ostream& operator<<(ostream& os, const SoftVector& sv)
{
@@ -578,6 +592,14 @@
os << std::dec;
}
+std::string BitVector::hexstr() const
+{
+ std::ostringstream ss;
+ hex(ss);
+ return ss.str();
+}
+
+
bool BitVector::unhex(const char* src)
{
// Assumes MSB-first packing.