Created
December 22, 2017 18:49
-
-
Save goldsborough/75ee1802110eda71517cc33ea3c59a88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const float two_pi = 2.0f * 3.14159265358979323846f; | |
for (int i = 0; i < kNumber; i += 16) { | |
for (int j = 0; j < 8; ++j) { | |
const float u1 = 1 - uniform[i + j]; | |
const float u2 = uniform[i + 8 + j]; | |
const float radius = std::sqrt(-2 * std::log(u1)); | |
const float theta = two_pi * u2; | |
output[i + j] = radius * std::cos(theta); | |
output[i + 8 + j] = radius * std::sin(theta); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment