Skip to content
Snippets Groups Projects
Commit 1755192e authored by Johannes Pfeifer's avatar Johannes Pfeifer
Browse files

Make 792924 consistent with cases where Pinf is an empty matrix

Fixes the crash in `analytic_derivatives/fs2000_analytic_derivation.mod`
parent 792924a3
Branches
Tags
1 merge request!1428Test the rank of Pinf in univariate smoother for the subset of observables
...@@ -255,8 +255,10 @@ if kalman_algo == 2 || kalman_algo == 4 ...@@ -255,8 +255,10 @@ if kalman_algo == 2 || kalman_algo == 4
[Pstar,Pinf] = compute_Pinf_Pstar(mf,ST,R1,Q,options_.qz_criterium); [Pstar,Pinf] = compute_Pinf_Pstar(mf,ST,R1,Q,options_.qz_criterium);
else else
Pstar = blkdiag(Pstar,H); Pstar = blkdiag(Pstar,H);
if ~isempty(Pinf)
Pinf = blkdiag(Pinf,zeros(vobs)); Pinf = blkdiag(Pinf,zeros(vobs));
end end
end
%now reset H to 0 %now reset H to 0
H = zeros(vobs,vobs); H = zeros(vobs,vobs);
else else
......
...@@ -122,7 +122,11 @@ end ...@@ -122,7 +122,11 @@ end
t = 0; t = 0;
icc=0; icc=0;
if ~isempty(Pinf(:,:,1))
newRank = rank(Z*Pinf(:,:,1)*Z',diffuse_kalman_tol); newRank = rank(Z*Pinf(:,:,1)*Z',diffuse_kalman_tol);
else
newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
end
while newRank && t < smpl while newRank && t < smpl
t = t+1; t = t+1;
a(:,t) = a1(:,t); a(:,t) = a1(:,t);
...@@ -156,7 +160,11 @@ while newRank && t < smpl ...@@ -156,7 +160,11 @@ while newRank && t < smpl
end end
end end
if newRank if newRank
if ~isempty(Pinf(:,:,t))
oldRank = rank(Z*Pinf(:,:,t)*Z',diffuse_kalman_tol); oldRank = rank(Z*Pinf(:,:,t)*Z',diffuse_kalman_tol);
else
oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
end
else else
oldRank = 0; oldRank = 0;
end end
...@@ -168,7 +176,11 @@ while newRank && t < smpl ...@@ -168,7 +176,11 @@ while newRank && t < smpl
Pstar(:,:,t+1) = T*Pstar(:,:,t)*T'+ QQ; Pstar(:,:,t+1) = T*Pstar(:,:,t)*T'+ QQ;
Pinf(:,:,t+1) = T*Pinf(:,:,t)*T'; Pinf(:,:,t+1) = T*Pinf(:,:,t)*T';
if newRank if newRank
if ~isempty(Pinf(:,:,t+1))
newRank = rank(Z*Pinf(:,:,t+1)*Z',diffuse_kalman_tol); newRank = rank(Z*Pinf(:,:,t+1)*Z',diffuse_kalman_tol);
else
newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
end
end end
if oldRank ~= newRank if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!') disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment