7 #ifndef SPECTRA_SIMPLE_RANDOM_H
8 #define SPECTRA_SIMPLE_RANDOM_H
30 inline long next_long_rand(
long seed)
32 constexpr
unsigned int m_a = 16807;
33 constexpr
unsigned long m_max = 2147483647
L;
37 lo = m_a * (long) (seed & 0xFFFF);
38 hi = m_a * (long) ((
unsigned long) seed >> 16);
39 lo += (hi & 0x7FFF) << 16;
56 template <
typename Scalar>
61 constexpr
unsigned long m_max = 2147483647
L;
63 seed = next_long_rand(seed);
68 template <
typename RealScalar>
71 static std::complex<RealScalar>
run(
long& seed)
75 return std::complex<RealScalar>(r,
i);
80 template <
typename Scalar =
double>
92 SimpleRandom(
unsigned long init_seed)
94 constexpr
unsigned long m_max = 2147483647
L;
95 m_rand = init_seed ? (init_seed & m_max) : 1;
106 void random_vec(
Vector& vec)
129 #endif // SPECTRA_SIMPLE_RANDOM_H