I have two problems, first the below code is quitting randomly because of a memory or uninitialized place error, I just can't see it. second, I'm not sure that the algorithm is correct. (The algorithm is suppose to simulate the Hanbury Brown Twiss photonics experiment for anyone who cares)
The vectors are made up of linearly increasing time stamps, where the stop signal is delayed by 180 seconds, if the i_th start signal is less than the i_th stop signal, the timer starts, ignoring all start signals until the timer meets a stop signal, and vica versa, if the timer is stopped, all stops should be ignored until a start is registered. The code should then bucket sort the time difference between these start/stops.
-If there is a name for this kind of sort please post it below.
The below code takes these filled vectors and tries to simulate this process. but I cant figure out what wrong with the memory issues before I get back to fixing the algorithm.
this is the code I have that doesn't work all the time, it works for start/stop vectors smaller than 10,000 double, but I need it to iterate through up to 100,000 doubles.
while( starts.size() > 5 && stops.size() > 5 ){
if( start.at(0) >= stop.at(0) ){
thisStart = starts.at(0);
}
j=0;
while( stops.at(j) <= starts.at(0) ){
j++;
}
stops.erase(stops.begin(), stops.begin() + j + 1 );
thisStop = stops.at(0);
j=0;
while( starts.at(j) <= thisStop){
j++;
}
starts.erase(starts.begin(), starts.begin() + j+1 );
bucketSort(thisStop - thisStart, bins, &counts);
}