Why does the address &ra[0] keep changing?
Thanks.Code:
void overlappingPermutations(Distribution& D, int* ra) {
// overlappingPermutations
//
// Take five consecutively-generated RNs at a time and
// determine their order. There are 5P5 = 120 different
// orderings.
//
//
// Example:
//
//
//
//
// Expected distribution: Flat
//
// Complexity: O(N)
vector<int> pattern(120);
int is[5] = {0};
while(ra) {
int i = 0;
while(i < 5){
is[i++] = *ra++;
}
if(ra - &ra[0] == 0) cout << "bang!\n"; // Always written!
rankPermutations(pattern, is, 5);
}
// Rest of implementation comes later
}
// ...
int main(void) {
Distribution* D = new Distribution[12];
bool running = true;
int* ra;
try {
ra = new int[10000000];
} catch (bad_alloc) {
cout << "Memory allocation failed\n";
return 127;
}
long int count = 0;
seedRNG();
while(running) {
ra[count++] = rand();
if(count % 1000000 == 0) cout << count << " values so far.\n";
if(count == 10000000) running = false;
}
diehard(ra); // Diehard just calls functions like `overlappingPermutations',
// which all have the same prototype.
}