int main(void) { float bounds[6]; float particle[3] = {0, 4, 0}; int64_t in_bounds = 0; float newpos[3]; float a[3], b[3]; int64_t i; BOX_SIZE=1; PERIODIC=1; sscanf("-1 -1 -1 2 2 2", "%f %f %f %f %f %f", bounds, bounds+1, bounds+2, bounds+3, bounds+4, bounds+5); for (i=0; i<1073741824*0.2; i++) { in_bounds+=_check_bounds(particle, newpos, bounds); particle[0]+=1e-9; } printf("Total: %"PRId64"\n", in_bounds); return 0; }
double RL_MultiTable::read(const vector<int> & idx) { assert(_check_bounds(idx)); return data[idx]; }
double & RL_MultiTable::operator()(const vector<int> & idx) { assert(_check_bounds(idx)); return data[idx]; }
void load_prev_binary_halos(int64_t snap, int64_t chunk, float *bounds, int64_t our_chunk) { FILE *input; char buffer[1024]; struct binary_output_header bh; struct halo h; int64_t remaining = 0, to_read, i,j, h_start = num_prev_halos; double v_to_dx; get_output_filename(buffer, 1024, snap, chunk, "bin"); input = check_fopen(buffer, "rb"); check_fread(&bh, sizeof(struct binary_output_header), 1, input); assert(bh.magic == ROCKSTAR_MAGIC); assert(bh.num_halos >= 0); assert(bh.num_particles >= 0); //Conversion in Comoving Mpc/h / (km/s) //Note that the time units are in 1/H = 1/(h*100 km/s/Mpc) v_to_dx = 0.01*(scale_to_time(SCALE_NOW) - scale_to_time(bh.scale)) / (0.5*(SCALE_NOW + bh.scale)); remaining = bh.num_halos; while (remaining > 0) { to_read = PREV_HALO_BUFFER_SIZE; if (to_read > remaining) to_read = remaining; check_fread(prev_halo_buffer, sizeof(struct halo), to_read, input); remaining -= to_read; for (i=0; i<to_read; i++) { for (j=0; j<3; j++) prev_halo_buffer[i].pos[j] += v_to_dx*prev_halo_buffer[i].pos[j+3]; h = prev_halo_buffer[i]; if (!bounds || _check_bounds(prev_halo_buffer[i].pos, h.pos, bounds) || our_chunk == chunk) add_to_previous_halos(&h, &bh); } } if (chunk == our_chunk) { hid_cache = check_realloc(hid_cache, sizeof(int64_t)*bh.num_particles, "Allocating halo id cache"); check_fread(hid_cache, sizeof(int64_t), bh.num_particles, input); for (i=h_start; i<num_prev_halos; i++) ph[i].file_offset = -1; } fclose(input); }