rssoft  0.0.0
Reed-Solomon codes library with soft decision decoding
/shared/development/google_code/rssoft/library/lib/MultiplicityMatrix.h
Go to the documentation of this file.
00001 /*
00002  Copyright 2013 Edouard Griffiths <f4exb at free dot fr>
00003 
00004  This file is part of RSSoft. A Reed-Solomon Soft Decoding library
00005 
00006  This program is free software; you can redistribute it and/or modify
00007  it under the terms of the GNU General Public License as published by
00008  the Free Software Foundation; either version 2 of the License, or
00009  (at your option) any later version.
00010 
00011  This program is distributed in the hope that it will be useful,
00012  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  GNU General Public License for more details.
00015 
00016  You should have received a copy of the GNU General Public License
00017  along with this program; if not, write to the Free Software
00018  Foundation, Inc., 51 Franklin Street, Boston, MA  02110-1301  USA
00019 
00020  Multiplicity Matrix class
00021 
00022  */
00023  #ifndef __MULTIPLICITY_MATRIX_H__
00024  #define __MULTIPLICITY_MATRIX_H__
00025  
00026  #include <utility>
00027  #include <map>
00028  #include <iostream>
00029 
00030 namespace rssoft
00031 {
00032 
00033 class ReliabilityMatrix;
00034 
00038 class MultiplicityMatrix_SparseOrdering
00039 {
00040 public:
00041     MultiplicityMatrix_SparseOrdering() {}
00042     ~MultiplicityMatrix_SparseOrdering() {}
00043     
00044     bool operator()(const std::pair<unsigned int, unsigned int>& index1, const std::pair<unsigned int, unsigned int>& index2) const
00045     {
00046         if (index1.second == index2.second) // same column
00047         {
00048             return index1.first < index2.first; // row order
00049         }
00050         else
00051         {
00052             return index1.second < index2.second; // column order
00053         }
00054     }
00055 };
00056 
00062 class MultiplicityMatrix : public std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>
00063 {
00064 public:
00068     class traversing_iterator : public std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator
00069     {
00070     public:
00075         traversing_iterator(std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator const &c) :
00076                 std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator(c) {}
00077 
00081         unsigned int iX()
00082         {
00083                 std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator *c_it = this;
00084                 return (*c_it)->first.second;
00085         }
00086 
00090         unsigned int iY()
00091         {
00092                 std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator *c_it = this;
00093                 return (*c_it)->first.first;
00094         }
00095 
00099         unsigned int multiplicity()
00100         {
00101                 std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator *c_it = this;
00102                 return (*c_it)->second;
00103         }
00104     };
00105 
00113     MultiplicityMatrix(const ReliabilityMatrix& relmat, unsigned int multiplicity, bool soft_decision=true);
00114 
00120     MultiplicityMatrix(const ReliabilityMatrix& relmat, float lambda);
00121     
00125     ~MultiplicityMatrix();
00126     
00131     unsigned int cost() const
00132     {
00133         return _cost;
00134     }
00135     
00139         unsigned int get_nb_symbols_log2() const
00140         {
00141                 return _nb_symbols_log2;
00142         }
00143 
00147         unsigned int get_nb_symbols() const
00148         {
00149                 return _nb_symbols;
00150         }
00151 
00155         unsigned int get_message_length() const
00156         {
00157                 return _message_length;
00158         }
00159 
00163         unsigned int operator()(unsigned int i_row, unsigned int i_col) const;
00164 
00168         friend std::ostream& operator <<(std::ostream& os, const MultiplicityMatrix& matrix);
00169     
00170 
00171 protected:
00179     typedef std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::const_iterator const_iterator;
00180 
00188     typedef std::map<std::pair<unsigned int, unsigned int>, unsigned int, MultiplicityMatrix_SparseOrdering>::iterator iterator;
00189 
00193         iterator operator()(unsigned int i_row, unsigned int i_col)
00194     {
00195         return find(std::make_pair(i_row, i_col));
00196     }
00197 
00198         unsigned int _nb_symbols_log2; 
00199         unsigned int _nb_symbols; 
00200         unsigned int _message_length; 
00201     unsigned int _cost; 
00202 };
00203  
00204 } // namespace rssoft
00205 
00206  #endif // __MULTIPLICITY_MATRIX_H__
00207  
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines