00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef PUNCTURING_H
00029 #define PUNCTURING_H
00030
00031
00032 #include "misc.h"
00033 #include "signals.h"
00034
00035 namespace simthlib
00036 {
00037
00041 class Puncturing
00042 {
00043 private:
00044
00047 static const char *punct2[14][7];
00048
00051 static const char *punct3[8][4];
00052
00055 static const char *punct4;
00056
00057
00059 int pO;
00060
00061 typedef simth::BitSeq::storage_type punctureTabType;
00062 punctureTabType punctureTab;
00063
00066 int depuncturedLength;
00067
00068 protected:
00069
00073 int getDepuncturedLength( ) const;
00074
00075 void invariant() const;
00076 public:
00084 Puncturing(int codeRateNumerator,int codeRateDenumerator,
00085 int memoryLength, int codeOutputBits, int codeInputBits = 1);
00086
00087
00088 Puncturing(const std::string& puncturePattern);
00089
00093 void puncture(const simth::BitSeq &inputSequence, simth::BitSeq* outputSequence) const;
00094 void puncture(const simth::LlrSeq &inputSequence, simth::LlrSeq* outputSequence) const;
00095 void depuncture(const simth::LlrSeq &inputSequence, simth::LlrSeq* outputSequence) const;
00096
00099 int getPuncturedLength(int len) const;
00100
00107 int getDepuncturedLength(int len) const;
00108
00114 void setDepuncturedLength (int outLen);
00115
00116
00117 };
00118
00119
00120 inline void Puncturing::invariant() const
00121 {
00122 if(DEBUG) {
00123 if(punctureTab.size() <= 0) {
00124 throw std::runtime_error("inline Puncturing::invariant() : error !");
00125 }
00126 }
00127 }
00128
00129 inline void Puncturing::setDepuncturedLength(int outputLen)
00130 {
00131 if(DEBUG) {
00132 if(outputLen < 0) {
00133 throw std::runtime_error("inline int Puncturing::setOutputLength(int outputLen) const : "
00134 "outputLen < 0");
00135 }
00136 }
00137 depuncturedLength = outputLen;
00138 }
00139
00140 inline int Puncturing::getDepuncturedLength( ) const
00141 {
00142 if(DEBUG) {
00143 if(depuncturedLength < 0) {
00144 throw std::runtime_error("inline int Puncturing::getDepuncturedLength(int outputLen) const : "
00145 "outputLength must be set before calling this function");
00146 }
00147 }
00148 return depuncturedLength;
00149 }
00150
00151 }
00152
00153 #endif