12 #ifndef __RD_UTILS_H__ 13 #define __RD_UTILS_H__ 18 #include <boost/random.hpp> 55 PRECONDITION(ref.size() == probe.size(),
"size mismatch");
56 typename T::const_iterator refIt = ref.begin();
57 typename T::iterator probeIt = probe.begin();
58 typename T::iterator probeIt2;
60 unsigned int nSwaps = 0;
61 while (refIt != ref.end()) {
62 if ((*probeIt) != (*refIt)) {
65 while ((*probeIt2) != (*refIt) && probeIt2 != probe.end()) {
68 if (probeIt2 != probe.end()) {
73 std::swap(*probeIt, *probeIt2);
86 double half =
int_pow<n / 2>(x);
90 return half * half * x;
RDKIT_RDGENERAL_EXPORT double getRandomVal(int seed=-1)
boost::minstd_rand rng_type
#define RDKIT_RDGENERAL_EXPORT
int firstThousandPrimes[NUM_PRIMES_AVAIL]
#define CHECK_INVARIANT(expr, mess)
RDKIT_RDGENERAL_EXPORT rng_type & getRandomGenerator(int seed=-1)
Optionally seed and return a reference to the global (Boost) random.
const int NUM_PRIMES_AVAIL
the number of primes available and stored
double int_pow< 0 >(double)
std::vector< int > INT_VECT
boost::uniform_real uniform_double
double int_pow< 1 >(double x)
RDKIT_RDGENERAL_EXPORT bool feq(double v1, double v2, double tol=1e-4)
floating point comparison with a tolerance
const int FILE_MAXLINE
an assumed maximum length for lines read from files
#define PRECONDITION(expr, mess)
boost::variate_generator< rng_type &, uniform_double > double_source_type
boost::variate_generator< rng_type &, uniform_int > int_source_type
RDKIT_RDGENERAL_EXPORT double computeIntVectPrimesProduct(const INT_VECT &ring)
compute the product of the set of primes corresponding to the values in an INT_VECT ...
unsigned int countSwapsToInterconvert(const T &ref, T probe)
boost::uniform_int uniform_int
RDKIT_RDGENERAL_EXPORT double_source_type & getDoubleRandomSource()
return a reference to the global (Boost) random source