src/core/rng-stream.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 4231 6f9f859bae8b
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
tomh@346
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
tomh@346
     2
//
tomh@346
     3
//  Copyright (C) 2001  Pierre L'Ecuyer (lecuyer@iro.umontreal.ca)
tomh@346
     4
//
tomh@346
     5
// This program is free software; you can redistribute it and/or modify
tomh@346
     6
// it under the terms of the GNU General Public License version 2 as
tomh@346
     7
// published by the Free Software Foundation;
tomh@346
     8
//
tomh@346
     9
// This program is distributed in the hope that it will be useful,
tomh@346
    10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
tomh@346
    11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
tomh@346
    12
// GNU General Public License for more details.
tomh@346
    13
//
tomh@346
    14
// You should have received a copy of the GNU General Public License
tomh@346
    15
// along with this program; if not, write to the Free Software
tomh@346
    16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
tomh@346
    17
//
tomh@346
    18
// Modified for ns-3 by: Rajib Bhattacharjea<raj.b@gatech.edu>
tomh@346
    19
tomh@346
    20
#ifndef RNGSTREAM_H
tomh@346
    21
#define RNGSTREAM_H
tomh@346
    22
#include <string>
Emmanuelle@676
    23
#include <stdint.h>
tomh@346
    24
tomh@2797
    25
namespace ns3 {
tomh@346
    26
tomh@2797
    27
/**
tomh@2797
    28
 * \ingroup core
tomh@2797
    29
 * \ingroup randomvariable 
tomh@2797
    30
 *
tomh@2797
    31
 * \brief Combined Multiple-Recursive Generator MRG32k3a
tomh@2797
    32
 *
tomh@2797
    33
 * This class is the combined multiple-recursive random number
tomh@2797
    34
 * generator called MRG32k3a.  The ns3::RandomVariableBase class
tomh@2797
    35
 * holds a static instance of this class.  The details of this
tomh@2797
    36
 * class are explained in:  
tomh@2797
    37
 * http://www.iro.umontreal.ca/~lecuyer/myftp/papers/streams00.pdf
tomh@2797
    38
 */
tomh@346
    39
class RngStream {
tomh@346
    40
public:  //public api
tomh@346
    41
  RngStream ();
raj@360
    42
  RngStream (const RngStream&);
tomh@346
    43
  void InitializeStream(); // Separate initialization
tomh@346
    44
  void ResetStartStream ();
tomh@346
    45
  void ResetStartSubstream ();
tomh@346
    46
  void ResetNextSubstream ();
raj@364
    47
  void ResetNthSubstream(uint32_t N);
tomh@346
    48
  void SetAntithetic (bool a);
tomh@346
    49
  void IncreasedPrecis (bool incp);
tomh@346
    50
  bool SetSeeds (const uint32_t seed[6]);
tomh@346
    51
  void AdvanceState (int32_t e, int32_t c);
tomh@346
    52
  void GetState (uint32_t seed[6]) const;
tomh@346
    53
  double RandU01 ();
tomh@346
    54
  int32_t RandInt (int32_t i, int32_t j);
tomh@346
    55
public: //public static api
raj@4224
    56
  static bool SetPackageSeed (uint32_t seed);
tomh@346
    57
  static bool SetPackageSeed (const uint32_t seed[6]);
raj@4224
    58
  static void GetPackageSeed (uint32_t seed[6]);
raj@4224
    59
  static void SetPackageRun (uint32_t run);
raj@4224
    60
  static uint32_t GetPackageRun (void);
tomh@346
    61
  static bool CheckSeed(const uint32_t seed[6]);
raj@4224
    62
  static bool CheckSeed(uint32_t seed);
tomh@346
    63
private: //members
tomh@346
    64
  double Cg[6], Bg[6], Ig[6];
tomh@346
    65
  bool anti, incPrec;
tomh@346
    66
  double U01 ();
tomh@346
    67
  double U01d ();
raj@4224
    68
  static uint32_t EnsureGlobalInitialized (void);
tomh@346
    69
private: //static data
tomh@346
    70
  static double nextSeed[6];
tomh@346
    71
};
tomh@346
    72
tomh@2797
    73
} //namespace ns3
tomh@346
    74
tomh@346
    75
#endif
tomh@346
    76
 
tomh@346
    77