Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
MichelJuillard
dynare
Commits
6d114289
Commit
6d114289
authored
Apr 22, 2015
by
Houtan Bastani
Browse files
preprocessor: move M_ statements to a separate function called set_<modfilename>_M_.m, #885
parent
46263910
Changes
17
Hide whitespace changes
Inline
Side-by-side
doc/dynare.texi
View file @
6d114289
...
...
@@ -698,13 +698,16 @@ and the processing instructions, as described in @ref{The Model file}.
@
code
{
dynare
}
begins
by
launching
the
preprocessor
on
the
@
file
{.
mod
}
file
.
By
default
(
unless
@
code
{
use_dll
}
option
has
been
given
to
@
code
{
model
}),
the
preprocessor
creates
three
intermediary
files
:
@
code
{
model
}),
the
preprocessor
creates
four
intermediary
files
:
@
table
@
file
@
item
@
var
{
FILENAME
}.
m
Contains
variable
declarations
,
and
computing
tasks
@
item
@
var
{
FILENAME
}
_M_
.
m
Defines
the
model
structure
@
item
@
var
{
FILENAME
}
_dynamic
.
m
@
vindex
M_
.
lead_lag_incidence
Contains
the
dynamic
model
equations
.
Note
that
Dynare
might
introduce
auxiliary
equations
and
variables
(@
pxref
{
Auxiliary
variables
}).
Outputs
are
the
residuals
of
the
dynamic
model
equations
in
the
order
the
equations
were
declared
and
the
Jacobian
of
the
dynamic
model
equations
.
For
higher
order
approximations
also
the
Hessian
and
the
third
-
order
derivatives
are
provided
.
When
computing
the
Jacobian
of
the
dynamic
model
,
the
order
of
the
endogenous
variables
in
the
columns
is
stored
in
@
code
{
M_
.
lead_lag_incidence
}.
The
rows
of
this
matrix
represent
time
periods
:
the
first
row
denotes
a
lagged
(
time
t
-
1
)
variable
,
the
second
row
a
contemporaneous
(
time
t
)
variable
,
and
the
third
row
a
leaded
(
time
t
+
1
)
variable
.
The
columns
of
the
matrix
represent
the
endogenous
variables
in
their
order
of
declaration
.
A
zero
in
the
matrix
means
that
this
endogenous
does
not
appear
in
the
model
in
this
time
period
.
The
value
in
the
@
code
{
M_
.
lead_lag_incidence
}
matrix
corresponds
to
the
column
of
that
variable
in
the
Jacobian
of
the
dynamic
model
.
Example
:
Let
the
second
declared
variable
be
@
code
{
c
}
and
the
@
code
{(
3
,
2
)}
entry
of
@
code
{
M_
.
lead_lag_incidence
}
be
@
code
{
15
}.
Then
the
@
code
{
15
}
th
column
of
the
Jacobian
is
the
derivative
with
respect
to
@
code
{
y
(+
1
)}.
...
...
preprocessor/DynamicModel.cc
View file @
6d114289
...
...
@@ -2310,7 +2310,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const
}
void
DynamicModel
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
block_decomposition
,
bool
byte_code
,
bool
use_dll
,
int
order
,
bool
estimation_present
)
const
DynamicModel
::
write
M_
Output
(
ostream
&
output
,
const
string
&
basename
,
bool
block_decomposition
,
bool
byte_code
,
bool
use_dll
,
int
order
,
bool
estimation_present
)
const
{
/* Writing initialisation for M_.lead_lag_incidence matrix
M_.lead_lag_incidence is a matrix with as many columns as there are
...
...
@@ -2844,19 +2844,14 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
<<
"M_.maximum_lead = "
<<
max_lead
<<
";"
<<
endl
;
output
<<
"M_.maximum_endo_lag = "
<<
max_endo_lag
<<
";"
<<
endl
<<
"M_.maximum_endo_lead = "
<<
max_endo_lead
<<
";"
<<
endl
<<
"oo_.steady_state = zeros("
<<
symbol_table
.
endo_nbr
()
<<
", 1);"
<<
endl
;
<<
"M_.maximum_endo_lead = "
<<
max_endo_lead
<<
";"
<<
endl
;
output
<<
"M_.maximum_exo_lag = "
<<
max_exo_lag
<<
";"
<<
endl
<<
"M_.maximum_exo_lead = "
<<
max_exo_lead
<<
";"
<<
endl
<<
"oo_.exo_steady_state = zeros("
<<
symbol_table
.
exo_nbr
()
<<
", 1);"
<<
endl
;
<<
"M_.maximum_exo_lead = "
<<
max_exo_lead
<<
";"
<<
endl
;
if
(
symbol_table
.
exo_det_nbr
())
{
output
<<
"M_.maximum_exo_det_lag = "
<<
max_exo_det_lag
<<
";"
<<
endl
<<
"M_.maximum_exo_det_lead = "
<<
max_exo_det_lead
<<
";"
<<
endl
<<
"oo_.exo_det_steady_state = zeros("
<<
symbol_table
.
exo_det_nbr
()
<<
", 1);"
<<
endl
;
}
output
<<
"M_.maximum_exo_det_lag = "
<<
max_exo_det_lag
<<
";"
<<
endl
<<
"M_.maximum_exo_det_lead = "
<<
max_exo_det_lead
<<
";"
<<
endl
;
output
<<
"M_.params = NaN("
<<
symbol_table
.
param_nbr
()
<<
", 1);"
<<
endl
;
...
...
@@ -2878,6 +2873,16 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
}
void
DynamicModel
::
writeOutput
(
ostream
&
output
)
const
{
output
<<
"oo_.steady_state = zeros("
<<
symbol_table
.
endo_nbr
()
<<
", 1);"
<<
endl
<<
"oo_.exo_steady_state = zeros("
<<
symbol_table
.
exo_nbr
()
<<
", 1);"
<<
endl
;
if
(
symbol_table
.
exo_det_nbr
())
output
<<
"oo_.exo_det_steady_state = zeros("
<<
symbol_table
.
exo_det_nbr
()
<<
", 1);"
<<
endl
;
}
map
<
pair
<
int
,
pair
<
int
,
int
>
>
,
expr_t
>
DynamicModel
::
collect_first_order_derivatives_endogenous
()
{
...
...
preprocessor/DynamicModel.hh
View file @
6d114289
...
...
@@ -213,7 +213,8 @@ public:
void
computingPass
(
bool
jacobianExo
,
bool
hessian
,
bool
thirdDerivatives
,
bool
paramsDerivatives
,
const
eval_context_t
&
eval_context
,
bool
no_tmp_terms
,
bool
block
,
bool
use_dll
,
bool
bytecode
);
//! Writes model initialization and lead/lag incidence matrix to output
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
block
,
bool
byte_code
,
bool
use_dll
,
int
order
,
bool
estimation_present
)
const
;
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
block
,
bool
byte_code
,
bool
use_dll
,
int
order
,
bool
estimation_present
)
const
;
void
writeOutput
(
ostream
&
output
)
const
;
//! Adds informations for simulation in a binary file
void
Write_Inf_To_Bin_File_Block
(
const
string
&
dynamic_basename
,
const
string
&
bin_basename
,
...
...
preprocessor/ModFile.cc
View file @
6d114289
...
...
@@ -535,7 +535,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
#endif
)
const
{
ofstream
mOutputFile
;
ofstream
mOutputFile
,
M_OutputFile
;
if
(
basename
.
size
())
{
...
...
@@ -555,6 +555,16 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
exit
(
EXIT_FAILURE
);
}
string
fname
(
basename
+
"_M_"
);
fname
+=
".m"
;
M_OutputFile
.
open
(
fname
.
c_str
(),
ios
::
out
|
ios
::
binary
);
if
(
!
M_OutputFile
.
is_open
())
{
cerr
<<
"ERROR: Can't open file "
<<
fname
<<
" for writing"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
writeM_
(
M_OutputFile
,
basename
);
mOutputFile
<<
"%"
<<
endl
<<
"% Status : main Dynare file "
<<
endl
<<
"%"
<<
endl
...
...
@@ -570,10 +580,10 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
mOutputFile
<<
"clear M_ options_ oo_ estim_params_ bayestopt_ dataset_;"
<<
endl
;
mOutputFile
<<
"tic;"
<<
endl
<<
"% Save empty dates and dseries objects in memory."
<<
endl
<<
"dates('initialize');"
<<
endl
<<
"dseries('initialize');"
<<
endl
<<
"% Define global variables."
<<
endl
<<
"% Save empty dates and dseries objects in memory."
<<
endl
<<
"dates('initialize');"
<<
endl
<<
"dseries('initialize');"
<<
endl
<<
"% Define global variables."
<<
endl
<<
"global M_ oo_ options_ ys0_ ex0_ estimation_info"
<<
endl
<<
"options_ = [];"
<<
endl
<<
"M_.fname = '"
<<
basename
<<
"';"
<<
endl
...
...
@@ -583,6 +593,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
<<
"%"
<<
endl
<<
"% Some global variables initialization"
<<
endl
<<
"%"
<<
endl
;
config_file
.
writeHooks
(
mOutputFile
);
mOutputFile
<<
"global_initialization;"
<<
endl
<<
"diary off;"
<<
endl
;
...
...
@@ -592,6 +603,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
if
(
minimal_workspace
)
mOutputFile
<<
"options_.minimal_workspace = 1;"
<<
endl
;
mOutputFile
<<
"M_ = "
<<
basename
<<
"_M_(M_);"
<<
endl
;
if
(
console
)
mOutputFile
<<
"options_.console_mode = 1;"
<<
endl
<<
"options_.nodisplay = 1;"
<<
endl
;
...
...
@@ -600,32 +613,12 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
if
(
nointeractive
)
mOutputFile
<<
"options_.nointeractive = 1;"
<<
endl
;
cout
<<
"Processing outputs ..."
<<
endl
;
symbol_table
.
writeM_Output
(
M_OutputFile
);
symbol_table
.
writeOutput
(
mOutputFile
);
// Initialize M_.Sigma_e, M_.Correlation_matrix, M_.H, and M_.Correlation_matrix_ME
mOutputFile
<<
"M_.Sigma_e = zeros("
<<
symbol_table
.
exo_nbr
()
<<
", "
<<
symbol_table
.
exo_nbr
()
<<
");"
<<
endl
<<
"M_.Correlation_matrix = eye("
<<
symbol_table
.
exo_nbr
()
<<
", "
<<
symbol_table
.
exo_nbr
()
<<
");"
<<
endl
;
if
(
mod_file_struct
.
calibrated_measurement_errors
)
mOutputFile
<<
"M_.H = zeros("
<<
symbol_table
.
observedVariablesNbr
()
<<
", "
<<
symbol_table
.
observedVariablesNbr
()
<<
");"
<<
endl
<<
"M_.Correlation_matrix_ME = eye("
<<
symbol_table
.
observedVariablesNbr
()
<<
", "
<<
symbol_table
.
observedVariablesNbr
()
<<
");"
<<
endl
;
else
mOutputFile
<<
"M_.H = 0;"
<<
endl
<<
"M_.Correlation_matrix_ME = 1;"
<<
endl
;
// May be later modified by a shocks block
mOutputFile
<<
"M_.sigma_e_is_diagonal = 1;"
<<
endl
;
// Initialize M_.det_shocks
mOutputFile
<<
"M_.det_shocks = [];"
<<
endl
;
if
(
linear
==
1
)
mOutputFile
<<
"options_.linear = 1;"
<<
endl
;
...
...
@@ -730,21 +723,20 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
if
(
block
&&
!
byte_code
)
mOutputFile
<<
"addpath "
<<
basename
<<
";"
<<
endl
;
mOutputFile
<<
"M_.orig_eq_nbr = "
<<
orig_eqn_nbr
<<
";"
<<
endl
<<
"M_.eq_nbr = "
<<
dynamic_model
.
equation_number
()
<<
";"
<<
endl
<<
"M_.ramsey_eq_nbr = "
<<
ramsey_eqn_nbr
<<
";"
<<
endl
;
if
(
dynamic_model
.
equation_number
()
>
0
)
{
dynamic_model
.
writeOutput
(
mOutputFile
,
basename
,
block
,
byte_code
,
use_dll
,
mod_file_struct
.
order_option
,
mod_file_struct
.
estimation_present
);
dynamic_model
.
writeM_Output
(
M_OutputFile
,
basename
,
block
,
byte_code
,
use_dll
,
mod_file_struct
.
order_option
,
mod_file_struct
.
estimation_present
);
dynamic_model
.
writeOutput
(
mOutputFile
);
if
(
!
no_static
)
static_model
.
writeOutput
(
m
OutputFile
,
block
);
static_model
.
write
M_
Output
(
M_
OutputFile
,
block
);
}
// Print statements
for
(
vector
<
Statement
*>::
const_iterator
it
=
statements
.
begin
();
it
!=
statements
.
end
();
it
++
)
{
(
*
it
)
->
writeM_Output
(
M_OutputFile
,
basename
,
minimal_workspace
);
(
*
it
)
->
writeOutput
(
mOutputFile
,
basename
,
minimal_workspace
);
/* Special treatment for initval block: insert initial values for the
...
...
@@ -803,6 +795,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
mOutputFile
<<
"diary off"
<<
endl
;
mOutputFile
.
close
();
M_OutputFile
.
close
();
if
(
hasModelChanged
)
{
...
...
@@ -822,6 +815,41 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
// Create steady state file
steady_state_model
.
writeSteadyStateFile
(
basename
,
mod_file_struct
.
ramsey_model_present
);
}
cout
<<
"done"
<<
endl
;
}
void
ModFile
::
writeM_
(
ofstream
&
M_OutputFile
,
const
string
&
basename
)
const
{
M_OutputFile
<<
"function M_ = "
<<
basename
<<
"_M_(M_)"
<<
endl
<<
"%"
<<
endl
<<
"% Created by the Dynare preprocessor"
<<
endl
<<
"%"
<<
endl
<<
"M_.fname = '"
<<
basename
<<
"';"
<<
endl
;
// Initialize M_.Sigma_e, M_.Correlation_matrix, M_.H, and M_.Correlation_matrix_ME
M_OutputFile
<<
"M_.Sigma_e = zeros("
<<
symbol_table
.
exo_nbr
()
<<
", "
<<
symbol_table
.
exo_nbr
()
<<
");"
<<
endl
<<
"M_.Correlation_matrix = eye("
<<
symbol_table
.
exo_nbr
()
<<
", "
<<
symbol_table
.
exo_nbr
()
<<
");"
<<
endl
;
if
(
mod_file_struct
.
calibrated_measurement_errors
)
M_OutputFile
<<
"M_.H = zeros("
<<
symbol_table
.
observedVariablesNbr
()
<<
", "
<<
symbol_table
.
observedVariablesNbr
()
<<
");"
<<
endl
<<
"M_.Correlation_matrix_ME = eye("
<<
symbol_table
.
observedVariablesNbr
()
<<
", "
<<
symbol_table
.
observedVariablesNbr
()
<<
");"
<<
endl
;
else
M_OutputFile
<<
"M_.H = 0;"
<<
endl
<<
"M_.Correlation_matrix_ME = 1;"
<<
endl
;
// May be later modified by a shocks block
M_OutputFile
<<
"M_.sigma_e_is_diagonal = 1;"
<<
endl
;
// Initialize M_.det_shocks
M_OutputFile
<<
"M_.det_shocks = [];"
<<
endl
;
M_OutputFile
<<
"M_.orig_eq_nbr = "
<<
orig_eqn_nbr
<<
";"
<<
endl
<<
"M_.eq_nbr = "
<<
dynamic_model
.
equation_number
()
<<
";"
<<
endl
<<
"M_.ramsey_eq_nbr = "
<<
ramsey_eqn_nbr
<<
";"
<<
endl
;
}
preprocessor/ModFile.hh
View file @
6d114289
...
...
@@ -152,6 +152,7 @@ public:
,
bool
cygwin
,
bool
msvc
#endif
)
const
;
void
writeM_
(
ofstream
&
M_OutputFile
,
const
string
&
basename
)
const
;
// Functions located in ExternalFiles.cc
void
writeExternalFiles
(
const
string
&
basename
,
FileOutputType
output
,
LanguageOutputType
language
)
const
;
void
writeExternalFilesC
(
const
string
&
basename
,
FileOutputType
output
)
const
;
...
...
preprocessor/NumericalInitialization.cc
View file @
6d114289
...
...
@@ -42,6 +42,13 @@ InitParamStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolid
void
InitParamStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
{
int
id
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
output
<<
symbol_table
.
getName
(
symb_id
)
<<
" = M_.params( "
<<
id
<<
" );
\n
"
;
}
void
InitParamStatement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
int
id
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
output
<<
"M_.params( "
<<
id
<<
" ) = "
;
...
...
@@ -270,6 +277,57 @@ HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
void
HistValStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
{
for
(
hist_values_t
::
const_iterator
it
=
hist_values
.
begin
();
it
!=
hist_values
.
end
();
it
++
)
{
int
symb_id
=
it
->
first
.
first
;
int
lag
=
it
->
first
.
second
;
const
expr_t
expression
=
it
->
second
;
SymbolType
type
=
symbol_table
.
getType
(
symb_id
);
// For a lag greater than 1 on endo, or for any exo, lookup for auxiliary variable
if
((
type
==
eEndogenous
&&
lag
<
0
)
||
type
==
eExogenous
)
{
try
{
// This function call must remain the 1st statement in this block
symb_id
=
symbol_table
.
searchAuxiliaryVars
(
symb_id
,
lag
);
lag
=
0
;
type
=
eEndogenous
;
}
catch
(
SymbolTable
::
SearchFailedException
&
e
)
{
if
(
type
==
eEndogenous
)
{
cerr
<<
"HISTVAL: internal error of Dynare, please contact the developers"
;
exit
(
EXIT_FAILURE
);
}
// We don't fail for exogenous, because they are not replaced by
// auxiliary variables in deterministic mode.
}
}
int
tsid
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
if
(
type
==
eExogenous
)
{
output
<<
"oo_.exo_simul( M_.maximum_lag + "
<<
lag
<<
", "
<<
tsid
<<
" ) = "
;
expression
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
else
if
(
type
!=
eExogenousDet
)
{
output
<<
"oo_.exo_det_simul( M_.maximum_lag + "
<<
lag
<<
", "
<<
tsid
<<
" ) = "
;
expression
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
}
}
void
HistValStatement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
output
<<
"%"
<<
endl
<<
"% HISTVAL instructions"
<<
endl
...
...
@@ -310,14 +368,11 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
int
tsid
=
symbol_table
.
getTypeSpecificID
(
symb_id
)
+
1
;
if
(
type
==
eEndogenous
)
output
<<
"M_.endo_histval( "
<<
tsid
<<
", M_.maximum_endo_lag + "
<<
lag
<<
") = "
;
else
if
(
type
==
eExogenous
)
output
<<
"oo_.exo_simul( M_.maximum_lag + "
<<
lag
<<
", "
<<
tsid
<<
" ) = "
;
else
if
(
type
!=
eExogenousDet
)
output
<<
"oo_.exo_det_simul( M_.maximum_lag + "
<<
lag
<<
", "
<<
tsid
<<
" ) = "
;
expression
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
{
output
<<
"M_.endo_histval( "
<<
tsid
<<
", M_.maximum_endo_lag + "
<<
lag
<<
") = "
;
expression
->
writeOutput
(
output
);
output
<<
";"
<<
endl
;
}
}
}
...
...
@@ -438,7 +493,6 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
switch
(
symbol_table
.
getType
(
it
->
first
))
{
case
eParameter
:
output
<<
"M_.params"
;
break
;
case
eEndogenous
:
output
<<
"oo_.steady_state"
;
...
...
@@ -453,9 +507,47 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
cerr
<<
"ERROR: Unsupported variable type for "
<<
symbol_table
.
getName
(
it
->
first
)
<<
" in load_params_and_steady_state"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
int
tsid
=
symbol_table
.
getTypeSpecificID
(
it
->
first
)
+
1
;
switch
(
symbol_table
.
getType
(
it
->
first
))
{
case
eParameter
:
break
;
default:
output
<<
"("
<<
tsid
<<
") = "
<<
it
->
second
<<
";"
<<
endl
;
}
}
}
void
LoadParamsAndSteadyStateStatement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
for
(
map
<
int
,
string
>::
const_iterator
it
=
content
.
begin
();
it
!=
content
.
end
();
it
++
)
{
switch
(
symbol_table
.
getType
(
it
->
first
))
{
case
eParameter
:
output
<<
"M_.params"
;
break
;
case
eEndogenous
:
case
eExogenous
:
case
eExogenousDet
:
break
;
default:
cerr
<<
"ERROR: Unsupported variable type for "
<<
symbol_table
.
getName
(
it
->
first
)
<<
" in load_params_and_steady_state"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
int
tsid
=
symbol_table
.
getTypeSpecificID
(
it
->
first
)
+
1
;
output
<<
"("
<<
tsid
<<
") = "
<<
it
->
second
<<
";"
<<
endl
;
switch
(
symbol_table
.
getType
(
it
->
first
))
{
case
eParameter
:
output
<<
"("
<<
tsid
<<
") = "
<<
it
->
second
<<
";"
<<
endl
;
break
;
default:
break
;
}
}
}
...
...
preprocessor/NumericalInitialization.hh
View file @
6d114289
...
...
@@ -41,6 +41,7 @@ public:
const
SymbolTable
&
symbol_table_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
//! Fill eval context with parameter value
void
fillEvalContext
(
eval_context_t
&
eval_context
)
const
;
...
...
@@ -111,6 +112,7 @@ public:
//! Workaround for trac ticket #157
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
};
class
InitvalFileStatement
:
public
Statement
...
...
@@ -167,6 +169,7 @@ public:
const
SymbolTable
&
symbol_table_arg
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
//! Fill eval context with parameters/variables values
void
fillEvalContext
(
eval_context_t
&
eval_context
)
const
;
};
...
...
preprocessor/Shocks.cc
View file @
6d114289
...
...
@@ -84,6 +84,11 @@ ShocksStatement::ShocksStatement(bool overwrite_arg,
void
ShocksStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
{
}
void
ShocksStatement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
output
<<
"%"
<<
endl
<<
"% SHOCKS instructions"
<<
endl
...
...
preprocessor/Shocks.hh
View file @
6d114289
...
...
@@ -78,6 +78,7 @@ public:
const
covar_and_corr_shocks_t
&
corr_shocks_arg
,
const
SymbolTable
&
symbol_table_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
};
...
...
preprocessor/SigmaeInitialization.cc
View file @
6d114289
...
...
@@ -60,6 +60,11 @@ SigmaeStatement::determineMatrixForm(const matrix_t &matrix) throw (MatrixFormEx
void
SigmaeStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
{
}
void
SigmaeStatement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
size_t
ic
,
ic1
,
ir
,
ir1
;
...
...
preprocessor/SigmaeInitialization.hh
View file @
6d114289
...
...
@@ -58,6 +58,7 @@ private:
public:
SigmaeStatement
(
const
matrix_t
&
matrix_arg
)
throw
(
MatrixFormException
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
};
#endif
preprocessor/Statement.cc
View file @
6d114289
...
...
@@ -64,6 +64,11 @@ Statement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &wa
{
}
void
Statement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
}
void
Statement
::
writeCOutput
(
ostream
&
output
,
const
string
&
basename
)
{
...
...
@@ -92,6 +97,12 @@ NativeStatement::writeOutput(ostream &output, const string &basename, bool minim
output
<<
ns
<<
endl
;
}
void
NativeStatement
::
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
{
writeOutput
(
output
,
basename
,
minimal_workspace
);
}
VerbatimStatement
::
VerbatimStatement
(
const
string
&
verbatim_statement_arg
)
:
verbatim_statement
(
verbatim_statement_arg
)
{
...
...
preprocessor/Statement.hh
View file @
6d114289
...
...
@@ -137,6 +137,7 @@ public:
\param basename is the name of the modfile (without extension) which can be used to build auxiliary files
*/
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
=
0
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
};
...
...
@@ -147,6 +148,7 @@ private:
public:
NativeStatement
(
const
string
&
native_statement_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeM_Output
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
);
};
class
VerbatimStatement
:
public
Statement
...
...
preprocessor/StaticModel.cc
View file @
6d114289
...
...
@@ -1601,7 +1601,7 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const
}
void
StaticModel
::
writeOutput
(
ostream
&
output
,
bool
block
)
const
StaticModel
::
write
M_
Output
(
ostream
&
output
,
bool
block
)
const
{
if
(
!
block
)
return
;
...
...
preprocessor/StaticModel.hh
View file @
6d114289
/*
* Copyright (C) 2003-201
2
Dynare Team
* Copyright (C) 2003-201
5
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -152,7 +152,7 @@ public:
StaticModel
(
SymbolTable
&
symbol_table_arg
,
NumericalConstants
&
num_constants
,
ExternalFunctionsTable
&
external_functions_table_arg
);
//! Writes information on block decomposition when relevant
void
writeOutput
(
ostream
&
output
,
bool
block
)
const
;
void
write
M_
Output
(
ostream
&
output
,
bool
block
)
const
;
//! Execute computations (variable sorting + derivation)
/*!
...
...
preprocessor/SymbolTable.cc
View file @
6d114289
...
...
@@ -172,6 +172,32 @@ SymbolTable::getID(SymbolType type, int tsid) const throw (UnknownTypeSpecificID
void
SymbolTable
::
writeOutput
(
ostream
&
output
)
const
throw
(
NotYetFrozenException
)
{
if
(
param_nbr
()
>
0
)
for
(
int
id
=
1
;
id
<
param_nbr
();
id
++
)
if
(
getName
(
param_ids
[
id
])
==
"dsge_prior_weight"
)
output
<<
"options_.dsge_var = 1;"
<<
endl
;
if
(
observedVariablesNbr
()
>
0
)
{
int
ic
=
1
;
output
<<
"options_.varobs = cell(1);"
<<
endl
;
for
(
vector
<
int
>::
const_iterator
it
=
varobs
.
begin
();
it
!=
varobs
.
end
();
it
++
)
{
output
<<
"options_.varobs("
<<
ic
<<
") = {'"
<<
getName
(
*
it
)
<<
"'};"
<<
endl
;
ic
++
;
}
output
<<
"options_.varobs_id = [ "
;
for
(
vector
<
int
>::
const_iterator
it
=
varobs
.
begin
();
it
!=
varobs
.
end
();
it
++
)
output
<<
getTypeSpecificID
(
*
it
)
+
1
<<
" "
;
output
<<
" ];"
<<
endl
;
}
}
void
SymbolTable
::
writeM_Output
(
ostream
&
output
)
const
throw
(
NotYetFrozenException
)
{
if
(
!
frozen
)
throw
NotYetFrozenException
();
...
...
@@ -218,14 +244,9 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
output
<<
"M_.param_names_tex = '"
<<
getTeXName
(
param_ids
[
0
])
<<
"';"
<<
endl
;
output
<<
"M_.param_names_long = '"
<<
getLongName
(
param_ids
[
0
])
<<
"';"
<<
endl
;
for
(
int
id
=
1
;
id
<
param_nbr
();
id
++
)
{
output
<<
"M_.param_names = char(M_.param_names, '"
<<
getName
(
param_ids
[
id
])
<<
"');"
<<
endl
<<
"M_.param_names_tex = char(M_.param_names_tex, '"
<<
getTeXName
(
param_ids
[
id
])
<<
"');"
<<
endl
<<
"M_.param_names_long = char(M_.param_names_long, '"
<<
getLongName
(
param_ids
[
id
])
<<
"');"
<<
endl
;
if
(
getName
(
param_ids
[
id
])
==
"dsge_prior_weight"
)
output
<<
"options_.dsge_var = 1;"
<<
endl
;
}
output
<<
"M_.param_names = char(M_.param_names, '"
<<
getName
(
param_ids
[
id
])
<<
"');"
<<
endl
<<
"M_.param_names_tex = char(M_.param_names_tex, '"
<<
getTeXName
(
param_ids
[
id
])
<<
"');"
<<
endl
<<
"M_.param_names_long = char(M_.param_names_long, '"
<<
getLongName
(
param_ids
[
id
])
<<
"');"
<<
endl
;
}
output
<<
"M_.exo_det_nbr = "
<<
exo_det_nbr
()
<<
";"
<<
endl
...
...
@@ -276,23 +297,6 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
output
<<
getTypeSpecificID
(
*
it
)
+
1
<<
" "
;
output
<<
"];"
<<
endl
;
}