rssoft  0.0.0
Reed-Solomon codes library with soft decision decoding
/shared/development/google_code/rssoft/library/lib/GFq_BivariateMonomial.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  Bivariate monomials with coefficient in GF(2^m) class
00021 
00022  */
00023 #ifndef __GFQ_BIVARIATE_MONOMIAL_H__
00024 #define __GFQ_BIVARIATE_MONOMIAL_H__
00025 
00026 #include <GFq_Element.h>
00027 #include <utility>
00028 
00029 namespace rssoft
00030 {
00031 namespace gf
00032 {
00033 
00037 class GFq_BivariateMonomialExponents : public std::pair<unsigned int, unsigned int>
00038 {
00039 public:
00040         GFq_BivariateMonomialExponents(unsigned int eX, unsigned int eY);
00041         GFq_BivariateMonomialExponents(const std::pair<unsigned int, unsigned int>& _exponents);
00042 
00046         unsigned int x() const
00047         {
00048                 return first;
00049         }
00050 
00054         unsigned int y() const
00055         {
00056                 return second;
00057         }
00058 
00064         unsigned int wdeg(unsigned int wX, unsigned int wY) const
00065         {
00066                 return wX*first + wY*second;
00067         }
00068 
00073         unsigned int wdeg(const std::pair<unsigned int, unsigned int>& weights) const
00074         {
00075                 return weights.first*first + weights.second*second;
00076         }
00077 
00081         bool are_zero() const
00082         {
00083                 return (first == 0) && (second == 0);
00084         }
00085 };
00086 
00091 typedef std::pair<GFq_BivariateMonomialExponents, GFq_Element> GFq_BivariateMonomialKeyValueRepresentation;
00092 
00096 class GFq_BivariateMonomial : public std::pair<GFq_BivariateMonomialExponents, GFq_Element>
00097 {
00098 public:
00099         GFq_BivariateMonomial(const GFq_Element& coeff, unsigned int eX, unsigned int eY);
00100         GFq_BivariateMonomial(const GFq_Element& coeff, const GFq_BivariateMonomialExponents& exponents);
00101         GFq_BivariateMonomial(const GFq_BivariateMonomialKeyValueRepresentation& monomial_rep);
00102 
00103         const GFq_Element& coeff() const
00104         {
00105                 return second;
00106         }
00107 
00108         unsigned int eX() const
00109         {
00110                 return first.first;
00111         }
00112 
00113         unsigned int eY() const
00114         {
00115                 return first.second;
00116         }
00117 
00118         const GFq_BivariateMonomialExponents& get_exponents() const
00119         {
00120                 return first;
00121         }
00122 
00123         unsigned int wdeg(unsigned int wX, unsigned int wY) const
00124         {
00125                 return first.wdeg(wX, wY);
00126         }
00127 
00128         unsigned int wdeg(const std::pair<unsigned int, unsigned int>& weights) const
00129         {
00130                 return first.wdeg(weights);
00131         }
00132 
00133         GFq_BivariateMonomial& operator =(const GFq_BivariateMonomial& monomial);
00134         GFq_BivariateMonomial& operator+=(const GFq_BivariateMonomial& monomial);
00135         GFq_BivariateMonomial& operator+=(const GFq_Element& gfe);
00136         GFq_BivariateMonomial& operator-=(const GFq_BivariateMonomial& monomial);
00137         GFq_BivariateMonomial& operator-=(const GFq_Element& gfe);
00138         GFq_BivariateMonomial& operator*=(const GFq_BivariateMonomial& monomial);
00139         GFq_BivariateMonomial& operator*=(const GFq_Element& gfe);
00140         GFq_BivariateMonomial& operator/=(const GFq_BivariateMonomial& monomial);
00141         GFq_BivariateMonomial& operator/=(const GFq_Element& gfe);
00142 };
00143 
00144 GFq_BivariateMonomial operator +(const GFq_BivariateMonomial& a, const GFq_BivariateMonomial& b);
00145 GFq_BivariateMonomial operator +(const GFq_BivariateMonomial& a, const GFq_Element& b);
00146 GFq_BivariateMonomial operator +(const GFq_Element& a, const GFq_BivariateMonomial& b);
00147 GFq_BivariateMonomial operator -(const GFq_BivariateMonomial& a, const GFq_BivariateMonomial& b);
00148 GFq_BivariateMonomial operator -(const GFq_BivariateMonomial& a, const GFq_Element& b);
00149 GFq_BivariateMonomial operator -(const GFq_Element& a, const GFq_BivariateMonomial& b);
00150 GFq_BivariateMonomial operator *(const GFq_BivariateMonomial& a, const GFq_BivariateMonomial& b);
00151 GFq_BivariateMonomial operator *(const GFq_Element& a, const GFq_BivariateMonomial& b);
00152 GFq_BivariateMonomial operator *(const GFq_BivariateMonomial& a, const GFq_Element& b);
00153 GFq_BivariateMonomial operator /(const GFq_BivariateMonomial& a, const GFq_BivariateMonomial& b);
00154 GFq_BivariateMonomial operator /(const GFq_BivariateMonomial& a, const GFq_Element& b);
00155 
00159 std::ostream& operator <<(std::ostream& os, const GFq_BivariateMonomialKeyValueRepresentation& monomial);
00160 
00164 GFq_BivariateMonomialKeyValueRepresentation make_bivariate_monomial(GFq_Element coeff, unsigned int exp_x, unsigned int exp_y);
00165 
00169 class GFq_WeightedRevLex_BivariateMonomial
00170 {
00171 public:
00177         GFq_WeightedRevLex_BivariateMonomial(unsigned int w_x, unsigned int w_y);
00178 
00183         GFq_WeightedRevLex_BivariateMonomial(const std::pair<unsigned int, unsigned int>& weights);
00184 
00190         bool operator()(const GFq_BivariateMonomialExponents& e1, const GFq_BivariateMonomialExponents& e2) const;
00191 
00195         ~GFq_WeightedRevLex_BivariateMonomial();
00196 
00197 protected:
00198         std::pair<unsigned int, unsigned int> weights;
00199 };
00200 
00201 } // namespace gf
00202 } // namespace rssoft
00203 
00204 #endif // __GFQ_BIVARIATE_MONOMIAL_H__
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines