![]() |
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 #include <RISE/scenario/ftfading/JakesFadingGenerator.hpp> 00029 #include <WNS/module/Base.hpp> 00030 #include <WNS/distribution/Uniform.hpp> 00031 #include <WNS/rng/RNGen.hpp> 00032 00033 using namespace rise; 00034 using namespace rise::scenario; 00035 using namespace rise::scenario::ftfading; 00036 00037 JakesFadingGenerator::JakesFadingGenerator() 00038 { 00039 } 00040 00041 JakesFadingGenerator::~JakesFadingGenerator() 00042 {} 00043 00044 void 00045 JakesFadingGenerator::initJakes(const double _maximumDopplerFrequency, const double _samplingTime, const unsigned int _numberOfWaves) 00046 { 00047 currentSampleIndex = 0; 00048 00049 //maximumDopplerFrequency = _maximumDopplerFrequency; 00050 samplingTime = _samplingTime; 00051 //numberOfWaves = _numberOfWaves; 00052 numberOfWavesQuarter = _numberOfWaves/4; 00053 00054 wns::distribution::Uniform randomAngle = 00055 wns::distribution::Uniform(0.0, 2.0 * M_PI); // between 0..2pi 00056 00057 double scaleFactor = 2.0/std::sqrt(static_cast<double>(numberOfWavesQuarter)); 00058 00059 complexTurningFactorVector.resize(numberOfWavesQuarter, 0.0); 00060 for (unsigned int i=0; i<numberOfWavesQuarter; ++i) 00061 complexTurningFactorVector[i] = std::polar<double>(1,randomAngle() ) * scaleFactor; 00062 00063 omega.resize(numberOfWavesQuarter, 0.0); 00064 for (unsigned int i=0; i<numberOfWavesQuarter; ++i) 00065 omega[i] = 2.0*M_PI*_maximumDopplerFrequency * samplingTime * std::cos(static_cast<double>((2.0*M_PI*(i+0.5) + randomAngle()) / _numberOfWaves)); 00066 00067 thetaInitial = randomAngle(); // from random number generator 00068 } 00069 00070 // TODO?? std::complex<double> JakesFadingGenerator::getComplexFadingValue(unsigned int sample) 00071 00072 std::complex<double> 00073 JakesFadingGenerator::getNextComplexFadingValue() 00074 { 00075 std::complex<double> complexSum = 0.0; 00076 for (unsigned int i=0; i<numberOfWavesQuarter; ++i) 00077 complexSum += complexTurningFactorVector[i] * std::cos(omega[i]*currentSampleIndex/*now*/ + thetaInitial); 00078 ++currentSampleIndex; // advance timestep 00079 return complexSum; // * scaleFactor is now already included in complexTurningFactorVector[i] 00080 } 00081 00082 wns::Ratio 00083 JakesFadingGenerator::getNextFadingRatio() 00084 { 00085 return wns::Ratio::from_factor(std::abs(getNextComplexFadingValue())); 00086 } 00087 00088 double 00089 JakesFadingGenerator::getNextFadingValue() 00090 { 00091 return std::abs(getNextComplexFadingValue()); 00092 }
1.5.5