Previously I just had max_translate set as a constant double and the program worked fine. However, I am now wanting to calculate a new value of max_translate depending on a ratio of successful to rejected moves elsewhere in the program:
1 2 3 4 5 6 7 8 9
double ratio = (naccept/(naccept+nreject));
However, just by adding this simple bit of code, the program has moved from being extremely quick to a virtual stand still.
Well, with the amount of detail you've given us, it's hard to tell. I imagine the cost of fetching max_translate from memory vs. getting it inside the floating point instruction is piling up.
Another possibility is that your previous version used exactly as many floating point registers as your CPU has, but now the program has to swap values in and out of memory. I've seen a function drop in performance by a factor of 4, I think, after adding one bitwise operation on one more variable.