I just noticed that both calcStepGrad and calcStepRest make deep (recursive) copies of the running solution every single time they try a new step. This includes copying also all the histories of previous gradient steps, P, P-int, P-psi, I, I-pf, J, etc...
Doing this wastes both time and memory! Let's work out a way to avoid making such huge copies every time!
I just noticed that both calcStepGrad and calcStepRest make deep (recursive) copies of the running solution every single time they try a new step. This includes copying also all the histories of previous gradient steps, P, P-int, P-psi, I, I-pf, J, etc...
Doing this wastes both time and memory! Let's work out a way to avoid making such huge copies every time!