00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 // 00003 // Copyright (C) 2001 Pierre L'Ecuyer (lecuyer@iro.umontreal.ca) 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License version 2 as 00007 // published by the Free Software Foundation; 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 // 00018 // Modified for ns-3 by: Rajib Bhattacharjea<raj.b@gatech.edu> 00019 00020 #ifndef RNGSTREAM_H 00021 #define RNGSTREAM_H 00022 #include <string> 00023 #include <stdint.h> 00024 00025 namespace ns3 { 00026 00027 /** 00028 * \ingroup core 00029 * \ingroup randomvariable 00030 * 00031 * \brief Combined Multiple-Recursive Generator MRG32k3a 00032 * 00033 * This class is the combined multiple-recursive random number 00034 * generator called MRG32k3a. The ns3::RandomVariableBase class 00035 * holds a static instance of this class. The details of this 00036 * class are explained in: 00037 * http://www.iro.umontreal.ca/~lecuyer/myftp/papers/streams00.pdf 00038 */ 00039 class RngStream { 00040 public: //public api 00041 RngStream (); 00042 RngStream (const RngStream&); 00043 void InitializeStream(); // Separate initialization 00044 void ResetStartStream (); 00045 void ResetStartSubstream (); 00046 void ResetNextSubstream (); 00047 void ResetNthSubstream(uint32_t N); 00048 void SetAntithetic (bool a); 00049 void IncreasedPrecis (bool incp); 00050 bool SetSeeds (const uint32_t seed[6]); 00051 void AdvanceState (int32_t e, int32_t c); 00052 void GetState (uint32_t seed[6]) const; 00053 double RandU01 (); 00054 int32_t RandInt (int32_t i, int32_t j); 00055 public: //public static api 00056 static bool SetPackageSeed (const uint32_t seed[6]); 00057 static bool CheckSeed(const uint32_t seed[6]); 00058 private: //members 00059 double Cg[6], Bg[6], Ig[6]; 00060 bool anti, incPrec; 00061 double U01 (); 00062 double U01d (); 00063 private: //static data 00064 static double nextSeed[6]; 00065 }; 00066 00067 } //namespace ns3 00068 00069 #endif 00070 00071