ccsoft  0.0.0
Convolutional codes library with soft decision decoding
ccsoft::CC_ReliabilityMatrix Class Reference

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>

List of all members.

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)

Detailed Description

Reliability Matrix class. Analog data is entered first then the normalization method is called to get the actual reliability data (probabilities).


Constructor & Destructor Documentation

ccsoft::CC_ReliabilityMatrix::CC_ReliabilityMatrix ( unsigned int  nb_symbols_log2,
unsigned int  message_length 
)

Constructor

Parameters:
nb_symbols_log2Log2 of the number of symbols used (number of symbols is a power of two)
message_lengthLength 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;
    }
}

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));
}

Here is the call graph for this function:

Destructor. Frees the matrix storage.

{
    delete[] _matrix;
}

Member Function Documentation

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

Parameters:
symbol_dataPointer 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

Parameters:
message_symbol_indexPosition of the symbol in the message
symbol_dataPointer 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

Parameters:
i_rowReference to the row index where the maximum is found
i_colColumn index
prev_maxValue 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;
    }

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];
    }

Resets the message symbol counter


Friends And Related Function Documentation

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;
}

Member Data Documentation

The reliability matrix stored column first.

incremented each time a new message symbol data is entered


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines