Minor improvement to ValueFnIter_Refine

This is more a performance issue than a bug.

In ValueFnIter/InfHorz/Refinement/ValueFnIter_Refine.m I changed

Policy=zeros(2,N_a,N_z);

to

Policy=zeros(2,N_a,N_z,'gpuArray');

This keeps everything on the GPU instead of creating the final policy on the CPU and then filling it using Policy_a, dstar, etc. which are on the GPU:

if n_d(1)>0
    Policy=zeros(2,N_a,N_z,'gpuArray');
    Policy(2,:,:)=shiftdim(Policy_a,-1);
    temppolicyindex=reshape(Policy_a,[1,N_a*N_z])+(0:1:N_a*N_z-1)*N_a;
    Policy(1,:,:)=reshape(dstar(temppolicyindex),[N_a,N_z]);
else
    Policy=Policy_a;
end

Not so important for performance since this is outside any hot loop, but still needs to be fixed.

This is also included in a PR, I think.

Merged this one :smiley: nice little improvement.

1 Like