Loading...
Searching...
No Matches
OBRandom Class Reference

`#include <openbabel/rand.h>`

## 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;
OpenBabel::OBRandom::NextInt
int NextInt()
Definition rand.cpp:466
OpenBabel::OBRandom::TimeSeed
void TimeSeed()
Definition rand.cpp:501
OpenBabel::OBRandom::OBRandom
OBRandom(bool useSys=false)
Constructor. useSys will use the system rand() function.
Definition rand.cpp:454
OpenBabel::OBRandom::NextFloat
double NextFloat()
Definition rand.cpp:483

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
OpenBabel::OBRandom::Seed
void Seed(int seed)
Use seed for the random number generator seed.
Definition rand.h:78

## Constructor & Destructor Documentation

## OBRandom()

OBRandom | ( | bool | useSys = false | ) |

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

## Member Function Documentation

## Seed()

void Seed | ( | int | seed | ) |

inline

Use `seed` for the random number generator seed.

## TimeSeed()

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(), OBConformerSearch::OBConformerSearch(), OBRandom(), OBForceField::RandomRotorSearchInitialize(), OBConformerSearch::Setup(), and OBForceField::WeightedRotorSearch().

## NextInt()

int NextInt | ( |  | ) |

Returns
  a random integer

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

## NextFloat()

double NextFloat | ( |  | ) |

Returns
  a random floating-point number between 0.0 and 1.0

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

The documentation for this class was generated from the following files:

- rand.h
- rand.cpp