in reply to Efficiency of implementation

I am unsure whether it will take more time to save 0.5 *4^7 *4^7 entries to RAM so that I only calculate once, or whether it would be better to calculate each element twice inside the double loop.
Judging from your code, it may be the latter. But that's more a guess than anything else. Which one is faster for you is only something you can determine. Try both methods, see which one is faster. It's impossible for us to determine how fast you can claim memory on your OS/hardware, and how your box is going to behave if you're going to use a lot of memory.

Replies are listed 'Best First'.
Re^2: Efficiency of implementation
by azheid (Sexton) on Jan 31, 2012 at 19:37 UTC

    Thanks for the reply. I will only have to do this a handful of times, so I am really looking for an expert best guess.

      So, does your code run now? If it runs within whatever time constraint that you have (and it sounds like even overnight is "fast enough"), why bother with more optimization? I mean if it takes you a day or two of work and the program would have already finished by then, its not a good use of your time. However a 2D array would probably be better that a 2D Hash.

      Update: Is there a way to provide a small, runnable data set? Even a 20x20 matrix or whatever? Ie. some data set that is small enough to post here?