In the update! method for DefaultState, we are currently using state.prev = copy(v) (see here. For arrays this can be expensive. It would be better to use copy!(istate.prev, v)
Also, only giving the user the current state in the function that is the first argument to managed_iteration forces him to make a copy of it before using. If I write these algorithms out by hand I write v = init; v_new = similar(v) once outside the loop, then I update v_new during stage 2 (iteration phase) and call copy!(v, v_new) at the end of stage 3 (between iteration processing). This means during the loop I don't allocate anything for v and v_new. We should think carefully about a way to enable the user to do this here also.
In the
update!method for DefaultState, we are currently usingstate.prev = copy(v)(see here. For arrays this can be expensive. It would be better to usecopy!(istate.prev, v)Also, only giving the user the current state in the function that is the first argument to
managed_iterationforces him to make a copy of it before using. If I write these algorithms out by hand I writev = init; v_new = similar(v)once outside the loop, then I updatev_newduring stage 2 (iteration phase) and callcopy!(v, v_new)at the end of stage 3 (between iteration processing). This means during the loop I don't allocate anything forvandv_new. We should think carefully about a way to enable the user to do this here also.