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

Function boxMullerTransform

src/backend/cuda/kernel/random_engine.hpp:264–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262
263template<typename Td, typename Tc>
264__device__ static void boxMullerTransform(Td *const out1, Td *const out2,
265 const Tc &r1, const Tc &r2) {
266 /*
267 * The log of a real value x where 0 < x < 1 is negative.
268 */
269 Tc r = sqrt(neg_two<Tc>() * log(r2));
270 Tc s, c;
271
272 // Multiplying by PI instead of 2*PI seems to yeild a better distribution
273 // even though the original boxMuller algorithm calls for 2 * PI
274 // sincos(two_pi<Tc>() * r1, &s, &c);
275 sincospi(r1, &s, &c);
276 *out1 = static_cast<Td>(r * s);
277 *out2 = static_cast<Td>(r * c);
278}
279#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 530
280template<>
281__device__ void boxMullerTransform<common::half, __half>(

Callers 3

half, __half>Method · 0.70

Calls 3

sqrtFunction · 0.85
logFunction · 0.85
sincospiFunction · 0.70

Tested by

no test coverage detected