Skip to content

Commit

Permalink
turn off debugging in RNG
Browse files Browse the repository at this point in the history
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1307 6778bc44-b910-0410-a7a0-be141de4315d
  • Loading branch information
w1z7ard committed Dec 1, 2009
1 parent 2a2fde2 commit f40217d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libprojectM/RandomNumberGenerators.hpp
Expand Up @@ -5,6 +5,8 @@
#include <cassert>
#include <iostream>

#define WEIGHTED_RANDOM_DEBUG 0

namespace RandomNumberGenerators {

inline float uniform()
Expand Down Expand Up @@ -96,15 +98,17 @@ inline std::size_t weightedRandom(const std::vector<int> & weights, unsigned int

const int sampledSum = uniformInteger(weightTotalHint);
int sum = 0;
std::cout << "[RNG::weightedRandom()] weightTotal = " << weightTotalHint <<
if (WEIGHTED_RANDOM_DEBUG) std::cout << "[RNG::weightedRandom()] weightTotal = " << weightTotalHint <<
std::endl;

for (std::size_t i = 0; i < weights.size();i++) {
if (WEIGHTED_RANDOM_DEBUG)
std::cout << "[RNG::weightedRandom()] weight[" << i << "] = " << weights[i] <<
std::endl;

sum += weights[i];
if (sampledSum <= sum) {
if (WEIGHTED_RANDOM_DEBUG)
std::cout << "[RNG::weightedRandom()] sampled index " << i << "(" <<
"running sum = " << sum << ", sampled sum = " << sampledSum << std::endl;
return i;
Expand Down

0 comments on commit f40217d

Please sign in to comment.