Thanks for your reply, it is good news that things are getting faster. I was just looking again at the code and noticed that the first END statement is not ending the ELSE block of the IF (as the indentation suggests) but ending the loop over 't'. In other words the results are always for t=MaxAge.
When age_x and age_j are both equal to MaxAge, I believe that Djxx will contain upto 126 copies of the same 126x126 matrix all stacked on top of each other.
As Rick suggests it may be worthwhile checking that things work as intended for a few specific values. Use a tiny data set and print out all the intermediate workings.
... View more