![]() |
rssoft
0.0.0
Reed-Solomon codes library with soft decision decoding
|
Reliability Matrix class. Analog data is entered first then the normalization method is called to get the actual reliability data (probabilities). More...
#include <ReliabilityMatrix.h>
Public Member Functions | |
ReliabilityMatrix (unsigned int nb_symbols_log2, unsigned int message_length) | |
ReliabilityMatrix (const ReliabilityMatrix &relmat) | |
~ReliabilityMatrix () | |
void | enter_symbol_data (float *symbol_data) |
void | enter_symbol_data (unsigned int message_symbol_index, float *symbol_data) |
void | enter_erasure () |
void | enter_erasure (unsigned int message_symbol_index) |
void | normalize () |
void | reset_message_symbol_count () |
unsigned int | get_nb_symbols_log2 () const |
unsigned int | get_nb_symbols () const |
unsigned int | get_message_length () const |
float & | operator() (unsigned int i_row, unsigned int i_col) |
const float & | operator() (unsigned int i_row, unsigned int i_col) const |
const float * | get_raw_matrix () const |
float | find_max (unsigned int &i_row, unsigned int &i_col) const |
Protected Attributes | |
unsigned int | _nb_symbols_log2 |
unsigned int | _nb_symbols |
unsigned int | _message_length |
unsigned int | _message_symbol_count |
incremented each time a new message symbol data is entered | |
float * | _matrix |
The reliability matrix stored column first. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const ReliabilityMatrix &matrix) |
Reliability Matrix class. Analog data is entered first then the normalization method is called to get the actual reliability data (probabilities).
rssoft::ReliabilityMatrix::ReliabilityMatrix | ( | unsigned int | nb_symbols_log2, |
unsigned int | message_length | ||
) |
Constructor
nb_symbols_log2 | Log2 of the number of symbols used (number of symbols is a power of two) |
message_length | Length of one message block to be decoded |
: _nb_symbols_log2(nb_symbols_log2), _nb_symbols(1<<nb_symbols_log2), _message_length(message_length), _message_symbol_count(0) { _matrix = new float[_nb_symbols*_message_length]; for (unsigned int i=0; i<_nb_symbols*_message_length; i++) { _matrix[i] = 0.0; } }
rssoft::ReliabilityMatrix::ReliabilityMatrix | ( | const ReliabilityMatrix & | relmat | ) |
Copy Constructor
: _nb_symbols_log2(relmat.get_nb_symbols_log2()), _nb_symbols(relmat.get_nb_symbols()), _message_length(relmat.get_message_length()), _message_symbol_count(0) { _matrix = new float[_nb_symbols*_message_length]; memcpy((void *) _matrix, (void *) relmat.get_raw_matrix(), _nb_symbols*_message_length*sizeof(float)); }
Destructor. Frees the matrix storage.
{ delete[] _matrix; }
Enter an erasure at current symbol position. This is done by zeroing out the corresponding column in the matrix thus neutralizing it for further multiplicity calculation.
{ if (_message_symbol_count < _message_length) { for (unsigned int i=0; i<_nb_symbols; i++) { _matrix[_message_symbol_count*_nb_symbols + i] = 0.0; } _message_symbol_count++; } }
void rssoft::ReliabilityMatrix::enter_erasure | ( | unsigned int | message_symbol_index | ) |
Enter an erasure at a given symbol position. This is done by zeroing out the corresponding column in the matrix thus neutralizing it for further multiplicity calculation.
{ if (message_symbol_index < _message_length) { for (unsigned int i=0; i<_nb_symbols; i++) { _matrix[message_symbol_index*_nb_symbols + i] = 0.0; } } }
void rssoft::ReliabilityMatrix::enter_symbol_data | ( | float * | symbol_data | ) |
Enter one more symbol position data
symbol_data | Pointer to symbol data array. There must be nb_symbol values corresponding to the relative reliability of each symbol for the current symbol position in the message |
{ if (_message_symbol_count < _message_length) { memcpy((void *) &_matrix[_message_symbol_count*_nb_symbols], (void *) symbol_data, _nb_symbols*sizeof(float)); _message_symbol_count++; } }
void rssoft::ReliabilityMatrix::enter_symbol_data | ( | unsigned int | message_symbol_index, |
float * | symbol_data | ||
) |
Enter symbol position data at given message symbol position
message_symbol_index | Position of the symbol in the message |
symbol_data | Pointer to symbol data array. There must be nb_symbol values corresponding to the relative reliability of each symbol for the current symbol position in the message |
{ if (message_symbol_index < _message_length) { memcpy((void *) &_matrix[message_symbol_index*_nb_symbols], (void *) symbol_data, _nb_symbols*sizeof(float)); } }
float rssoft::ReliabilityMatrix::find_max | ( | unsigned int & | i_row, |
unsigned int & | i_col | ||
) | const |
Finds the maximum value in the matrix
{ float max = 0.0; for (unsigned int ic = 0; ic < _message_length; ic++) { for (unsigned int ir = 0; ir < _nb_symbols; ir++) { if (_matrix[ic*_nb_symbols + ir] > max) { max = _matrix[ic*_nb_symbols + ir]; i_row = ir; i_col = ic; } } } return max; }
unsigned int rssoft::ReliabilityMatrix::get_message_length | ( | ) | const [inline] |
Get the number of message symbols (i.e. columns)
{ return _message_length; }
unsigned int rssoft::ReliabilityMatrix::get_nb_symbols | ( | ) | const [inline] |
Get the number of symbols (i.e. rows)
{ return _nb_symbols; }
unsigned int rssoft::ReliabilityMatrix::get_nb_symbols_log2 | ( | ) | const [inline] |
Get the log2 of the number of symbols (i.e. rows)
{ return _nb_symbols_log2; }
const float* rssoft::ReliabilityMatrix::get_raw_matrix | ( | ) | const [inline] |
Get a pointer to matrix storage
{ return _matrix; }
void rssoft::ReliabilityMatrix::normalize | ( | ) |
Normalize each column so that values represent an a posteriori probability i.e. sum of each column is 1.0
{ float col_sum = 0; float last_col_sum; for (unsigned int ic = 0; ic < _message_length+1; ic++) { last_col_sum = col_sum; col_sum = 0; for (unsigned int ir = 0; ir < _nb_symbols; ir++) { if (ic < _message_length) { col_sum += _matrix[ic*_nb_symbols + ir]; } if (ic > 0) { if (last_col_sum != 0.0) { _matrix[(ic-1)*_nb_symbols + ir] /= last_col_sum; } } } } }
float& rssoft::ReliabilityMatrix::operator() | ( | unsigned int | i_row, |
unsigned int | i_col | ||
) | [inline] |
Operator to get the value at row i column j. Read-write version.
{ return _matrix[_nb_symbols*i_col + i_row]; }
const float& rssoft::ReliabilityMatrix::operator() | ( | unsigned int | i_row, |
unsigned int | i_col | ||
) | const [inline] |
Operator to get the value at row i column j. Read-only version.
{ return _matrix[_nb_symbols*i_col + i_row]; }
void rssoft::ReliabilityMatrix::reset_message_symbol_count | ( | ) | [inline] |
Resets the message symbol counter
{ _message_symbol_count = 0; }
std::ostream& operator<< | ( | std::ostream & | os, |
const ReliabilityMatrix & | matrix | ||
) | [friend] |
Prints a reliability matrix to an output stream
{ unsigned int nb_rows = matrix.get_nb_symbols(); unsigned int nb_cols = matrix.get_message_length(); for (unsigned int ir=0; ir<nb_rows; ir++) { for (unsigned int ic=0; ic<nb_cols; ic++) { if (ic > 0) { os << " "; } os << std::fixed << std::setw(8) << std::setprecision(6) << matrix(ir, ic); } os << std::endl; } return os; }
float* rssoft::ReliabilityMatrix::_matrix [protected] |
The reliability matrix stored column first.
unsigned int rssoft::ReliabilityMatrix::_message_length [protected] |
unsigned int rssoft::ReliabilityMatrix::_message_symbol_count [protected] |
incremented each time a new message symbol data is entered
unsigned int rssoft::ReliabilityMatrix::_nb_symbols [protected] |
unsigned int rssoft::ReliabilityMatrix::_nb_symbols_log2 [protected] |