/*---------------------------------------------------------------------------*
 *                                   IT++			             *
 *---------------------------------------------------------------------------*
 * Copyright (c) 1995-2001 by Tony Ottosson, Thomas Eriksson, Pål Frenger,   *
 * Tobias Ringström, and Jonas Samuelsson.                                   *
 *                                                                           *
 * Permission to use, copy, modify, and distribute this software and its     *
 * documentation under the terms of the GNU General Public License is hereby *
 * granted. No representations are made about the suitability of this        *
 * software for any purpose. It is provided "as is" without expressed or     *
 * implied warranty. See the GNU General Public License for more details.    *
 *---------------------------------------------------------------------------*/

/*! 
  \file 
  \brief Definitions of a Reed-Solomon codec class
  \author Pål Frenger

  1.7

  2003/05/22 08:55:18
*/

#ifndef __reedsolomon_h
#define __reedsolomon_h

#include "base/vec.h"
#include "comm/galois.h"

namespace itpp {

  //---------------------- Reed-Solomon --------------------------------------

  /*! 
    \ingroup fec
    \brief Reed-Solomon Codes.
  
    Uses the Berlkamp-Massey algorithm for decoding as described in: S. B. Wicker,
    "Error Control Systems for digital communication and storage," Prentice Hall.

    The code is \f$2^m\f$ - ary of length \f$2^m-1\f$ capable of correcting \f$t\f$ errors.
  */
  class Reed_Solomon {
  public:
    //! Class constructor for the \f$2^m\f$ - ary, \f$t\f$ error correcting RS-code.
    Reed_Solomon(int in_m, int in_t);
    //! Encoder function.
    bvec encode(const bvec &uncodedbits);
    //! Decoder function
    bvec decode(const bvec &codedbits);
    //! Gets the rate of the RS-code.
    double get_rate() { return double(k)/double(n); }
  protected:
    //! Internal encoder/decoder parameters
    int m, t, k, n, q;
    //! The generator polynomial of the RS code
    GFX g;
  };

} //namespace itpp

#endif // __reedsolomon_h


syntax highlighted by Code2HTML, v. 0.9.1