Skip to content
Snippets Groups Projects
Verified Commit f6004376 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'lyap' of git.dynare.org:JohannesPfeifer/dynare

Ref. !1913

Closes: #1078
parents 97a86b5b f273c09e
No related branches found
No related tags found
1 merge request!1913lyapunov_solver.m: make baseline compatible with sparse matrices
...@@ -66,7 +66,7 @@ else ...@@ -66,7 +66,7 @@ else
end end
%@test:1 %@test:1
%$ t = NaN(10,1); %$ t = NaN(13,1);
%$ options_.lyapunov_complex_threshold = 1e-15; %$ options_.lyapunov_complex_threshold = 1e-15;
%$ options_.qz_zero_threshold = 1e-6; %$ options_.qz_zero_threshold = 1e-6;
%$ options_.qz_criterium=1-options_.qz_zero_threshold; %$ options_.qz_criterium=1-options_.qz_zero_threshold;
...@@ -136,50 +136,71 @@ end ...@@ -136,50 +136,71 @@ end
%$ t(4) = 0; %$ t(4) = 0;
%$ end %$ end
%$ %$
%$ % Standard with sparse matrix
%$ try
%$ Pstar5_small = lyapunov_solver(sparse(T_small),sparse(R_small),sparse(Q_small),options_);
%$ Pstar5_large = lyapunov_solver(sparse(T_large),sparse(R_large),sparse(Q_large),options_);
%$ t(5) = 1;
%$ catch
%$ t(5) = 0;
%$ end
%$
%$ % Test the results. %$ % Test the results.
%$ %$
%$ if max(max(abs(Pstar1_small-Pstar2_small)))>1e-8 %$ if max(max(abs(Pstar1_small-Pstar2_small)))>1e-8
%$ t(5) = 0; %$ t(6) = 0;
%$ else %$ else
%$ t(5) = 1; %$ t(6) = 1;
%$ end %$ end
%$ %$
%$ if (isoctave && user_has_octave_forge_package('control')) || (~isoctave && user_has_matlab_license('control_toolbox')) %$ if (isoctave && user_has_octave_forge_package('control')) || (~isoctave && user_has_matlab_license('control_toolbox'))
%$ if max(max(abs(Pstar1_small-Pstar3_small)))>1e-8 %$ if max(max(abs(Pstar1_small-Pstar3_small)))>1e-8
%$ t(6) = 0; %$ t(7) = 0;
%$ else %$ else
%$ t(6) = 1; %$ t(7) = 1;
%$ end %$ end
%$ else %$ else
%$ t(6) = 1; %$ t(7) = 1;
%$ end %$ end
%$ %$
%$ if max(max(abs(Pstar1_small-Pstar4_small)))>1e-8 %$ if max(max(abs(Pstar1_small-Pstar4_small)))>1e-8
%$ t(7) = 0; %$ t(8) = 0;
%$ else %$ else
%$ t(7) = 1; %$ t(8) = 1;
%$ end
%$
%$ if max(max(abs(Pstar1_small-Pstar5_small)))>1e-8
%$ t(9) = 0;
%$ else
%$ t(9) = 1;
%$ end %$ end
%$ %$
%$ if max(max(abs(Pstar1_large-Pstar2_large)))>2e-8 %$ if max(max(abs(Pstar1_large-Pstar2_large)))>2e-8
%$ t(8) = 0; %$ t(10) = 0;
%$ else %$ else
%$ t(8) = 1; %$ t(10) = 1;
%$ end %$ end
%$ %$
%$ if (isoctave && user_has_octave_forge_package('control')) || (~isoctave && user_has_matlab_license('control_toolbox')) %$ if (isoctave && user_has_octave_forge_package('control')) || (~isoctave && user_has_matlab_license('control_toolbox'))
%$ if max(max(abs(Pstar1_large-Pstar3_large)))>1e-8 %$ if max(max(abs(Pstar1_large-Pstar3_large)))>1e-8
%$ t(9) = 0; %$ t(11) = 0;
%$ else %$ else
%$ t(9) = 1; %$ t(11) = 1;
%$ end %$ end
%$ else %$ else
%$ t(9) = 1; %$ t(11) = 1;
%$ end %$ end
%$ %$
%$ if max(max(abs(Pstar1_large-Pstar4_large)))>2e-8 %$ if max(max(abs(Pstar1_large-Pstar4_large)))>2e-8
%$ t(10) = 0; %$ t(12) = 0;
%$ else %$ else
%$ t(10) = 1; %$ t(12) = 1;
%$ end
%$
%$ if max(max(abs(Pstar1_large-Pstar5_large)))>2e-8
%$ t(13) = 0;
%$ else
%$ t(13) = 1;
%$ end %$ end
%$ %$
%$ T = all(t); %$ T = all(t);
......
...@@ -108,7 +108,7 @@ if size(a,1) == 1 ...@@ -108,7 +108,7 @@ if size(a,1) == 1
end end
if method<2 if method<2
[U,T] = schur(a); [U,T] = schur(full(a));
e1 = abs(ordeig(T)) > 2-qz_criterium; e1 = abs(ordeig(T)) > 2-qz_criterium;
k = sum(e1); % Number of unit roots. k = sum(e1); % Number of unit roots.
n = length(e1)-k; % Number of stationary variables. n = length(e1)-k; % Number of stationary variables.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment