45BERC::BERC(
int indelay,
int inignorefirst,
int inignorelast):
46 delay(indelay), ignorefirst(inignorefirst), ignorelast(inignorelast),
47 errors(0), corrects(0) {}
52 - ignorefirst - ignorelast;
55 for (
int i = 0; i < countlength; i++) {
56 if (in1(i + ignorefirst) == in2(i + ignorefirst + delay)) {
65 for (
int i = 0; i < countlength; i++) {
66 if (in1(i + ignorefirst - delay) == in2(i + ignorefirst)) {
88 int num, start1, start2;
89 int min_input_length =
std::min(in1.length(), in2.length());
90 int bestdelay = mindelay;
93 for (
int i = mindelay; i < maxdelay; i++) {
94 num = min_input_length -
std::abs(i) - ignorefirst - ignorelast;
95 start1 = (i < 0) ? -i : 0;
96 start2 = (i > 0) ? i : 0;
98 in2.mid(start2, num)))));
99 if (correlation > bestcorr) {
101 bestcorr = correlation;
109 std::cout.setf(std::ios::fixed);
110 std::cout << std::endl
111 <<
"==================================" << std::endl
112 <<
" Bit Error Counter Report " << std::endl
113 <<
"==================================" << std::endl
114 <<
" Ignore First = " << ignorefirst << std::endl
115 <<
" Ignore Last = " << ignorelast << std::endl
116 <<
" Delay = " << delay << std::endl
117 <<
" Number of counted bits = " << std::setprecision(0)
118 << (errors + corrects) << std::endl
119 <<
" Number of errors = " << std::setprecision(0)
120 << errors << std::endl
121 <<
"==================================" << std::endl
122 <<
" Error rate = " << std::setprecision(8)
123 << (errors / (errors + corrects)) << std::endl
124 <<
"==================================" << std::endl << std::endl;
128 int inignorefirst,
int inignorelast)
131 - inignorefirst - inignorelast;
132 int local_errors = 0;
135 for (
int i = 0; i < countlength; i++) {
136 if (in1(i + inignorefirst) != in2(i + inignorefirst + indelay)) {
142 for (
int i = 0; i < countlength; i++) {
143 if (in1(i + inignorefirst - indelay) != in2(i + inignorefirst)) {
161BLERC::BLERC(
int inblocksize): setup_done(true), blocksize(inblocksize),
162 errors(0), corrects(0) {}
167 blocksize = inblocksize;
178 "BLERC::count(): Block size has to be setup before counting errors.");
179 int min_input_length =
std::min(in1.length(), in2.length());
181 "BLERC::count(): Block size must not be longer than input vectors.");
183 for (
int i = 0; i < (min_input_length / blocksize); i++) {
185 for (
int j = 0; j < blocksize; j++) {
186 if (in1(i * blocksize + j) != in2(i * blocksize + j)) {
void report() const
Writes an error report.
void count(const bvec &in1, const bvec &in2)
Cumulative error counter.
void estimate_delay(const bvec &in1, const bvec &in2, int mindelay=-100, int maxdelay=100)
Run this member function if the delay between in1 and in2 is unknown.
static double count_errors(const bvec &in1, const bvec &in2, int indelay=0, int inignorefirst=0, int inignorelast=0)
static function to allow simple and fast count of bit-errors
BERC(int indelay=0, int inignorefirst=0, int inignorelast=0)
Constructor for the berc class.
void set_blocksize(int inblocksize, bool clear=true)
Set the block size.
void clear()
Clear the block error counter.
BLERC(void)
Class constructor.
void count(const bvec &in1, const bvec &in2)
Calculate the number of block errors between in1 and in2.
Definitions of converters between different vector and matrix types.
Definitions of Bit Error Rate Counter (BERC) and BLock Error Rate Counter (BLERC) classes.
#define it_assert(t, s)
Abort if t is not true.
T sum(const Vec< T > &v)
Sum of all elements in the vector.
T min(const Vec< T > &in)
Minimum value of vector.
Various functions on vectors and matrices - header file.
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
Mat< Num_T > elem_mult(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices.
int abs(const itpp::bin &inbin)
absolute value of bin