![]()  | 
  
  
  
    ccsoft
    0.0.0
    
   Convolutional 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 <CC_ReliabilityMatrix.h>
Public Member Functions | |
| CC_ReliabilityMatrix (unsigned int nb_symbols_log2, unsigned int message_length) | |
| CC_ReliabilityMatrix (const CC_ReliabilityMatrix &relmat) | |
| ~CC_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 * | get_raw_matrix () | 
| float | find_max (unsigned int &i_row, unsigned int &i_col) const | 
| float | find_max_in_col (unsigned int &i_row, unsigned int i_col, float prev_max=1.0) 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 CC_ReliabilityMatrix &matrix) | 
Reliability Matrix class. Analog data is entered first then the normalization method is called to get the actual reliability data (probabilities).
| ccsoft::CC_ReliabilityMatrix::CC_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;
    }
}
| ccsoft::CC_ReliabilityMatrix::CC_ReliabilityMatrix | ( | const CC_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 ccsoft::CC_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 ccsoft::CC_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 ccsoft::CC_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 ccsoft::CC_ReliabilityMatrix::find_max | ( | unsigned int & | i_row, | 
| unsigned int & | i_col | ||
| ) | const | 
Finds the maximum value in the matrix
{
    float max = 0.0;
    i_row = 0; // prevent core dump if all items are 0
    i_col = 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;
}
| float ccsoft::CC_ReliabilityMatrix::find_max_in_col | ( | unsigned int & | i_row, | 
| unsigned int | i_col, | ||
| float | prev_max = 1.0  | 
        ||
| ) | const | 
Finds the maximum value in a column of the matrix
| i_row | Reference to the row index where the maximum is found | 
| i_col | Column index | 
| prev_max | Value of the previous maximum when searching next maximum | 
{
    float max = 0.0;
    i_row = 0; // prevent core dump if all items are 0
    for (unsigned int ir = 0; ir < _nb_symbols; ir++)
    {
        if ((_matrix[i_col*_nb_symbols + ir] >= max) && (_matrix[i_col*_nb_symbols + ir] < prev_max))
        {
            max = _matrix[i_col*_nb_symbols + ir];
            i_row = ir;
        }
    }
    return max;
}
| unsigned int ccsoft::CC_ReliabilityMatrix::get_message_length | ( | ) |  const [inline] | 
        
Get the number of message symbols (i.e. columns)
    {
        return _message_length;
    }
| unsigned int ccsoft::CC_ReliabilityMatrix::get_nb_symbols | ( | ) |  const [inline] | 
        
Get the number of symbols (i.e. rows)
    {
        return _nb_symbols;
    }
| unsigned int ccsoft::CC_ReliabilityMatrix::get_nb_symbols_log2 | ( | ) |  const [inline] | 
        
Get the log2 of the number of symbols (i.e. rows)
    {
        return _nb_symbols_log2;
    }
| const float* ccsoft::CC_ReliabilityMatrix::get_raw_matrix | ( | ) |  const [inline] | 
        
Get a pointer to matrix storage
    {
        return _matrix;
    }
| float* ccsoft::CC_ReliabilityMatrix::get_raw_matrix | ( | ) |  [inline] | 
        
Get a pointer to matrix storage for update
    {
        return _matrix;
    }
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& ccsoft::CC_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& ccsoft::CC_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 ccsoft::CC_ReliabilityMatrix::reset_message_symbol_count | ( | ) |  [inline] | 
        
Resets the message symbol counter
    {
        _message_symbol_count = 0;
    }
| std::ostream& operator<< | ( | std::ostream & | os, | 
| const CC_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* ccsoft::CC_ReliabilityMatrix::_matrix [protected] | 
        
The reliability matrix stored column first.
unsigned int ccsoft::CC_ReliabilityMatrix::_message_length [protected] | 
        
unsigned int ccsoft::CC_ReliabilityMatrix::_message_symbol_count [protected] | 
        
incremented each time a new message symbol data is entered
unsigned int ccsoft::CC_ReliabilityMatrix::_nb_symbols [protected] | 
        
unsigned int ccsoft::CC_ReliabilityMatrix::_nb_symbols_log2 [protected] |