Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
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
Sébastien Villemot
dynare
Commits
9a7f34da
Verified
Commit
9a7f34da
authored
6 months ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
Occbin solver: use sparse representation for the model
Ref. #1859
parent
9465e460
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/+occbin/get_deriv.m
+11
-35
11 additions, 35 deletions
matlab/+occbin/get_deriv.m
with
11 additions
and
35 deletions
matlab/+occbin/get_deriv.m
+
11
−
35
View file @
9a7f34da
...
@@ -13,7 +13,7 @@ function [h_minus_1, h, h_plus_1, h_exo, resid] = get_deriv(M_, ys_)
...
@@ -13,7 +13,7 @@ function [h_minus_1, h, h_plus_1, h_exo, resid] = get_deriv(M_, ys_)
% - h_exo [N by N_exo] derivative matrix with respect to exogenous variables
% - h_exo [N by N_exo] derivative matrix with respect to exogenous variables
% - resid [N by 1] vector of residuals
% - resid [N by 1] vector of residuals
% Copyright © 2021 Dynare Team
% Copyright © 2021
-2024
Dynare Team
%
%
% This file is part of Dynare.
% This file is part of Dynare.
%
%
...
@@ -30,40 +30,16 @@ function [h_minus_1, h, h_plus_1, h_exo, resid] = get_deriv(M_, ys_)
...
@@ -30,40 +30,16 @@ function [h_minus_1, h, h_plus_1, h_exo, resid] = get_deriv(M_, ys_)
% You should have received a copy of the GNU General Public License
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
x
=
zeros
(
M_
.
maximum_lag
+
M_
.
maximum_lead
+
1
,
M_
.
exo_nbr
);
dyn_endo_ss
=
repmat
(
ys_
,
3
,
1
);
x
=
zeros
(
M_
.
exo_nbr
);
iyv
=
M_
.
lead_lag_incidence
'
;
[
resid
,
T_order
,
T
]
=
feval
([
M_
.
fname
'.sparse.dynamic_resid'
],
dyn_endo_ss
,
x
,
M_
.
params
,
ys_
);
iyr0
=
find
(
iyv
(:))
;
z
=
repmat
(
ys_
,
1
,
M_
.
maximum_lag
+
M_
.
maximum_lead
+
1
);
[
resid
,
g1
]
=
feval
([
M_
.
fname
,
'.dynamic'
],
z
(
iyr0
),
x
,
M_
.
params
,
ys_
,
M_
.
maximum_exo_lag
+
1
);
g1
=
feval
([
M_
.
fname
'.sparse.dynamic_g1'
],
dyn_endo_ss
,
x
,
M_
.
params
,
ys_
,
...
M_
.
dynamic_g1_sparse_rowval
,
M_
.
dynamic_g1_sparse_colval
,
...
M_
.
dynamic_g1_sparse_colptr
,
T_order
,
T
);
% Initialize matrices
h_minus_1
=
full
(
g1
(:,
1
:
M_
.
endo_nbr
));
h_minus_1
=
zeros
(
M_
.
endo_nbr
);
h
=
full
(
g1
(:,
M_
.
endo_nbr
+
(
1
:
M_
.
endo_nbr
)));
h
=
h_minus_1
;
h_plus_1
=
full
(
g1
(:,
2
*
M_
.
endo_nbr
+
(
1
:
M_
.
endo_nbr
)));
h_plus_1
=
h_minus_1
;
h_exo
=
full
(
g1
(:,
3
*
M_
.
endo_nbr
+
1
:
end
));
% build h_minus_1
if
M_
.
maximum_lag
lag_columns
=
find
(
iyv
(:,
1
));
n_lag_columns
=
length
(
lag_columns
);
h_minus_1
(:,
lag_columns
)
=
g1
(:,
1
:
n_lag_columns
);
else
n_lag_columns
=
0
;
end
% build h
contemporaneous_columns
=
find
(
iyv
(:,
M_
.
maximum_lag
+
1
));
n_contemporaneous_columns
=
length
(
contemporaneous_columns
);
h
(:,
contemporaneous_columns
)
=
g1
(:,
1
+
n_lag_columns
:
n_lag_columns
+
n_contemporaneous_columns
);
%build h_plus_1
if
M_
.
maximum_lead
lead_columns
=
find
(
iyv
(:,
end
));
n_lead_columns
=
length
(
lead_columns
);
h_plus_1
(:,
lead_columns
)
=
g1
(:,
n_lag_columns
+
n_contemporaneous_columns
+
1
:
n_lag_columns
+
n_contemporaneous_columns
+
n_lead_columns
);
else
n_lead_columns
=
0
;
end
h_exo
=
g1
(:,
n_lag_columns
+
n_contemporaneous_columns
+
n_lead_columns
+
1
:
end
);
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