Lines 69-110 adjust a2primeIndexesPath and a2primeProbsPath to include the upper index and upper prob respectively. This changes the shape from [N_a,N_ze,N_j-1,1,T-1] (with z and/or e) to [N_a,N_ze,N_j-1,2,T-1], which is then further reshaped to [N_a*(N_j-1)*N_ze,2,T-1]. So far, so good. The code without z and e is similar in spirit (slightly different in shape) all that follows applies to it in its respective shape as well.
Later (following the z and/or e case) we create:
elseif N_probs>1 % for a reason other than gridinterplayer
PolicyaprimejzPath=reshape(PolicyaprimejzPath,[N_a*(N_j-1)*N_z,1,T-1]); % so can assume this size later
So far, so good.
At line 475,. and quite many other cases, we run into trouble:
PolicyaprimejzPath=repmat(PolicyaprimejzPath,1,2,1)+repelem(simoptions.setup_experienceasset.N_a1*(a2primeIndexesPath-1),1,2,1);
The first half of the sum is the PolicyaprimejzPath needing to cover the upper and lower grids--all good. The second half of the sum attempts to re-expand a2primeIndexesPath. I think this should be the pattern (and similarly adjusted in the case of no z and no e):
PolicyaprimejzPath=repmat(PolicyaprimejzPath,1,2,1)+simoptions.setup_experienceasset.N_a1*(a2primeIndexesPath-1);
Even better, we could lift the repmat up to the construction of PolicyaprimejzPath and PolicyProbsPath so that it is correct coming out of the gate, saving over a dozen calls to repmap thoughout the 4 z/e combinations across two fastOLG options across both variables.
I'm going to merge that into my changes for when you are ready to take a look at it.
Lines 69-110 adjust a2primeIndexesPath and a2primeProbsPath to include the upper index and upper prob respectively. This changes the shape from
[N_a,N_ze,N_j-1,1,T-1](with z and/or e) to[N_a,N_ze,N_j-1,2,T-1], which is then further reshaped to[N_a*(N_j-1)*N_ze,2,T-1]. So far, so good. The code without z and e is similar in spirit (slightly different in shape) all that follows applies to it in its respective shape as well.Later (following the z and/or e case) we create:
So far, so good.
At line 475,. and quite many other cases, we run into trouble:
The first half of the sum is the
PolicyaprimejzPathneeding to cover the upper and lower grids--all good. The second half of the sum attempts to re-expanda2primeIndexesPath. I think this should be the pattern (and similarly adjusted in the case of no z and no e):Even better, we could lift the repmat up to the construction of
PolicyaprimejzPathandPolicyProbsPathso that it is correct coming out of the gate, saving over a dozen calls to repmap thoughout the 4 z/e combinations across two fastOLG options across both variables.I'm going to merge that into my changes for when you are ready to take a look at it.