![]() |
rssoft
0.0.0
Reed-Solomon codes library with soft decision decoding
|
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 Final evaluation of result polynomials to get possible codewords 00021 00022 */ 00023 #ifndef __FINAL_EVALUATION_H__ 00024 #define __FINAL_EVALUATION_H__ 00025 00026 #include "GFq.h" 00027 #include "GFq_Element.h" 00028 #include "GF_Utils.h" 00029 #include <vector> 00030 #include <map> 00031 00032 namespace rssoft 00033 { 00034 namespace gf 00035 { 00036 class GFq_Polynomial; 00037 } 00038 00039 class EvaluationValues; 00040 class ReliabilityMatrix; 00041 00045 class ProbabilityCodeword : public std::pair<float, std::vector<gf::GFq_Symbol> > 00046 { 00047 public: 00052 ProbabilityCodeword(); 00053 00057 ProbabilityCodeword(float probability, const std::vector<gf::GFq_Symbol>& codeword); 00058 00062 ~ProbabilityCodeword(); 00063 00067 void add_symbol(const gf::GFq_Symbol& symbol) 00068 { 00069 second.push_back(symbol); 00070 } 00071 00075 float get_probability_score() const 00076 { 00077 return first; 00078 } 00079 00083 float& get_probability_score() 00084 { 00085 return first; 00086 } 00087 00091 const std::vector<gf::GFq_Symbol>& get_codeword() const 00092 { 00093 return second; 00094 } 00095 00099 std::vector<gf::GFq_Symbol>& get_codeword() 00100 { 00101 return second; 00102 } 00103 00107 bool operator<(const ProbabilityCodeword& other) const 00108 { 00109 return first < other.first; 00110 } 00111 00115 bool operator>(const ProbabilityCodeword& other) const 00116 { 00117 return first > other.first; 00118 } 00119 00123 void print_codeword(std::ostream& os) const; 00124 }; 00125 00129 std::ostream& operator <<(std::ostream& os, const ProbabilityCodeword& scored_codeword); 00130 00131 00132 class FinalEvaluation 00133 { 00134 public: 00141 FinalEvaluation(const gf::GFq& _gf, unsigned int _k, const EvaluationValues& _evaluation_values); 00142 00146 ~FinalEvaluation(); 00147 00151 void run(const std::vector<gf::GFq_Polynomial>& polynomials, const ReliabilityMatrix& relmat); 00152 00156 const std::vector<gf::GFq_Symbol>& get_best_codeword() const 00157 { 00158 return codewords.begin()->get_codeword(); 00159 } 00160 00164 const std::vector<ProbabilityCodeword>& get_codewords() const 00165 { 00166 return codewords; 00167 } 00168 00172 const std::vector<gf::GFq_Symbol>& get_best_message() const 00173 { 00174 return messages.begin()->get_codeword(); 00175 } 00176 00180 const std::vector<ProbabilityCodeword>& get_messages() const 00181 { 00182 return messages; 00183 } 00184 00188 void print_codewords(std::ostream& os, const std::vector<ProbabilityCodeword>& words) const; 00189 00190 protected: 00191 const gf::GFq& gf; 00192 unsigned int k; 00193 const EvaluationValues& evaluation_values; 00194 std::map<gf::GFq_Element, unsigned int> symbol_index; 00195 std::vector<ProbabilityCodeword> codewords; 00196 std::vector<ProbabilityCodeword> messages; 00197 }; 00198 00199 } // namespace rssoft 00200 00201 #endif // __FINAL_EVALUATION_H__ 00202 00203