OBRandom Class Reference

Random number generator. More...

#include <openbabel/rand.h>

List of all members.

Public Member Functions

 OBRandom (bool useSys=false)
void Seed (int seed)
void TimeSeed ()
int NextInt ()
double NextFloat ()

Detailed Description

Random number generator.

The OBRandom class can be used to facilitate cross-platform random number generation. The class can be set to specific seed states, or set to use the current time or other arbitrary data as a seed.

     OBRandom generator; // Don't use system rand() functions
     generator.TimeSeed(); // initialize from the current time

     cerr << " New Random Integer " << generator.NextInt() << endl;
     cerr << " New Random Floating-Point " << generator.NextFloat() << endl;

Alternatively, OBRandom can be used as an interface to the system random number generator.

     OBRandom generator(true); // Use system rand() functions
     generator.Seed(10246);// Use a specific initial seed value for reproducing sequence

Constructor & Destructor Documentation

OBRandom ( bool  useSys = false )

Constructor. useSys will use the system rand() function.


Member Function Documentation

void Seed ( int  seed ) [inline]

Use seed for the random number generator seed.

void TimeSeed (  )

Use the current time for the random number generator seed If sranddev is available (e.g., Mac OS X, BSD...) use this instead for more random seeds

Referenced by OBForceField::GenerateVelocities(), OBForceField::RandomRotorSearchInitialize(), vector3::randomUnitVector(), OBConformerSearch::Setup(), and OBForceField::WeightedRotorSearch().

int NextInt (  )
Returns:
a random integer

Referenced by OBForceField::RandomRotorSearchInitialize(), and OBConformerSearch::Setup().

double NextFloat (  )
Returns:
a random floating-point number between 0.0 and 1.0

Referenced by OBForceField::GenerateVelocities(), matrix3x3::randomRotation(), vector3::randomUnitVector(), and OBForceField::WeightedRotorSearch().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines