I’m working on a large economic model that involves a dynamic optimization problem. I’ve set up arrays within immutable structs to hold the solutions to the problem. The algorithm involves iterating on fixed points on these arrays. So I have “old” and “new” arrays and I compute the tolerance between them and then replace the “old” with the “new”.
I’m running into a problem where I will get small numbers of nan
elements in the new array and some (incorrect) massive numbers as well when I mutate them. I used @infiltrate
to diagnose the source of these. But when I do the assignment to a new test array, the nan
elements don’t show up. In addition, if I do the assignment again to the struct within the infiltrator.jl repl, the nan
elements will sometimes disappear.
The code leading up to the assignments is quite complicated, so I’ve just provided some screenshots below to show what’s going on. The cPol
, aPol
, etc., variables are views into other arrays within the hh
struct. I checked each of the components on the right-hand side for nan
elements and they had none.
I’d greatly appreciate any insight into this strange error.
Assignment to a new array, test
works fine:
Assignment to the struct array shows nan
errors:
Assigning again to the struct array and nan
errors disappear: