Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

bitmapping.h

Go to the documentation of this file.
00001 /*-*-c++-*-*****************************************************************
00002                           bitmapping.h  -  description
00003                              -------------------
00004     begin                : Mon May 26 2003
00005     copyright            : (C) 2003 by Peter Haase
00006     email                : p.haase@tuhh.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
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     //Bits pro Symbol
00149     //im folgenden Beispiel gleich 2
00150     const int bitsPerSymbol;
00151     //Modulationswertigkeit
00152     //im folgenden Beispiel gleich 4
00153     const int modulationValency;
00154 
00155     //die Bits werden in einem 2 dimensionalen
00156     //Vektor geschrieben
00157     //Beispiel (gray mapping)
00158     //
00159     //Symbol-|
00160     //index  | 0 | 1 | 2 | 3
00161     //       ------------------------
00162     //Bit 1  | 0 | 0 | 1 | 1
00163     //Bit 2  | 0 | 1 | 1 | 0
00164     simth::boolVector2d bitArray;
00165 
00166     //wie oben, aber anstatt der Bits pro Symbol
00167     //wird der zugehoerige Integerwert eingetragen
00168     //Fuer das obige Beispiel (gray mapping) also:
00169     //Symbol-|
00170     //index  | 0 | 1 | 2 | 3
00171     //       ------------------------
00172     //Wert   | 0 | 1 | 3 | 2
00173     int mappedIndex[simth::MAX_STATES_PER_SYMBOL];
00174     //Wie mappedIndex aber Invertierung durch Vertauschen der Zeilen
00175     int mappedInteger[simth::MAX_STATES_PER_SYMBOL];
00176 
00177   public:
00182     MappingScheme(int bitsPerState);
00183 
00184     virtual ~MappingScheme(){};
00185 
00186     //eventuell auf fehler vor boolVector2d testen
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     //virtual void print(std::ostream &os, bool detailedPrint = false) const;
00290 };
00291 
00292 // The factory classes MappingMaker have been removed in favor of
00293 // static factory functions in the MappingScheme class and additionaly
00294 // the usage of std::auto_ptr in the device classes. 
00295 
00296 
00297 }
00298 
00299 #endif

Generated on Tue Aug 9 14:35:10 2005 for simtheticlib by  doxygen 1.4.1