RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
Rand.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// Wrapper around Randint class
14// Function provided to return reference to single instance (singleton) of
15// Rand
16
17#ifndef _RBTRAND_H_
18#define _RBTRAND_H_
19
20// Use standard C++11 RNG on Solaris and Windows/MSVC due to PCG build failure
21// Solaris issue: https://github.com/imneme/pcg-cpp/issues/42
22// Windows/MSVC issue: https://github.com/imneme/pcg-cpp/issues/11
23#if !defined(__sun) && !(defined(_WIN32) && defined(_MSC_VER))
24#include <pcg_random.hpp>
25#endif
26#include <random>
27
28#include "rxdock/Coord.h"
29
30namespace rxdock {
31
32class Rand {
34 // Constructor
35public:
36 Rand();
38 // Destructor
39 ~Rand();
40
42 // Public methods
43
44 // Seed the random number generator
45 RBTDLL_EXPORT void Seed(int seed = 0);
46 // Seed the random number generator from the random device
47 void SeedFromRandomDevice();
48 // Returns current seed
49 RBTDLL_EXPORT int GetSeed();
50 // Get a random double between 0 and 1
51 RBTDLL_EXPORT double GetRandom01();
52 // Get a random integer between 0 and nMax-1
53 int GetRandomInt(int nMax);
54 // Get a random unit vector distributed evenly over the surface of a sphere
55 Vector GetRandomUnitVector();
56 double GetGaussianRandom(double, double);
57 double GetCauchyRandom(double, double);
58
59private:
60#if defined(__sun) || (defined(_WIN32) && defined(_MSC_VER))
61 std::default_random_engine m_rng;
62#else
63 pcg32 m_rng; // Random number generator
64#endif
65};
66
68// Non-member functions in rxdock namespace
69
70// Returns reference to single instance of Rand class (singleton)
71RBTDLL_EXPORT Rand &GetRandInstance();
72
73} // namespace rxdock
74
75#endif //_RBTRAND_H_
Definition Coord.h:45
Definition Rand.h:32