Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
25b3c84b
Commit
25b3c84b
authored
Sep 17, 2010
by
Ferhat Mihoubi
Browse files
RESID command is compatible now with block option and without bytecode option (closes ticket #45)
parent
0ecfc5ee
Changes
2
Show whitespace changes
Inline
Side-by-side
matlab/resid.m
View file @
25b3c84b
...
...
@@ -55,7 +55,20 @@ end
% Compute the residuals
if
options_
.
block
&&
~
options_
.
bytecode
error
(
'RESID: incompatibility with "block" without "bytecode" option'
)
z
=
zeros
(
M_
.
endo_nbr
,
1
);
for
i
=
1
:
length
(
M_
.
blocksMFS
)
[
r
,
g
,
yy
,
var_indx
]
=
feval
([
M_
.
fname
'_static'
],
...
i
,
...
oo_
.
steady_state
,
...
[
oo_
.
exo_steady_state
;
...
oo_
.
exo_det_steady_state
],
M_
.
params
);
if
isempty
(
M_
.
blocksMFS
{
i
})
idx
=
var_indx
;
else
idx
=
M_
.
blocksMFS
{
i
};
end
z
(
idx
)
=
r
;
end
elseif
options_
.
block
&&
options_
.
bytecode
[
z
,
check
]
=
bytecode
(
'evaluate'
,
'static'
);
else
...
...
preprocessor/StaticModel.cc
View file @
25b3c84b
...
...
@@ -1069,9 +1069,10 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const
string
func_name
=
basename
+
"_static"
;
output
<<
"function [residual, g1, y] = "
<<
func_name
<<
"(nblock, y, x, params)"
<<
endl
output
<<
"function [residual, g1, y
, var_index
] = "
<<
func_name
<<
"(nblock, y, x, params)"
<<
endl
<<
" residual = [];"
<<
endl
<<
" g1 = [];"
<<
endl
<<
" var_index = [];
\n
"
<<
endl
<<
" switch nblock"
<<
endl
;
unsigned
int
nb_blocks
=
getNbBlocks
();
...
...
@@ -1086,9 +1087,18 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const
BlockSimulationType
simulation_type
=
getBlockSimulationType
(
b
);
if
(
simulation_type
==
EVALUATE_BACKWARD
||
simulation_type
==
EVALUATE_FORWARD
)
output
<<
" y = "
<<
func_name
<<
"_"
<<
b
+
1
<<
"(y, x, params);
\n
"
;
{
output
<<
" y_tmp = "
<<
func_name
<<
"_"
<<
b
+
1
<<
"(y, x, params);
\n
"
;
ostringstream
tmp
;
for
(
int
i
=
0
;
i
<
getBlockSize
(
b
);
i
++
)
tmp
<<
" "
<<
getBlockVariableID
(
b
,
i
)
+
1
;
output
<<
" var_index = ["
<<
tmp
.
str
()
<<
"];
\n
"
;
output
<<
" residual = y(var_index) - y_tmp(var_index);
\n
"
;
output
<<
" y = y_tmp;
\n
"
;
}
else
output
<<
" [residual, y, g1] = "
<<
func_name
<<
"_"
<<
b
+
1
<<
"(y, x, params);
\n
"
;
}
output
<<
" end"
<<
endl
<<
"end"
<<
endl
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment