Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Commits
f6004376
Verified
Commit
f6004376
authored
3 years ago
by
Sébastien Villemot
Browse files
Options
Downloads
Plain Diff
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
!1913
lyapunov_solver.m: make baseline compatible with sparse matrices
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/lyapunov_solver.m
+36
-15
36 additions, 15 deletions
matlab/lyapunov_solver.m
matlab/lyapunov_symm.m
+1
-1
1 addition, 1 deletion
matlab/lyapunov_symm.m
with
37 additions
and
16 deletions
matlab/lyapunov_solver.m
+
36
−
15
View file @
f6004376
...
@@ -66,7 +66,7 @@ else
...
@@ -66,7 +66,7 @@ else
end
end
%@test:1
%@test:1
%$ t = NaN(1
0
,1);
%$ t = NaN(1
3
,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(1
0
) = 0;
%$ t(1
2
) = 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);
...
...
This diff is collapsed.
Click to expand it.
matlab/lyapunov_symm.m
+
1
−
1
View file @
f6004376
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment