SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWRandGenR250 Class Reference

Generates random numbers uniformly distributed over the interval [0, 1]. More...

#include <rw/randr250.h>

Public Member Functions

 RWRandGenR250 ()
 
 RWRandGenR250 (const RWRandGenR250 &u)
 
 RWRandGenR250 (unsigned long seed)
 
double operator() ()
 
RWRandGenR250operator= (const RWRandGenR250 &u)
 
void printOn (std::ostream &s) const
 
void restart ()
 
void restart (unsigned long seed)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
 
void scanFrom (std::istream &s)
 
unsigned long seed () const
 

Friends

bool operator== (const RWRandGenR250 &lhs, const RWRandGenR250 &rhs)
 

Related Symbols

(Note that these are not member symbols.)

bool operator!= (const RWRandGenR250 &lhs, const RWRandGenR250 &rhs)
 
std::ostream & operator<< (std::ostream &s, const RWRandGenR250 &gen)
 
std::istream & operator>> (std::istream &s, RWRandGenR250 &gen)
 

Detailed Description

Class RWRandGenR250 generates random numbers uniformly distributed over the interval [0, 1], and may be used instead of class RWRandGenerator as a template parameter to any of the distribution generators derived from abstract base class RWTRand. RWRandGenR250 is a generalized feedback shift register generator.

Unlike class RWRandGenerator, each instance of RWRandGenR250 contains and maintains its own, independent state. This can make it easier to use in some situations. The "internal state" of an instance of RWRandGenR250 consists of a seed, an array of unsigned longs known as the "state vector" and an integer index into that state vector. (S. Kirkpatrick and E. Stoll, Journal of Computational Physics, 40, p. 517 (1981).

Synopsis
#include <rw/randr250.h>
Generates random numbers uniformly distributed over the interval [0, 1].
Definition randr250.h:66

Constructor & Destructor Documentation

◆ RWRandGenR250() [1/3]

RWRandGenR250::RWRandGenR250 ( )

Constructs a generator, arbitrarily seeded by a call to the time() function.

◆ RWRandGenR250() [2/3]

RWRandGenR250::RWRandGenR250 ( unsigned long seed)
explicit

Constructs a generator with a specified seed.

◆ RWRandGenR250() [3/3]

RWRandGenR250::RWRandGenR250 ( const RWRandGenR250 & u)

Constructs a copy of u. The copy's state will equal the state of u at the time the copy is created, but will not share the state of u.

Member Function Documentation

◆ operator()()

double RWRandGenR250::operator() ( )

Returns a random double in [0,1].

◆ operator=()

RWRandGenR250 & RWRandGenR250::operator= ( const RWRandGenR250 & u)

Sets an instance of RWRandGenR250 equal to the state of instance u.

◆ printOn()

void RWRandGenR250::printOn ( std::ostream & s) const

Outputs a summary of self's internal state on ostream s.

◆ restart() [1/2]

void RWRandGenR250::restart ( )

Restarts the generator, arbitrarily seeding it by a call to the time() function.

◆ restart() [2/2]

void RWRandGenR250::restart ( unsigned long seed)

Restarts the generator with specified seed.

◆ restoreFrom() [1/2]

void RWRandGenR250::restoreFrom ( RWFile & )

Restores internal state of self from an RWFile.

◆ restoreFrom() [2/2]

void RWRandGenR250::restoreFrom ( RWvistream & )

Restores internal state of self from a virtual stream.

◆ saveOn() [1/2]

void RWRandGenR250::saveOn ( RWFile & ) const

Stores internal state of self in a binary format to an RWFile.

◆ saveOn() [2/2]

void RWRandGenR250::saveOn ( RWvostream & ) const

Stores internal state of self to a virtual stream.

◆ scanFrom()

void RWRandGenR250::scanFrom ( std::istream & s)

Inputs an internal state from istream s to self.

◆ seed()

unsigned long RWRandGenR250::seed ( ) const

Returns the seed used to initialize the generator.

Friends And Related Symbol Documentation

◆ operator!=()

bool operator!= ( const RWRandGenR250 & lhs,
const RWRandGenR250 & rhs )
related

Returns the negation of operator==().

◆ operator<<()

std::ostream & operator<< ( std::ostream & s,
const RWRandGenR250 & gen )
related

Outputs a summary of gen's internal state on ostream s.

◆ operator==

bool operator== ( const RWRandGenR250 & lhs,
const RWRandGenR250 & rhs )
friend

Returns true if lhs generator is equal to rhs generator. Two distinct instances of RWRandGenR250 are equal if they will return identical sequences of values.

◆ operator>>()

std::istream & operator>> ( std::istream & s,
RWRandGenR250 & gen )
related

Inputs an internal state from istream s to gen.

Copyright © 2025 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.