![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef RISE_PLMAPPING_SNR2MI_HPP 00029 #define RISE_PLMAPPING_SNR2MI_HPP 00030 00031 #include <WNS/PowerRatio.hpp> 00032 #include <WNS/container/Mapping.hpp> 00033 #include <WNS/Enum.hpp> 00034 #include <WNS/Singleton.hpp> 00035 #include <WNS/service/phy/phymode/SNR2MIInterface.hpp> 00036 00037 namespace rise { namespace plmapping { 00038 00039 namespace tests { 00040 class SNR2MITest; 00041 class CoderFullTests; 00042 } 00043 00044 const unsigned int MAX_MODULATIONS_FOR_TABLE = 6; // only up to QAM64 00045 00054 class SNR2MI : 00055 virtual public wns::service::phy::phymode::SNR2MIInterface 00056 { 00057 friend class tests::SNR2MITest; 00058 friend class tests::CoderFullTests; 00059 public: 00060 virtual ~SNR2MI(){} 00062 virtual double convertSNR2MIB(const wns::Ratio& snr, const wns::service::phy::phymode::PhyModeInterface& phyMode) const; 00064 virtual double convertSNR2MI(const wns::Ratio& snr, const wns::service::phy::phymode::PhyModeInterface& phyMode) const; 00067 virtual wns::Ratio convertMIB2SNR(const double& mib, const wns::service::phy::phymode::Modulation& mod) const; 00068 00069 private: 00071 virtual double mapSNR2MI(const wns::Ratio& snr, wns::service::phy::phymode::Modulation modTYPE) const = 0; 00073 double convertSNR2MIB(const wns::Ratio& snr, wns::service::phy::phymode::Modulation modTYPE) const; 00074 00078 static double BER2MIB(double ber); 00082 static double MIB2BER(double mib); 00083 }; 00084 00085 00088 class SNR2MIFormula : 00089 public SNR2MI 00090 { 00091 public: 00092 SNR2MIFormula(){}; 00093 virtual ~SNR2MIFormula(){}; 00094 00095 private: 00097 virtual double mapSNR2MI(const wns::Ratio& snr, wns::service::phy::phymode::Modulation modTYPE) const; 00098 }; 00099 00100 00102 class SNR2MIMap : 00103 public SNR2MI, 00104 public wns::container::Mapping<wns::service::phy::phymode::Modulation, double> 00105 { 00106 public: 00107 SNR2MIMap(); 00108 virtual ~SNR2MIMap(){}; 00109 00110 private: 00112 virtual double mapSNR2MI(const wns::Ratio& snr, wns::service::phy::phymode::Modulation modTYPE) const; 00113 00115 void initBPSK(); 00116 void initQPSK(); 00117 void initQAM8(); 00118 void initQAM16(); 00119 void initQAM32(); 00120 void initQAM64(); 00121 00122 }; 00123 00127 inline double rootFindByBisection(double (*func)(double), double offset, double x1, double x2, double accuracy) 00128 { 00129 const unsigned int maxIterations = 100; 00130 unsigned int iteration; 00131 double f = (*func)(x1) - offset; 00132 double fmid = (*func)(x2) - offset; 00133 assure(f*fmid<0.0, "rootFindByBisection(): Root must be bracketed within ["<<x1<<","<<x2<<"]: f="<<f<<", fmid="<<fmid); 00134 double rtb = (f<0.0) ? x1 : x2; 00135 double dx = (f<0.0) ? (x2-x1) : (x1-x2); 00136 for(iteration=1; iteration<=maxIterations; iteration++) { 00137 double xmid=rtb+(dx *= 0.5); 00138 fmid = (*func)(xmid) - offset; 00139 if (fmid <= 0.0) rtb=xmid; 00140 if ((fabs(dx) < accuracy) || (fmid == 0.0)) return rtb; 00141 } 00142 assure(false,"rootFindByBisection(): too many iterations: "<<maxIterations); 00143 return rtb; 00144 } 00145 00146 }} 00147 #endif // RISE_PLMAPPING_SNR2MI_HPP 00148 00149
1.5.5