Harmonize output of local_state_space_iteration_k and local_state_space_iteration_2

local_state_space_iteration_k has all endogenous variables as its output, while local_state_space_iteration_2 has only restrict_var_list (i.e. drops static variables that are not observed). Nevertheless in pretty much all particle filters we have code like

if ReducedForm.use_k_order_solver
  tmp = local_state_space_iteration_k(yhat, epsilon, dr, Model, DynareOptions);
else
  tmp = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,ThreadsOptions.local_state_space_iteration_2);
end
PredictionError = bsxfun(@minus,Y(:,t),tmp(mf1,:));

where mf1 is the position of the observables in restrict_var_list. Consequently, the use of k_order_solver will generally return wrong result as we are reading out the wrong variables. There are two ways of fixing this:

  1. Change indexing for reading out to restrict_var_list(mf1) in various subfunctions
  2. Make the output of local_state_space_iteration_k and local_state_space_iteration_2 consistent to output only restrict_var_list

I would prefer option 2 as it makes the code faster and we do not need to introduce additional case distinctions that make the code hard to parse.

Relatedly, local_state_space_iteration_2 is about 60 times faster than local_state_space_iteration_k at the same order=2, see https://git.dynare.org/Dynare/dynare/-/blob/master/tests/particle/local_state_space_iteration_k_test.mod so any changes should keep this in mind.

Edited by Johannes Pfeifer