-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoverdensity_calc.c
68 lines (51 loc) · 1.78 KB
/
overdensity_calc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
int boxCoordinates(double xCoor[], double yCoor[], double zCoor[], int rowNumber){
xlabel = (int) trunc((xCoor[rowNumber] - AxisLimsArray[0][2])/xCellSize);
ylabel = (int) trunc((yCoor[rowNumber] - AxisLimsArray[0][1])/yCellSize);
zlabel = (int) trunc((zCoor[rowNumber] - AxisLimsArray[0][0])/zCellSize);
boxlabel = (int) xlabel + n2*ylabel + n2*n1*zlabel;
return boxlabel;
}
int calc_overdensity(int max_gals){
walltime("Wall time at start of overdensity calc.");
for(j=0; j<n0*n1*n2; j++) overdensity[j] = -1.0;
/*
for(j=0; j<n0*n1*n2; j++){
overdensity[j][0] = 0.0;
overdensity[j][1] = 0.0;
}
*/
for(j=0; j<max_gals; j++){
//if(Acceptanceflag[j] == true){
ngp_assign(xCoor[j], yCoor[j], zCoor[j], 1. / (double) max_gals); // (fkp_galweight[j]/sqrt(alpha))*clip_galweight[j]/sampling[j])
// cic assign, weighted by sampling, fkp wghts and clipping.
// cic_assign(xCoor[j], yCoor[j], zCoor[j], 1. / (double) max_gals); // (fkp_galweight[j]/sqrt(alpha))*clip_galweight[j]/sampling[j])
//}
}
/*
for(j=0; j<rand_number; j++){
// ngp_assign(rand_x[j], rand_y[j], rand_z[j], -sqrt(alpha)*rand_weight[j]);
cic_assign(rand_x[j], rand_y[j], rand_z[j], -sqrt(alpha)*rand_weight[j]); // assumes all randoms up to rand_number are accepted.
}
*/
walltime("Wall time after overdensity calc.");
return 0;
}
static int rand_int(int n){
int limit = RAND_MAX - RAND_MAX % n;
int rnd;
do{
rnd = rand();
}
while (rnd >= limit);
return rnd % n;
}
void shuffle(double *array, int n){
int i, j;
double tmp;
for(i = n - 1; i > 0; i--){
j = rand_int(i + 1);
tmp = array[j];
array[j] = array[i];
array[i] = tmp;
}
}