MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / boxMullerTransform

Function boxMullerTransform

src/backend/oneapi/kernel/random_engine_write.hpp:118–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116//
117template<typename Tc>
118static void boxMullerTransform(cfloat *const cOut, const Tc &r1, const Tc &r2) {
119 /*
120 * The log of a real value x where 0 < x < 1 is negative.
121 */
122 Tc r = sycl::sqrt(neg_two<Tc>() * sycl::log(r2));
123 Tc s, c;
124
125 // Multiplying by PI instead of 2*PI seems to yeild a better distribution
126 // even though the original boxMuller algorithm calls for 2 * PI
127 // sincos(two_pi<Tc>() * r1, &s, &c);
128 sincospi(r1, &s, &c);
129 cOut->real(static_cast<float>(r * s));
130 cOut->imag(static_cast<float>(r * c));
131}
132
133template<typename Tc>
134static void boxMullerTransform(cdouble *const cOut, const Tc &r1,

Callers 2

Calls 3

sqrtFunction · 0.85
logFunction · 0.85
sincospiFunction · 0.70

Tested by

no test coverage detected