![]() |
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_SCENARIO_PATHLOSS_DETAIL_HASHRNG_HPP 00029 #define RISE_SCENARIO_PATHLOSS_DETAIL_HASHRNG_HPP 00030 00031 #include <RISE/scenario/pathloss/DistanceDependent.hpp> 00032 #include <boost/random.hpp> 00033 00034 namespace rise { namespace scenario { namespace pathloss { 00035 00036 namespace detail { 00037 00045 class HashRNG 00046 { 00047 public: 00048 HashRNG(unsigned int initialSeed, 00049 wns::Position p1, 00050 wns::Position p2, 00051 bool correlateBS, 00052 bool correlateUT); 00053 00054 static const bool has_fixed_range = true; 00055 00056 double 00057 operator()(); 00058 00059 double 00060 min() 00061 { 00062 return 0.0; 00063 } 00064 00065 double 00066 max() 00067 { 00068 return 1.0; 00069 } 00070 00071 private: 00072 template<typename T> 00073 void combine( unsigned int& hash, T t) 00074 { 00075 unsigned int* it= (unsigned int*)(&t); 00076 00077 assure(sizeof(T) % sizeof(unsigned int) == 0, "Incompatible hash types in HashRNG::combineDouble"); 00078 00079 int count = sizeof(T) / sizeof(unsigned int); 00080 00081 for (int ii=0; ii < count; ++ii) 00082 { 00083 // DJB Hash function 00084 hash = ((hash << 5) + hash) + *it; 00085 it++; 00086 } 00087 } 00088 00089 boost::mt19937 rng; 00090 boost::uniform_real<> uni; 00091 boost::variate_generator<boost::mt19937&, boost::uniform_real<> > dis; 00092 00093 unsigned int myHash; 00094 }; 00095 00096 } // detail 00097 } // pathloss 00098 } // scenario 00099 } // rise 00100 00101 #endif // RISE_SCENARIO_PATHLOSS_DETAIL_HASHRNG_HPP
1.5.5