00001 00029 #ifndef CRC_H 00030 #define CRC_H 00031 00032 #include <itpp/base/vec.h> 00033 #include <itpp/base/mat.h> 00034 00035 00036 namespace itpp 00037 { 00038 00064 class CRC_Code 00065 { 00066 public: 00067 00069 CRC_Code() { reverse_parity = false; } 00070 00078 CRC_Code(const std::string &code) { reverse_parity = false; set_code(code); } 00079 00081 void set_generator(const bvec &poly); 00082 00084 void set_code(const std::string &code); 00085 00087 void parity(const bvec &in_bits, bvec &out) const; 00088 00090 bool check_parity(const bvec &coded_bits) const; 00091 00093 void encode(const bvec &in_bits, bvec &out) const; 00094 00096 bvec encode(const bvec &in_bits) const; 00097 00099 bool decode(const bvec &coded_bits, bvec &out) const; 00100 00102 bool decode(bvec &bits) const; 00103 00104 private: 00105 bool reverse_parity; 00106 bvec polynomial; 00107 int no_parity; 00108 }; 00109 00110 } // namespace itpp 00111 00112 #endif // #ifndef CRC_H
Generated on Wed Jul 27 2011 16:27:04 for IT++ by Doxygen 1.7.4