Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

RNG Class Reference

#include <rng.h>

Inheritance diagram for RNG:

Inheritance graph
[legend]
Collaboration diagram for RNG:

Collaboration graph
[legend]
List of all members.

Public Types

enum  RNGSources { RAW_SEED_SOURCE, PREDEF_SEED_SOURCE, HEURISTIC_SEED_SOURCE }

Public Member Functions

 RNG (const char *name="")
 RNG (long seed)
void init ()
long seed ()
void set_seed (long seed)
long next ()
double next_double ()
 RNG (RNGSources source, int seed=1)
void set_seed (RNGSources source, int seed=1)
void reset_start_stream ()
void reset_start_substream ()
void reset_next_substream ()
void set_antithetic (bool a)
void increased_precis (bool incp)
void set_seed (const unsigned long seed[6])
void advance_state (long e, long c)
void get_state (unsigned long seed[6]) const
void write_state () const
void write_state_full () const
double rand_u01 ()
long rand_int (long i, long j)
int command (int argc, const char *const *argv)
int uniform_positive_int ()
double uniform_double ()
int random ()
double uniform ()
int uniform (int k)
double uniform (double r)
double uniform (double a, double b)
double exponential ()
double exponential (double r)
double pareto (double scale, double shape)
double paretoII (double scale, double shape)
double normal (double avg, double std)
double lognormal (double avg, double std)

Static Public Member Functions

RNGdefaultrng ()
void set_package_seed (const unsigned long seed[6])

Protected Member Functions

double U01 ()
double U01d ()

Protected Attributes

double Cg_ [6]
double Bg_ [6]
double Ig_ [6]
bool anti_
bool inc_prec_
char name_ [100]

Static Protected Attributes

double next_seed_ [6]
RNGdefault_ = NULL

Member Enumeration Documentation

enum RNG::RNGSources
 

Enumeration values:
RAW_SEED_SOURCE 
PREDEF_SEED_SOURCE 
HEURISTIC_SEED_SOURCE 

Definition at line 106 of file rng.h.


Constructor & Destructor Documentation

RNG::RNG const char *  name = ""  ) 
 

Definition at line 818 of file rng.cc.

References init(), and name_.

00819 { 
00820         if (strlen (s) > 99) {
00821                 strncpy (name_, s, 99);
00822                 name_[100] = 0;
00823         }
00824         else 
00825                 strcpy (name_, s);
00826 
00827         init();
00828 }

Here is the call graph for this function:

RNG::RNG long  seed  ) 
 

Definition at line 748 of file rng.cc.

References init(), and set_seed().

00749 {
00750         set_seed (seed);
00751         init();
00752 }

Here is the call graph for this function:

RNG::RNG RNGSources  source,
int  seed = 1
[inline]
 

Definition at line 121 of file rng.h.

References set_seed().

00121 { set_seed(source, seed); };

Here is the call graph for this function:


Member Function Documentation

void RNG::advance_state long  e,
long  c
 

Definition at line 884 of file rng.cc.

References A1p0, A2p0, Cg_, InvA1, InvA2, m1, m2, MatMatModM(), MatPowModM(), MatTwoPowModM(), and MatVecModM().

00885 { 
00886         double B1[3][3], C1[3][3], B2[3][3], C2[3][3]; 
00887         if (e > 0) { 
00888                 MatTwoPowModM (A1p0, B1, m1, e); 
00889                 MatTwoPowModM (A2p0, B2, m2, e); 
00890         } else if (e < 0) { 
00891                 MatTwoPowModM (InvA1, B1, m1, -e); 
00892                 MatTwoPowModM (InvA2, B2, m2, -e); 
00893         } 
00894         if (c >= 0) { 
00895                 MatPowModM (A1p0, C1, m1, c); 
00896                 MatPowModM (A2p0, C2, m2, c); 
00897         } else { 
00898                 MatPowModM (InvA1, C1, m1, -c); 
00899                 MatPowModM (InvA2, C2, m2, -c); 
00900         } 
00901         if (e) { 
00902                 MatMatModM (B1, C1, C1, m1); 
00903                 MatMatModM (B2, C2, C2, m2); 
00904         } 
00905         MatVecModM (C1, Cg_, Cg_, m1); 
00906         MatVecModM (C2, &Cg_[3], &Cg_[3], m2); 
00907 } 

Here is the call graph for this function:

int RNG::command int  argc,
const char *const *  argv
 

Definition at line 219 of file rng.cc.

References default_, get_state(), HEURISTIC_SEED_SOURCE, lognormal(), MAXINT, normal(), PREDEF_SEED_SOURCE, RAW_SEED_SOURCE, reset_next_substream(), reset_start_substream(), seed(), set_seed(), uniform(), and uniform_positive_int().

00220 {
00221         Tcl& tcl = Tcl::instance();
00222 
00223         if (argc == 3) {
00224                 if (strcmp(argv[1], "testint") == 0) {
00225                         int n = atoi(argv[2]);
00226                         tcl.resultf("%d", uniform(n));
00227                         return (TCL_OK);
00228                 }
00229                 if (strcmp(argv[1], "testdouble") == 0) {
00230                         double d = atof(argv[2]);
00231                         tcl.resultf("%6e", uniform(d));
00232                         return (TCL_OK);
00233                 }
00234                 if (strcmp(argv[1], "seed") == 0) {
00235                         int s = atoi(argv[2]);
00236                         // NEEDSWORK: should be a way to set seed to PRDEF_SEED_SOURCE
00237                         if (s) {
00238                                 if (s <= 0 || (unsigned int)s >= MAXINT) {
00239                                         tcl.resultf("Setting random number seed to known bad value.");
00240                                         return TCL_ERROR;
00241                                 };
00242                                 set_seed(RAW_SEED_SOURCE, s);
00243                         } else set_seed(HEURISTIC_SEED_SOURCE, 0);
00244                         return(TCL_OK);
00245                 }
00246         } else if (argc == 2) {
00247                 if (strcmp(argv[1], "next-random") == 0) {
00248                         tcl.resultf("%u", uniform_positive_int());
00249                         return(TCL_OK);
00250                 }
00251                 if (strcmp(argv[1], "seed") == 0) {
00252 #ifdef OLD_RNG
00253                         tcl.resultf("%u", stream_.seed());
00254 #else
00255                         tcl.resultf("%u", seed());
00256 #endif /* OLD_RNG */
00257                         return(TCL_OK);
00258                 }
00259 #ifndef OLD_RNG
00260                 if (strcmp (argv[1], "next-substream") == 0) {
00261                         reset_next_substream();
00262                         return (TCL_OK);
00263                 }
00264                 if (strcmp (argv[1], "all-seeds") == 0) {
00265                         unsigned long seeds[6];
00266                         get_state (seeds);
00267                         tcl.resultf ("%lu %lu %lu %lu %lu %lu",
00268                                      seeds[0], seeds[1], seeds[2], 
00269                                      seeds[3], seeds[4], seeds[5]);
00270                         return (TCL_OK);
00271                 }
00272                 if (strcmp (argv[1], "reset-start-substream") == 0) {
00273                         reset_start_substream();
00274                         return (TCL_OK);
00275                 }
00276 #endif /* !OLD_RNG */
00277                 if (strcmp(argv[1], "default") == 0) {
00278                         default_ = this;
00279                         return(TCL_OK);
00280                 }
00281 #if 0
00282                 if (strcmp(argv[1], "test") == 0) {
00283                         if (test())
00284                                 tcl.resultf("RNG test failed");
00285                         else
00286                                 tcl.resultf("RNG test passed");
00287                         return(TCL_OK);
00288                 }
00289 #endif
00290         } else if (argc == 4) {
00291                 if (strcmp(argv[1], "seed") == 0) {
00292                         int s = atoi(argv[3]);
00293                         if (strcmp(argv[2], "raw") == 0) {
00294                                 set_seed(RNG::RAW_SEED_SOURCE, s);
00295                         } else if (strcmp(argv[2], "predef") == 0) {
00296                                 set_seed(RNG::PREDEF_SEED_SOURCE, s);
00297                                 // s is the index in predefined seed array
00298                                 // 0 <= s < 64
00299                         } else if (strcmp(argv[2], "heuristic") == 0) {
00300                                 set_seed(RNG::HEURISTIC_SEED_SOURCE, 0);
00301                         }
00302                         return(TCL_OK);
00303                 }
00304                 if (strcmp(argv[1], "normal") == 0) {
00305                         double avg = strtod(argv[2], NULL);
00306                         double std = strtod(argv[3], NULL);
00307                         tcl.resultf("%g", normal(avg, std));
00308                         return (TCL_OK);
00309                 }
00310                 if (strcmp(argv[1], "lognormal") == 0) {
00311                         double avg = strtod(argv[2], NULL);
00312                         double std = strtod(argv[3], NULL);
00313                         tcl.resultf("%g", lognormal(avg, std));
00314                         return (TCL_OK);
00315                 }
00316         }
00317         return(TclObject::command(argc, argv));
00318 }

Here is the call graph for this function:

RNG* RNG::defaultrng  )  [inline, static]
 

Definition at line 123 of file rng.h.

References default_.

Referenced by RA_Traffic::RA_Traffic(), RandomVariable::RandomVariable(), and Random::rng().

00123 { return (default_); }

double RNG::exponential double  r  )  [inline]
 

Definition at line 271 of file rng.h.

References exponential().

00272         { return (r * exponential());}

Here is the call graph for this function:

double RNG::exponential  )  [inline]
 

Definition at line 269 of file rng.h.

References uniform().

Referenced by exponential(), Random::exponential(), and ExponentialRandomVariable::value().

00270         { return (-log(uniform())); }

Here is the call graph for this function:

void RNG::get_state unsigned long  seed[6]  )  const
 

Definition at line 910 of file rng.cc.

References Cg_.

Referenced by command(), and seed().

00911 { 
00912         for (int i = 0; i < 6; ++i) 
00913                 seed[i] = static_cast<unsigned long> (Cg_[i]); 
00914 } 

void RNG::increased_precis bool  incp  ) 
 

Definition at line 955 of file rng.cc.

References inc_prec_.

00956 { 
00957         inc_prec_ = incp; 
00958 } 

void RNG::init  ) 
 

Definition at line 754 of file rng.cc.

References A1p127, A2p127, anti_, Bg_, Cg_, Ig_, inc_prec_, m1, m2, MatVecModM(), and next_seed_.

Referenced by RNG(), and set_seed().

00755 {
00756         anti_ = false; 
00757         inc_prec_ = false; 
00758 
00759         /* Information on a stream. The arrays {Cg_, Bg_, Ig_} contain the
00760            current state of the stream, the starting state of the current
00761            SubStream, and the starting state of the stream. This stream
00762            generates antithetic variates if anti_ = true. It also generates
00763            numbers with extended precision (53 bits if machine follows IEEE
00764            754 standard) if inc_prec_ = true. next_seed_ will be the seed of
00765            the next declared RngStream. */
00766 
00767         for (int i = 0; i < 6; ++i) { 
00768                 Bg_[i] = Cg_[i] = Ig_[i] = next_seed_[i]; 
00769         } 
00770         MatVecModM (A1p127, next_seed_, next_seed_, m1); 
00771         MatVecModM (A2p127, &next_seed_[3], &next_seed_[3], m2); 
00772 }

Here is the call graph for this function:

double RNG::lognormal double  avg,
double  std
[inline]
 

Definition at line 286 of file rng.h.

References normal().

Referenced by command(), Random::lognormal(), and LogNormalRandomVariable::value().

00286                                                         { 
00287                 return (exp (normal(avg, std))); 
00288         }

Here is the call graph for this function:

long RNG::next  ) 
 

Definition at line 796 of file rng.cc.

References MAXINT, and rand_int().

Referenced by set_seed(), and uniform_positive_int().

00797 {
00798         return (rand_int(0, MAXINT));
00799 }

Here is the call graph for this function:

double RNG::next_double  ) 
 

Definition at line 801 of file rng.cc.

References rand_u01().

Referenced by uniform_double().

00802 {
00803         return (rand_u01());
00804 }

Here is the call graph for this function:

double RNG::normal double  avg,
double  std
 

Definition at line 192 of file rng.cc.

References uniform().

Referenced by command(), lognormal(), Random::normal(), Shadowing::Pr(), and NormalRandomVariable::value().

00193 {
00194         static int parity = 0;
00195         static double nextresult;
00196         double sam1, sam2, rad;
00197    
00198         if (std == 0) return avg;
00199         if (parity == 0) {
00200                 sam1 = 2*uniform() - 1;
00201                 sam2 = 2*uniform() - 1;
00202                 while ((rad = sam1*sam1 + sam2*sam2) >= 1) {
00203                         sam1 = 2*uniform() - 1;
00204                         sam2 = 2*uniform() - 1;
00205                 }
00206                 rad = sqrt((-2*log(rad))/rad);
00207                 nextresult = sam2 * rad;
00208                 parity = 1;
00209                 return (sam1 * rad * std + avg);
00210         }
00211         else {
00212                 parity = 0;
00213                 return (nextresult * std + avg);
00214         }
00215 }

Here is the call graph for this function:

double RNG::pareto double  scale,
double  shape
[inline]
 

Definition at line 277 of file rng.h.

References pow(), and uniform().

Referenced by POO_Traffic::next_interval(), Random::pareto(), and ParetoRandomVariable::value().

00277                                                          { 
00278                 // When 1 < shape < 2, its mean is scale**shape, its 
00279                 // variance is infinite.
00280                 return (scale * (1.0/pow(uniform(), 1.0/shape)));
00281         }

Here is the call graph for this function:

double RNG::paretoII double  scale,
double  shape
[inline]
 

Definition at line 282 of file rng.h.

References pow(), and uniform().

Referenced by Random::paretoII(), and ParetoIIRandomVariable::value().

00282                                                            { 
00283                 return (scale * ((1.0/pow(uniform(), 1.0/shape)) - 1));
00284         }

Here is the call graph for this function:

long RNG::rand_int long  i,
long  j
 

Definition at line 980 of file rng.cc.

References rand_u01().

Referenced by next().

00981 { 
00982         //      return (long) low + (long) (((double) (high-low) * drn) + 0.5);
00983         return ((long) (low + (unsigned long) (((unsigned long) 
00984                                                 (high-low+1)) * rand_u01())));
00985 }; 

Here is the call graph for this function:

double RNG::rand_u01  ) 
 

Definition at line 969 of file rng.cc.

References inc_prec_, U01(), and U01d().

Referenced by next_double(), and rand_int().

00970 { 
00971         if (inc_prec_) 
00972                 return U01d(); 
00973         else 
00974                 return U01(); 
00975 } 

Here is the call graph for this function:

int RNG::random  )  [inline]
 

Definition at line 259 of file rng.h.

References uniform_positive_int().

00259 { return uniform_positive_int(); }

Here is the call graph for this function:

void RNG::reset_next_substream  ) 
 

Definition at line 852 of file rng.cc.

References A1p76, A2p76, Bg_, Cg_, m1, m2, and MatVecModM().

Referenced by command().

00853 { 
00854         MatVecModM(A1p76, Bg_, Bg_, m1); 
00855         MatVecModM(A2p76, &Bg_[3], &Bg_[3], m2); 
00856         for (int i = 0; i < 6; ++i) 
00857                 Cg_[i] = Bg_[i]; 
00858 } 

Here is the call graph for this function:

void RNG::reset_start_stream  ) 
 

Definition at line 834 of file rng.cc.

References Bg_, Cg_, and Ig_.

00835 { 
00836         for (int i = 0; i < 6; ++i) 
00837                 Cg_[i] = Bg_[i] = Ig_[i]; 
00838 } 

void RNG::reset_start_substream  ) 
 

Definition at line 843 of file rng.cc.

References Bg_, and Cg_.

Referenced by command().

00844 { 
00845         for (int i = 0; i < 6; ++i) 
00846                 Cg_[i] = Bg_[i]; 
00847 } 

long RNG::seed  ) 
 

Definition at line 789 of file rng.cc.

References get_state(), and seed().

Referenced by command(), seed(), and Random::seed_heuristically().

00790 {
00791         unsigned long seed[6];
00792         get_state(seed);
00793         return ((long) seed[0]);
00794 }

Here is the call graph for this function:

void RNG::set_antithetic bool  a  ) 
 

Definition at line 961 of file rng.cc.

References anti_.

00962 { 
00963         anti_ = a; 
00964 } 

void RNG::set_package_seed const unsigned long  seed[6]  )  [static]
 

Definition at line 861 of file rng.cc.

References abort(), CheckSeed(), and next_seed_.

Referenced by set_seed().

00862 { 
00863         if (CheckSeed (seed)) 
00864                 abort();
00865         for (int i = 0; i < 6; ++i) 
00866                 next_seed_[i] = seed[i]; 
00867 } 

Here is the call graph for this function:

void RNG::set_seed const unsigned long  seed[6]  ) 
 

Definition at line 870 of file rng.cc.

References abort(), Bg_, Cg_, CheckSeed(), and Ig_.

00871 { 
00872         if (CheckSeed (seed)) 
00873                 abort();
00874         for (int i = 0; i < 6; ++i) 
00875                 Cg_[i] = Bg_[i] = Ig_[i] = seed[i]; 
00876 } 

Here is the call graph for this function:

void RNG::set_seed RNGSources  source,
int  seed = 1
 

Definition at line 322 of file rng.cc.

References abort(), HEURISTIC_SEED_SOURCE, MAXINT, next(), PREDEF_SEED_SOURCE, RAW_SEED_SOURCE, and set_seed().

00323 {
00324         /* The following predefined seeds are evenly spaced around
00325          * the 2^31 cycle.  Each is approximately 33,000,000 elements
00326          * apart.
00327          */
00328 #define N_SEEDS_ 64
00329         static long predef_seeds[N_SEEDS_] = {
00330                 1973272912L,  188312339L, 1072664641L,  694388766L,
00331                 2009044369L,  934100682L, 1972392646L, 1936856304L,
00332                 1598189534L, 1822174485L, 1871883252L,  558746720L,
00333                 605846893L, 1384311643L, 2081634991L, 1644999263L,
00334                 773370613L,  358485174L, 1996632795L, 1000004583L,
00335                 1769370802L, 1895218768L,  186872697L, 1859168769L,
00336                 349544396L, 1996610406L,  222735214L, 1334983095L,
00337                 144443207L,  720236707L,  762772169L,  437720306L,
00338                 939612284L,  425414105L, 1998078925L,  981631283L,
00339                 1024155645L,  822780843L,  701857417L,  960703545L,
00340                 2101442385L, 2125204119L, 2041095833L,   89865291L,
00341                 898723423L, 1859531344L,  764283187L, 1349341884L,
00342                 678622600L,  778794064L, 1319566104L, 1277478588L,
00343                 538474442L,  683102175L,  999157082L,  985046914L,
00344                 722594620L, 1695858027L, 1700738670L, 1995749838L,
00345                 1147024708L,  346983590L,  565528207L,  513791680L
00346         };
00347         static long heuristic_sequence = 0;
00348 
00349         switch (source) {
00350         case RAW_SEED_SOURCE:
00351                 if (seed <= 0 || (unsigned int)seed >= MAXINT)    // Wei Ye
00352                         abort();
00353                 // use it as it is
00354                 break;
00355         case PREDEF_SEED_SOURCE:
00356                 if (seed < 0 || seed >= N_SEEDS_)
00357                         abort();
00358                 seed = predef_seeds[seed];
00359                 break;
00360         case HEURISTIC_SEED_SOURCE:
00361                 timeval tv;
00362                 gettimeofday(&tv, 0);
00363                 heuristic_sequence++;   // Always make sure we're different than last time.
00364                 seed = (tv.tv_sec ^ tv.tv_usec ^ (heuristic_sequence << 8)) & 0x7fffffff;
00365                 break;
00366         };
00367         // set it
00368         // NEEDSWORK: should we throw out known bad seeds?
00369         // (are there any?)
00370         if (seed < 0)
00371                 seed = -seed;
00372 #ifdef OLD_RNG
00373         stream_.set_seed(seed);
00374 #else
00375         set_seed(seed);
00376 #endif /* OLD_RNG */
00377 
00378         // Toss away the first few values of heuristic seed.
00379         // In practice this makes sequential heuristic seeds
00380         // generate different first values.
00381         //
00382         // How many values to throw away should be the subject
00383         // of careful analysis.  Until then, I just throw away
00384         // ``a bunch''.  --johnh
00385         if (source == HEURISTIC_SEED_SOURCE) {
00386                 int i;
00387                 for (i = 0; i < 128; i++) {
00388 #ifdef OLD_RNG                  
00389                         stream_.next();
00390 #else
00391                         next();
00392 #endif /* OLD_RNG */
00393                 };
00394         };
00395 }

Here is the call graph for this function:

void RNG::set_seed long  seed  ) 
 

Definition at line 774 of file rng.cc.

References HEURISTIC_SEED_SOURCE, init(), and set_package_seed().

Referenced by Shadowing::command(), command(), main(), RNG(), Random::seed(), Random::seed_heuristically(), set_seed(), and Shadowing::Shadowing().

00775 {
00776         if (seed == 0) {
00777                 set_seed (HEURISTIC_SEED_SOURCE, seed);
00778         }
00779         else {
00780                 unsigned long seed_vec[6] = {0, 0, 0, 0, 0, 0};
00781                 for (int i=0; i<6; i++) {
00782                         seed_vec[i] = (unsigned long) seed;
00783                 }
00784                 set_package_seed (seed_vec);
00785                 init();
00786         }
00787 }

Here is the call graph for this function:

double RNG::U01  )  [protected]
 

Definition at line 696 of file rng.cc.

References a12, a13n, a21, a23n, anti_, Cg_, m1, m2, norm, p1, and p2.

Referenced by rand_u01(), and U01d().

00697 { 
00698         long k; 
00699         double p1, p2, u; 
00700         /* Component 1 */ 
00701         p1 = a12 * Cg_[1] - a13n * Cg_[0]; 
00702         k = static_cast<long> (p1 / m1); 
00703         p1 -= k * m1; 
00704         if (p1 < 0.0) p1 += m1; 
00705         Cg_[0] = Cg_[1]; Cg_[1] = Cg_[2]; Cg_[2] = p1; 
00706         /* Component 2 */ 
00707         p2 = a21 * Cg_[5] - a23n * Cg_[3]; 
00708         k = static_cast<long> (p2 / m2); 
00709         p2 -= k * m2; 
00710         if (p2 < 0.0) p2 += m2; 
00711         Cg_[3] = Cg_[4]; Cg_[4] = Cg_[5]; Cg_[5] = p2; 
00712         /* Combination */ 
00713         u = ((p1 > p2) ? (p1 - p2) * norm : (p1 - p2 + m1) * norm); 
00714         return (anti_ == false) ? u : (1 - u); 
00715 } 

double RNG::U01d  )  [protected]
 

Definition at line 720 of file rng.cc.

References anti_, fact, and U01().

Referenced by rand_u01().

00721 { 
00722         double u; 
00723         u = U01(); 
00724         if (anti_) { 
00725                 // Don't forget that U01() returns 1 - u in 
00726                 // the antithetic case 
00727                 u += (U01() - 1.0) * fact; 
00728                 return (u < 0.0) ? u + 1.0 : u; 
00729         } else { 
00730                 u += U01() * fact; 
00731                 return (u < 1.0) ? u : (u - 1.0); 
00732         } 
00733 } 

Here is the call graph for this function:

double RNG::uniform double  a,
double  b
[inline]
 

Definition at line 267 of file rng.h.

References uniform().

00268         { return (a + uniform(b - a)); }

Here is the call graph for this function:

double RNG::uniform double  r  )  [inline]
 

Definition at line 265 of file rng.h.

References uniform().

00266         { return (r * uniform());}

Here is the call graph for this function:

int RNG::uniform int  k  )  [inline]
 

Definition at line 263 of file rng.h.

References uniform_positive_int().

00264         { return (uniform_positive_int() % (unsigned)k); }

Here is the call graph for this function:

double RNG::uniform  )  [inline]
 

Definition at line 260 of file rng.h.

References uniform_double().

Referenced by command(), tags_database::create_tags_database(), exponential(), tags_database::get_random_tag(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), Random::integer(), LandmarkAgent::LandmarkAgent(), LandmarkAgent::MoveTags(), normal(), pareto(), paretoII(), LandmarkAgent::random_timer(), uniform(), Random::uniform(), RA_Traffic::value(), EmpiricalRandomVariable::value(), and UniformRandomVariable::value().

00260 {return uniform_double();}

Here is the call graph for this function:

double RNG::uniform_double  )  [inline]
 

Definition at line 249 of file rng.h.

References next_double().

Referenced by uniform(), Random::uniform(), and uniform().

00249                                        { // range [0.0, 1.0)
00250 #ifdef OLD_RNG
00251                 return stream_.next_double();
00252 #else
00253                 return next_double();
00254 #endif /* OLD_RNG */
00255         }

Here is the call graph for this function:

int RNG::uniform_positive_int  )  [inline]
 

Definition at line 242 of file rng.h.

References next().

Referenced by command(), random(), Random::random(), and uniform().

00242                                           {  // range [0, MAXINT]
00243 #ifdef OLD_RNG
00244                 return (int)(stream_.next());
00245 #else
00246                 return (int)(next());
00247 #endif /* OLD_RNG */
00248         }

Here is the call graph for this function:

void RNG::write_state  )  const
 

Definition at line 917 of file rng.cc.

References Cg_, and name_.

00918 { 
00919         printf ("The current state of the Rngstream %s:\n", name_);
00920         printf (" Cg_ = { ");
00921         for(int i=0;i<5;i++) { 
00922                 printf ("%lu, ", (unsigned long) Cg_[i]);
00923         } 
00924         printf ("%lu }\n\n", (unsigned long) Cg_[5]);
00925 } 

void RNG::write_state_full  )  const
 

Definition at line 928 of file rng.cc.

References anti_, Bg_, Cg_, Ig_, inc_prec_, and name_.

00929 { 
00930         int i; 
00931         printf ("The RNG %s:\n", name_);
00932         printf (" anti_ = %s", (anti_ ? "true" : "false")); 
00933         printf (" inc_prec_ = %s\n", (inc_prec_ ? "true" : "false")); 
00934 
00935         printf (" Ig_ = { ");
00936         for (i = 0; i < 5; i++) { 
00937                 printf ("%lu, ", (unsigned long) Ig_[i]);
00938         } 
00939         printf ("%lu }\n", (unsigned long) Ig_[5]);
00940 
00941         printf (" Bg_ = { ");
00942         for (i = 0; i < 5; i++) { 
00943                 printf ("%lu, ", (unsigned long) Bg_[i]);
00944         } 
00945         printf ("%lu }\n", (unsigned long) Bg_[5]);
00946 
00947         printf (" Cg_ = { ");
00948         for (i = 0; i < 5; i++) { 
00949                 printf ("%lu, ", (unsigned long) Cg_[i]);
00950         } 
00951         printf ("%lu }\n\n", (unsigned long) Cg_[5]);
00952 } 


Member Data Documentation

bool RNG::anti_ [protected]
 

Definition at line 300 of file rng.h.

Referenced by init(), set_antithetic(), U01(), U01d(), and write_state_full().

double RNG::Bg_[6] [protected]
 

Definition at line 294 of file rng.h.

Referenced by init(), reset_next_substream(), reset_start_stream(), reset_start_substream(), set_seed(), and write_state_full().

double RNG::Cg_[6] [protected]
 

Definition at line 294 of file rng.h.

Referenced by advance_state(), get_state(), init(), reset_next_substream(), reset_start_stream(), reset_start_substream(), set_seed(), U01(), write_state(), and write_state_full().

RNG * RNG::default_ = NULL [static, protected]
 

Definition at line 189 of file rng.cc.

Referenced by command(), and defaultrng().

double RNG::Ig_[6] [protected]
 

Definition at line 294 of file rng.h.

Referenced by init(), reset_start_stream(), set_seed(), and write_state_full().

bool RNG::inc_prec_ [protected]
 

Definition at line 300 of file rng.h.

Referenced by increased_precis(), init(), rand_u01(), and write_state_full().

char RNG::name_[100] [protected]
 

Definition at line 306 of file rng.h.

Referenced by RNG(), write_state(), and write_state_full().

double RNG::next_seed_ [static, protected]
 

Initial value:

 
{ 
        12345.0, 12345.0, 12345.0, 12345.0, 12345.0, 12345.0 
}

Definition at line 810 of file rng.cc.

Referenced by init(), and set_package_seed().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:16:27 2004 for NS2.26SourcesOriginal by doxygen 1.3.3