51#define NDIV (1 + IMM1 / NTAB)
53#define RNMX (1.0 - EPS)
56template <
class T> T
ran2(
long *idum)
67 static long idum2 = 123456789;
83 for (j =
NTAB + 7; j >= 0; j--)
86 *idum =
IA1 * (*idum - k *
IQ1) - k *
IR1;
100 *idum =
IA1 * (*idum - k *
IQ1) - k *
IR1;
107 idum2 =
IA2 * (idum2 - k *
IQ2) - k *
IR2;
121 if ((temp =
AM * iy) >
RNMX)
146#ifdef NEKTAR_USE_THREAD_SAFETY
147static std::mutex mutex;
156#ifdef NEKTAR_USE_THREAD_SAFETY
158 std::scoped_lock l(mutex);
164 static long seed = 0;
169 seed = long(outseed);
180 v1 = 2.0 * ran2<T>(&seed) - 1.0;
181 v2 = 2.0 * ran2<T>(&seed) - 1.0;
182 rsq = v1 * v1 + v2 * v2;
183 }
while (rsq >= 1.0 || rsq == 0.0);
184 fac =
sqrt(-2.0 *
log(rsq) / rsq);
200 const int incx,
int outseed);
204 const int incx,
int outseed);
#define LIB_UTILITIES_EXPORT
T ran2(long *idum)
Generates a number from ~Normal(0,1)
void FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
scalarT< T > log(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)