| 262 | |
| 263 | template<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 |
| 280 | template<> |
| 281 | __device__ void boxMullerTransform<common::half, __half>( |
no test coverage detected