101 const T
d = (a < 1. ? 1.+a : a) - 1./3.;
102 const T c = 1./std::sqrt (9.*
d);
105 if (a <= 0 || math::isinf (a))
107 for (i=0; i < n; i++)
108 r[i] = numeric_limits<T>::NaN ();
112 for (i=0; i < n; i++)
116 x = rand_normal<T> ();
121 u = rand_uniform<T> ();
123 if (u >= 1.-0.0331*xsq*xsq && std::log (u) >= 0.5*xsq +
d*(1-v+std::log (v)))
131 for (i = 0; i < n; i++)
132 r[i] *= exp (-rand_exponential<T> () / a);