100 const T
d = (a < 1. ? 1.+a : a) - 1./3.;
101 const T c = 1./std::sqrt (9.*
d);
104 if (a <= 0 || math::isinf (a))
106 for (i=0; i < n; i++)
107 r[i] = numeric_limits<T>::NaN ();
111 for (i=0; i < n; i++)
115 x = rand_normal<T> ();
120 u = rand_uniform<T> ();
122 if (u >= 1.-0.0331*xsq*xsq && std::log (u) >= 0.5*xsq +
d*(1-v+std::log (v)))
130 for (i = 0; i < n; i++)
131 r[i] *= exp (-rand_exponential<T> () / a);