Eg, here is one actual loop this would be used on. Something like @Unroll_before_reset
would be ideal:
function test6(gt)
for t in 1:10
@Unroll_before_reset for i in 1:2
@reset gt[i].min .+= gt[i].act
r1 = @SVector rand(Uniform(-.003, .003), 16)
@reset gt[i].fat .-= gt[i].act .* (gt[i].ded .- r1)
@reset gt[i].fat .= max.(gt[i].fat, 0.1)
@reset gt[i].sh_cm .= gt[i].sh_c0 .* gt[i].fat .* gt[i].act
@reset gt[i].ps_cm .= gt[i].ps_c0 .* gt[i].fat .* gt[i].act
@reset gt[i].tk_cm .= gt[i].tk_c0 .* gt[i].fat .* gt[i].act
end
end
return gt
end
Even better would be @Unroll_then_reset for cases where @reset
is being called on every line. I’ve yet to explore writing macros, but this discussion gives the impression it would not be trivial: