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 BITMAPPING_H
00029 #define BITMAPPING_H
00030
00031 #include <iostream>
00032 #include <memory>
00033
00034 #include <simthetic/misc.h>
00035 #include <simthetic/phbib.h>
00036 #include <simthetic/containers.h>
00037
00038 namespace simthlib
00039 {
00040
00041
00058 enum map_type {
00060 GRAY,
00062 NATURAL,
00064 PARTITIONED
00065 };
00067 map_type string2map_type(const std::string& s);
00068
00069 class MappingScheme;
00070 std::ostream& operator<<(std::ostream &os, const MappingScheme& mapping);
00071
00072
00073
00076 class Gray
00077 {
00078 private:
00079
00081 int grayMap[simth::MAX_STATES_PER_SYMBOL];
00082
00084 int invGrayMap[simth::MAX_STATES_PER_SYMBOL];
00085
00087 void check(int i);
00088 public:
00090 Gray();
00096 int toGray(int i);
00102 int inverseGray(int i);
00103 };
00104
00105
00110 class StaticGray
00111 {
00112 private:
00114 static Gray helpGray;
00115
00116 public:
00122 static int toGray(int i);
00123
00129 static int inverseGray(int i);
00130 };
00131
00132
00133
00134
00135
00136
00145 class MappingScheme
00146 {
00147 protected:
00148
00149
00150 const int bitsPerSymbol;
00151
00152
00153 const int modulationValency;
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 simth::boolVector2d bitArray;
00165
00166
00167
00168
00169
00170
00171
00172
00173 int mappedIndex[simth::MAX_STATES_PER_SYMBOL];
00174
00175 int mappedInteger[simth::MAX_STATES_PER_SYMBOL];
00176
00177 public:
00182 MappingScheme(int bitsPerState);
00183
00184 virtual ~MappingScheme(){};
00185
00186
00194 bool getBit(int symbIndex, int bitPos) const
00195 {return bitArray[symbIndex][bitPos];}
00196
00201 int getDataValue(int symbolIndex) const ;
00202
00203
00207 int getSymbolIndex(int integerValue) const ;
00208
00209
00210 virtual void print(std::ostream &os, bool detailedPrint = false) const;
00211
00214 static std::auto_ptr<simthlib::MappingScheme>
00215 newMapping(int bitsPerSymbolPar, map_type mappMode);
00216 static std::auto_ptr<simthlib::MappingScheme>
00217 new2DimMapping(int numBits1, int numBits2, map_type mappMode);
00218 static std::auto_ptr<simthlib::MappingScheme>
00219 newApskMapping(int bitsPerState, map_type mappMode);
00220 static std::auto_ptr<simthlib::MappingScheme>
00221 newQamMapping(int bitsPerState, map_type mappMode);
00223 };
00224
00225
00226
00227
00228
00229
00230 class NaturalMapping : public MappingScheme
00231 {
00232
00233 public:
00236 NaturalMapping(int bitsPerState);
00237
00238 virtual ~NaturalMapping(){};
00239
00240 virtual void print(std::ostream &os, bool detailedPrint = false) const;
00241 };
00242
00243 class GrayMapping : public MappingScheme
00244 {
00245
00246 public:
00249 GrayMapping(int bitsPerState);
00250 virtual ~GrayMapping(){};
00251 virtual void print(std::ostream &os, bool detailedPrint = false) const;
00252 };
00253
00258 class GrayMapping2Dimension : public MappingScheme
00259 {
00260 public:
00263 GrayMapping2Dimension(int bitsPerAmplitude, int bitsPerPhase);
00264 virtual ~GrayMapping2Dimension(){};
00265 virtual void print(std::ostream &os, bool detailedPrint = false) const;
00266 };
00267
00278 class PartitionedMappingRectangular : public MappingScheme
00279 {
00280 private:
00281 int reBits;
00282 int imBits;
00283 void partitioningStep(int step);
00284 public:
00287 PartitionedMappingRectangular(int bitsPerSymbol);
00288 virtual ~PartitionedMappingRectangular(){};
00289
00290 };
00291
00292
00293
00294
00295
00296
00297 }
00298
00299 #endif