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
d6155b1e
Commit
d6155b1e
authored
Jan 04, 2012
by
Stéphane Adjemian
Browse files
Merge branch 'master' of kirikou.dynare.org:/srv/d_kirikou/git/dynare
parents
7b856645
0b64c61f
Changes
30
Hide whitespace changes
Inline
Side-by-side
doc/dynare.texi
View file @
d6155b1e
...
...
@@ -6075,7 +6075,7 @@ line. The main directives are:
@item
@code{@@#define}, for defining a macro-processor variable,
@item
@code{@@#if}, @code{@@#
then
}, @code{@@#else}, @code{@@#endif} for
@code{@@#if}, @code{@@#
ifdef
}, @code{@@#else}, @code{@@#endif} for
conditional statements,
@item
@code{@@#for}, @code{@@#endfor} for constructing loops.
...
...
@@ -6218,13 +6218,15 @@ end;
@end deffn
@deffn {Macro directive} @@#if @var{MACRO_EXPRESSION}
@deffnx {Macro directive} @@#ifdef @var{MACRO_VARIABLE}
@deffnx {Macro directive} @@#else
@deffnx {Macro directive} @@#endif
Conditional inclusion of some part of the @file{.mod} file.
The lines between @code{@@#if} and the next @code{@@#else} or
@code{@@#end} is executed only if the condition evaluates to a
non-null integer. The @code{@@#else} branch is optional and, if
present, is only evaluated if the condition evaluates to @code{0}.
The lines between @code{@@#if} or @code{@@#ifdef} and the next
@code{@@#else} or @code{@@#endif} is executed only if the condition
evaluates to a non-null integer. The @code{@@#else} branch is optional
and, if present, is only evaluated if the condition evaluates to
@code{0}.
@examplehead
...
...
@@ -6242,6 +6244,23 @@ model;
end;
@end example
@examplehead
Choose between two alternative monetary policy rules using a
macro-variable. As @code{linear_mon_pol} was not previously defined in
this example, the second equation will be chosen:
@example
model;
@@#ifdef linear_mon_pol
i = w*i(-1) + (1-w)*i_ss + w2*(pie-piestar);
@@#else
i = i(-1)^w * i_ss^(1-w) * (pie/piestar)^w2;
@@#endif
...
end;
@end example
@end deffn
@deffn {Macro directive} @@#for @var{MACRO_VARIABLE} in @var{MACRO_EXPRESSION}
...
...
doc/macroprocessor/macroprocessor.tex
View file @
d6155b1e
...
...
@@ -65,7 +65,7 @@
\begin{itemize}
\item
file inclusion
\item
loops (
\textit
{
for
}
structure)
\item
conditional inclusion (
\textit
{
if/
then/
else
}
structures)
\item
conditional inclusion (
\textit
{
if/else
}
structures)
\item
expression substitution
\end{itemize}
\item
Implemented in Dynare starting from version 4.0
...
...
@@ -95,7 +95,7 @@
\begin{itemize}
\item
file inclusion:
\verb
+
@#include
+
\item
definition a variable of the macro-processor:
\verb
+
@#define
+
\item
conditional statements (
\verb
+
@#if/@#
then/@#
else/@#endif
+
)
\item
conditional statements (
\verb
+
@#if/@#else/@#endif
+
)
\item
loop statements (
\verb
+
@#for/@#endfor
+
)
\end{itemize}
\item
In most cases, directives occupy exactly one line of text. In case of need, two anti-slashes (
\verb
+
\\
+
) at the end of the line indicates that the directive is continued on the next line.
...
...
matlab/distributions/inverse_gamma_specification.m
View file @
d6155b1e
...
...
@@ -99,7 +99,7 @@ elseif type == 1; % Inverse Gamma 1
end
end
%
Solve
for
nu
using
the
secant
method
.
while
abs
(
nu2
-
nu1
)
>
1e-
8
while
abs
(
nu2
/
nu1
-
1
)
>
1e-
14
if
err
>
0
nu1
=
nu
;
if
nu
<
nu2
...
...
@@ -117,10 +117,10 @@ elseif type == 1; % Inverse Gamma 1
end
s
=
(
sigma2
+
mu2
)
*
(
nu
-
2
);
if
check_solution_flag
if
abs
(
mu
-
sqrt
(
s
/
2
)
*
gamma
((
nu
-
1
)
/
2
)
/
gamma
(
nu
/
2
))
>
1e-
9
if
abs
(
log
(
mu
)
-
log
(
sqrt
(
s
/
2
)
)
-
gamma
ln
((
nu
-
1
)
/
2
)
+
gamma
ln
(
nu
/
2
))
>
1e-
7
error
(
'
inverse_gamma_specification
::
Failed
in
solving
for
the
hyperparameters
!
'
);
end
if
abs
(
sigma
-
sqrt
(
s
/
(
nu
-
2
)
-
mu
^
2
))
>
1e-
9
if
abs
(
sigma
-
sqrt
(
s
/
(
nu
-
2
)
-
mu
^
2
))
>
1e-
7
error
(
'
inverse_gamma_specification
::
Failed
in
solving
for
the
hyperparameters
!
'
);
end
end
...
...
matlab/dyn_forecast.m
View file @
d6155b1e
...
...
@@ -61,10 +61,10 @@ switch task
if
horizon
==
0
horizon
=
5
;
end
if
size
(
oo_
.
endo_simul
,
2
)
<
maximum_lag
if
isempty
(
M_
.
endo_histval
)
y0
=
repmat
(
oo_
.
steady_state
,
1
,
maximum_lag
);
else
y0
=
oo
_
.
endo_
simul
(:,
1
:
maximum_lag
)
;
y0
=
M
_
.
endo_
histval
;
end
case
'smoother'
horizon
=
options_
.
forecast
;
...
...
matlab/global_initialization.m
View file @
d6155b1e
...
...
@@ -56,7 +56,6 @@ options_.lyapunov_complex_threshold = 1e-15;
options_
.
solve_tolf
=
eps
^
(
1
/
3
);
options_
.
solve_tolx
=
eps
^
(
2
/
3
);
options_
.
solve_maxit
=
500
;
options_
.
deterministic_simulation_initialization
=
0
;
% Default number of threads for parallelized mex files.
options_
.
threads
.
kronecker
.
A_times_B_kronecker_C
=
1
;
...
...
@@ -333,6 +332,7 @@ oo_.exo_det_steady_state = [];
oo_
.
exo_det_simul
=
[];
M_
.
params
=
[];
M_
.
endo_histval
=
[];
% BVAR
M_
.
bvar
=
[];
...
...
matlab/gsa/skewness.m
→
matlab/gsa/
gsa_
skewness.m
View file @
d6155b1e
function
s
=
skewness
(
y
),
function
s
=
gsa_
skewness
(
y
),
% y=stand_(y);
% s=mean(y.^3);
...
...
matlab/gsa/speed.m
→
matlab/gsa/
gsa_
speed.m
View file @
d6155b1e
function
[
tadj
,
iff
]
=
speed
(
A
,
B
,
mf
,
p
),
% [tadj, iff] = speed(A,B,mf,p),
function
[
tadj
,
iff
]
=
gsa_
speed
(
A
,
B
,
mf
,
p
),
% [tadj, iff] =
gsa_
speed(A,B,mf,p),
%
% Part of the Sensitivity Analysis Toolbox for DYNARE
%
...
...
matlab/gsa/log_trans_.m
View file @
d6155b1e
...
...
@@ -3,10 +3,10 @@ function [yy, xdir, isig, lam]=log_trans_(y0,xdir0)
if
nargin
==
1
,
xdir0
=
''
;
end
f
=
inline
(
'skewness(log(y+lam))'
,
'lam'
,
'y'
);
f
=
inline
(
'
gsa_
skewness(log(y+lam))'
,
'lam'
,
'y'
);
isig
=
1
;
if
~
(
max
(
y0
)
<
0
|
min
(
y0
)
>
0
)
if
skewness
(
y0
)
<
0
,
if
gsa_
skewness
(
y0
)
<
0
,
isig
=-
1
;
y0
=-
y0
;
end
...
...
matlab/gsa/map_ident_.m
View file @
d6155b1e
...
...
@@ -127,7 +127,7 @@ if opt_gsa.load_ident_files==0,
% ino=find(~ismember([1:nr],io));
% T2=A(ino,1:nr,:);
R
=
A
(:,
nr
+
1
:
nc
,:);
% [tadj, iff] = speed(A(1:nr,1:nr,:),R,io,0.5);
% [tadj, iff] =
gsa_
speed(A(1:nr,1:nr,:),R,io,0.5);
% [tadj, j0, ir_tadj, ic_tadj] = teff(tadj,Nsam,istable);
% [iff, j0, ir_if, ic_if] = teff(iff,Nsam,istable);
...
...
matlab/make_y_.m
View file @
d6155b1e
...
...
@@ -35,29 +35,16 @@ if isempty(oo_.steady_state)
oo_
.
steady_state
=
zeros
(
M_
.
endo_nbr
,
1
);
end
if
isempty
(
oo
_
.
endo_
simu
l
)
if
isempty
(
M
_
.
endo_
histva
l
)
if
isempty
(
ys0_
)
oo_
.
endo_simul
=
[
oo_
.
steady_state
*
ones
(
1
,
M_
.
maximum_lag
+
options_
.
periods
+
M_
.
maximum_lead
)];
else
oo_
.
endo_simul
=
[
ys0_
*
ones
(
1
,
M_
.
maximum_lag
)
oo_
.
steady_state
*
ones
(
1
,
options_
.
periods
+
M_
.
maximum_lead
)];
end
elseif
size
(
oo_
.
endo_simul
,
2
)
<
M_
.
maximum_lag
+
M_
.
maximum_lead
+
options_
.
periods
switch
options_
.
deterministic_simulation_initialization
case
0
oo_
.
endo_simul
=
[
oo_
.
endo_simul
...
oo_
.
steady_state
*
ones
(
1
,
M_
.
maximum_lag
+
options_
.
periods
+
M_
.
maximum_lead
-
size
(
oo_
.
endo_simul
,
2
),
1
)];
case
1
% A linear approximation is used to initialize the solution.
oldopt
=
options_
;
options_
.
order
=
1
;
dr
=
oo_
.
dr
;
dr
.
ys
=
oo_
.
steady_state
;
[
dr
,
info
,
M_
,
options_
,
oo_
]
=
dr1
(
dr
,
0
,
M_
,
options_
,
oo_
);
exogenous_variables
=
zeros
(
M_
.
maximum_lag
+
options_
.
periods
+
M_
.
maximum_lead
-
size
(
oo_
.
endo_simul
,
2
)
+
1
,
0
);
y0
=
oo_
.
endo_simul
(:,
1
:
M_
.
maximum_lag
);
oo_
.
endo_simul
=
simult_
(
y0
,
dr
,
exogenous_variables
,
1
);
options_
=
oldopt
;
case
2
% Homotopic mod: Leave endo_simul as it is.
otherwise
error
(
'Unknown method.'
)
else
if
~
isempty
(
ys0_
)
error
(
'histval and endval cannot be used simultaneously'
)
end
end
\ No newline at end of file
oo_
.
endo_simul
=
[
M_
.
endo_histval
...
oo_
.
steady_state
*
ones
(
1
,
options_
.
periods
+
M_
.
maximum_lead
)];
end
matlab/steady.m
View file @
d6155b1e
...
...
@@ -62,13 +62,3 @@ end
disp_steady_state
(
M_
,
oo_
);
M_
.
Sigma_e
=
Sigma_e
;
if
isempty
(
ys0_
)
oo_
.
endo_simul
(:,
1
:
M_
.
maximum_lag
)
=
oo_
.
steady_state
*
ones
(
1
,
M_
.
maximum_lag
);
%%% Unless I'm wrong, this is (should be?) done in make_y_.m
% $$$ else
% $$$ options_ =set_default_option(options_,'periods',1);
% $$$ oo_.endo_simul(:,M_.maximum_lag+1:M_.maximum_lag+options_.periods+ ...
% $$$ M_.maximum_lead) = oo_.steady_state * ones(1,options_.periods+M_.maximum_lead);
end
\ No newline at end of file
matlab/stoch_simul.m
View file @
d6155b1e
...
...
@@ -130,13 +130,10 @@ if options_.periods > 0 && ~PI_PCL_solver
options_
=
options_old
;
return
end
% Note that the first column of oo_.endo_simul is preserved by the following
% call to simult; this is important because stoch_simul can be followed by
% forecast (see ticket #157)
if
size
(
oo_
.
endo_simul
,
2
)
==
0
if
isempty
(
M_
.
endo_histval
)
y0
=
oo_
.
dr
.
ys
;
else
y0
=
oo
_
.
endo_
simul
(:,
1
)
;
y0
=
M
_
.
endo_
histval
;
end
oo_
.
endo_simul
=
simult
(
y0
,
oo_
.
dr
);
dyn2vec
;
...
...
matlab/stoch_simul_sparse.m
View file @
d6155b1e
...
...
@@ -82,10 +82,10 @@ elseif options_.periods ~= 0
options_
=
options_old
;
return
end
if
size
(
oo_
.
endo_simul
,
2
)
<
maximum_lag
if
isempty
(
M_
.
endo_histval
)
y0
=
oo_
.
dr
.
ys
;
else
y0
=
oo
_
.
endo_
simul
(:,
1
)
;
y0
=
M
_
.
endo_
histval
;
end
oo_
.
endo_simul
=
simult
(
y0
,
oo_
.
dr
);
dyn2vec
;
...
...
mex/build/octave/mex.am
View file @
d6155b1e
...
...
@@ -14,10 +14,10 @@ LDFLAGS += $(shell $(MKOCTFILE) -p LDFLAGS)
LIBS += $(shell $(MKOCTFILE) -p OCTAVE_LIBS)
LIBS += $(shell $(MKOCTFILE) -p BLAS_LIBS)
LIBS += $(shell $(MKOCTFILE) -p LAPACK_LIBS)
LIBS += $(shell $(MKOCTFILE) -p FFTW_LIBS)
LIBS += $(shell $(MKOCTFILE) -p LIBS)
LIBS += $(shell $(MKOCTFILE) -p FLIBS)
LIBS += $(shell $(MKOCTFILE) -p CXXLIBS) # Only used for Octave/MinGW
all-local:
$(MKDIR_P) $(top_srcdir)/../../octave
...
...
preprocessor/CodeInterpreter.hh
View file @
d6155b1e
...
...
@@ -234,6 +234,18 @@ enum external_function_type
ExternalFunctionSecondDerivative
};
enum
PriorDistributions
{
eNoShape
=
0
,
eBeta
=
1
,
eGamma
=
2
,
eNormal
=
3
,
eInvGamma
=
4
,
eInvGamma1
=
4
,
eUniform
=
5
,
eInvGamma2
=
6
};
struct
Block_contain_type
{
int
Equation
,
Variable
,
Own_Derivative
;
...
...
preprocessor/ComputingTasks.cc
View file @
d6155b1e
...
...
@@ -446,7 +446,7 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct
.
dsge_prior_weight_in_estimated_params
=
true
;
// Handle case of degenerate beta prior
if
(
it
->
prior
==
"1"
)
//BETA_PDF is associated with "1" in DynareBison.yy
if
(
it
->
prior
==
eBeta
)
try
{
if
(
it
->
mean
->
eval
(
eval_context_t
())
==
0.5
...
...
@@ -1358,7 +1358,7 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li
options_list
.
num_options
.
find
(
"ms.number_of_regimes"
);
if
(
it_num_regimes
==
options_list
.
num_options
.
end
())
{
cerr
<<
"ERROR: should not arrive here: MarkovSwitchingStatement
::checkPass
"
<<
endl
;
cerr
<<
"ERROR: should not arrive here: MarkovSwitchingStatement
constructor
"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
int
num_regimes
=
lexical_cast
<
int
>
(
it_num_regimes
->
second
);
...
...
@@ -1655,9 +1655,11 @@ BasicPriorStatement::~BasicPriorStatement()
}
BasicPriorStatement
::
BasicPriorStatement
(
const
string
&
name_arg
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
)
:
name
(
name_arg
),
prior_shape
(
prior_shape_arg
),
variance
(
variance_arg
),
options_list
(
options_list_arg
),
first_statement_encountered
(
false
)
...
...
@@ -1667,11 +1669,12 @@ BasicPriorStatement::BasicPriorStatement(const string &name_arg,
void
BasicPriorStatement
::
checkPass
(
ModFileStructure
&
mod_file_struct
)
{
if
(
options_list
.
num_options
.
find
(
"
shape
"
)
==
options_list
.
num_options
.
end
()
)
if
(
prior_
shape
==
eNoShape
)
{
cerr
<<
"ERROR: You must pass the shape option to the prior statement."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
if
(
options_list
.
num_options
.
find
(
"date1"
)
!=
options_list
.
num_options
.
end
()
||
options_list
.
num_options
.
find
(
"date2"
)
!=
options_list
.
num_options
.
end
())
if
(
options_list
.
num_options
.
find
(
"date1"
)
==
options_list
.
num_options
.
end
()
||
...
...
@@ -1681,6 +1684,19 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct)
<<
"Please inform Dynare Team."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
OptionsList
::
num_options_t
::
const_iterator
it_num
=
options_list
.
num_options
.
find
(
"domain"
);
if
(
it_num
!=
options_list
.
num_options
.
end
())
{
using
namespace
boost
;
vector
<
string
>
tokenizedDomain
;
split
(
tokenizedDomain
,
it_num
->
second
,
is_any_of
(
"[ ]"
),
token_compress_on
);
if
(
tokenizedDomain
.
size
()
!=
4
)
{
cerr
<<
"ERROR: You must pass exactly two values to the domain option."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
}
}
void
...
...
@@ -1715,7 +1731,6 @@ BasicPriorStatement::writeVarianceOption(ostream &output, const string &lhs_fiel
void
BasicPriorStatement
::
writeOutputHelper
(
ostream
&
output
,
const
string
&
field
,
const
string
&
lhs_field
)
const
{
OptionsList
::
num_options_t
::
const_iterator
itn
=
options_list
.
num_options
.
find
(
field
);
if
(
itn
!=
options_list
.
num_options
.
end
())
output
<<
"estimation_info"
<<
lhs_field
<<
"(prior_indx)."
<<
field
...
...
@@ -1727,10 +1742,18 @@ BasicPriorStatement::writeOutputHelper(ostream &output, const string &field, con
<<
" = '"
<<
itd
->
second
<<
"';"
<<
endl
;
}
void
BasicPriorStatement
::
writeShape
(
ostream
&
output
,
const
string
&
lhs_field
)
const
{
assert
(
prior_shape
!=
eNoShape
);
output
<<
"estimation_info"
<<
lhs_field
<<
"(prior_indx).shape = "
<<
prior_shape
<<
";"
<<
endl
;
}
PriorStatement
::
PriorStatement
(
const
string
&
name_arg
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
)
:
BasicPriorStatement
(
name_arg
,
variance_arg
,
options_list_arg
)
BasicPriorStatement
(
name_arg
,
prior_shape_arg
,
variance_arg
,
options_list_arg
)
{
}
...
...
@@ -1748,10 +1771,10 @@ PriorStatement::writeOutput(ostream &output, const string &basename) const
{
string
lhs_field
=
".prior"
;
BasicPriorStatement
::
writePriorIndex
(
output
,
lhs_field
);
writePriorIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(prior_indx) = {'"
<<
name
<<
"'};"
<<
endl
<<
"estimation_info"
<<
lhs_field
<<
"(prior_indx).name = '"
<<
name
<<
"';"
<<
endl
;
writeShape
(
output
,
lhs_field
);
writeOutputHelper
(
output
,
"mean"
,
lhs_field
);
writeOutputHelper
(
output
,
"mode"
,
lhs_field
);
writeOutputHelper
(
output
,
"stdev"
,
lhs_field
);
...
...
@@ -1761,14 +1784,15 @@ PriorStatement::writeOutput(ostream &output, const string &basename) const
writeOutputHelper
(
output
,
"date2"
,
lhs_field
);
writeOutputHelper
(
output
,
"domain"
,
lhs_field
);
writeOutputHelper
(
output
,
"interval"
,
lhs_field
);
BasicPriorStatement
::
writeVarianceOption
(
output
,
lhs_field
);
writeVarianceOption
(
output
,
lhs_field
);
}
StdPriorStatement
::
StdPriorStatement
(
const
string
&
name_arg
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
,
const
SymbolTable
&
symbol_table_arg
)
:
BasicPriorStatement
(
name_arg
,
variance_arg
,
options_list_arg
),
BasicPriorStatement
(
name_arg
,
prior_shape_arg
,
variance_arg
,
options_list_arg
),
symbol_table
(
symbol_table_arg
)
{
}
...
...
@@ -1789,10 +1813,11 @@ StdPriorStatement::writeOutput(ostream &output, const string &basename) const
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
lhs_field
=
"."
+
lhs_field
+
".prior"
;
BasicPriorStatement
::
writePriorIndex
(
output
,
lhs_field
);
writePriorIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(prior_indx) = {'"
<<
name
<<
"'};"
<<
endl
;
output
<<
"estimation_info"
<<
lhs_field
<<
"(prior_indx).name = '"
<<
name
<<
"';"
<<
endl
;
writeShape
(
output
,
lhs_field
);
writeOutputHelper
(
output
,
"mean"
,
lhs_field
);
writeOutputHelper
(
output
,
"mode"
,
lhs_field
);
writeOutputHelper
(
output
,
"stdev"
,
lhs_field
);
...
...
@@ -1800,14 +1825,15 @@ StdPriorStatement::writeOutput(ostream &output, const string &basename) const
writeOutputHelper
(
output
,
"shift"
,
lhs_field
);
writeOutputHelper
(
output
,
"domain"
,
lhs_field
);
writeOutputHelper
(
output
,
"interval"
,
lhs_field
);
BasicPriorStatement
::
writeVarianceOption
(
output
,
lhs_field
);
writeVarianceOption
(
output
,
lhs_field
);
}
CorrPriorStatement
::
CorrPriorStatement
(
const
string
&
name_arg1
,
const
string
&
name_arg2
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
,
const
SymbolTable
&
symbol_table_arg
)
:
BasicPriorStatement
(
name_arg1
,
variance_arg
,
options_list_arg
),
BasicPriorStatement
(
name_arg1
,
prior_shape_arg
,
variance_arg
,
options_list_arg
),
name1
(
name_arg2
),
symbol_table
(
symbol_table_arg
)
{
...
...
@@ -1836,11 +1862,12 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
lhs_field
=
"."
+
lhs_field
+
"_corr.prior"
;
BasicPriorStatement
::
writePriorIndex
(
output
,
lhs_field
);
writePriorIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(prior_indx) = {'"
<<
name
<<
"_"
<<
name1
<<
"'};"
<<
endl
;
output
<<
"estimation_info"
<<
lhs_field
<<
"(prior_indx).name1 = '"
<<
name
<<
"';"
<<
endl
;
output
<<
"estimation_info"
<<
lhs_field
<<
"(prior_indx).name2 = '"
<<
name1
<<
"';"
<<
endl
;
writeShape
(
output
,
lhs_field
);
writeOutputHelper
(
output
,
"mean"
,
lhs_field
);
writeOutputHelper
(
output
,
"mode"
,
lhs_field
);
writeOutputHelper
(
output
,
"stdev"
,
lhs_field
);
...
...
@@ -1848,7 +1875,7 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
writeOutputHelper
(
output
,
"shift"
,
lhs_field
);
writeOutputHelper
(
output
,
"domain"
,
lhs_field
);
writeOutputHelper
(
output
,
"interval"
,
lhs_field
);
BasicPriorStatement
::
writeVarianceOption
(
output
,
lhs_field
);
writeVarianceOption
(
output
,
lhs_field
);
}
BasicOptionsStatement
::~
BasicOptionsStatement
()
...
...
@@ -1929,7 +1956,7 @@ OptionsStatement::writeOutput(ostream &output, const string &basename) const
{
string
lhs_field
=
".options"
;
BasicOptionsStatement
::
writeOptionsIndex
(
output
,
lhs_field
);
writeOptionsIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(options_indx) = {'"
<<
name
<<
"'};"
<<
endl
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name = '"
<<
name
<<
"';"
<<
endl
;
...
...
@@ -1964,7 +1991,7 @@ StdOptionsStatement::writeOutput(ostream &output, const string &basename) const
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
lhs_field
=
"."
+
lhs_field
+
".options"
;
BasicOptionsStatement
::
writeOptionsIndex
(
output
,
lhs_field
);
writeOptionsIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(options_indx) = {'"
<<
name
<<
"'};"
<<
endl
;
output
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name = '"
<<
name
<<
"';"
<<
endl
;
...
...
@@ -2006,7 +2033,7 @@ CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
get_base_name
(
symbol_table
.
getType
(
name
),
lhs_field
);
lhs_field
=
"."
+
lhs_field
+
"_corr.options"
;
BasicOptionsStatement
::
writeOptionsIndex
(
output
,
lhs_field
);
writeOptionsIndex
(
output
,
lhs_field
);
output
<<
"estimation_info"
<<
lhs_field
<<
"_index(options_indx) = {'"
<<
name
<<
"_"
<<
name1
<<
"'};"
<<
endl
;
lhs_field
+=
"."
;
output
<<
"estimation_info"
<<
lhs_field
<<
"(options_indx).name1 = '"
<<
name
<<
"';"
<<
endl
;
...
...
preprocessor/ComputingTasks.hh
View file @
d6155b1e
...
...
@@ -251,7 +251,8 @@ class EstimationParams
{
public:
int
type
;
string
name
,
name2
,
prior
;
string
name
,
name2
;
PriorDistributions
prior
;
expr_t
init_val
,
low_bound
,
up_bound
,
mean
,
std
,
p3
,
p4
,
jscale
;
void
...
...
@@ -260,7 +261,7 @@ public:
type
=
0
;
name
=
""
;
name2
=
""
;
prior
=
"NaN"
;
prior
=
eNoShape
;
init_val
=
datatree
.
NaN
;
low_bound
=
datatree
.
MinusInfinity
;
up_bound
=
datatree
.
Infinity
;
...
...
@@ -583,10 +584,12 @@ public:
virtual
~
BasicPriorStatement
();
protected:
const
string
name
;
const
PriorDistributions
prior_shape
;
const
expr_t
variance
;
const
OptionsList
options_list
;
bool
first_statement_encountered
;
BasicPriorStatement
(
const
string
&
name_arg
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
);
...
...
@@ -594,12 +597,14 @@ protected:
void
writePriorIndex
(
ostream
&
output
,
const
string
&
lhs_field
)
const
;
void
writeVarianceOption
(
ostream
&
output
,
const
string
&
lhs_field
)
const
;
void
writeOutputHelper
(
ostream
&
output
,
const
string
&
field
,
const
string
&
lhs_field
)
const
;
void
writeShape
(
ostream
&
output
,
const
string
&
lhs_field
)
const
;
};
class
PriorStatement
:
public
BasicPriorStatement
{
public:
PriorStatement
(
const
string
&
name_arg
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
);
...
...
@@ -612,6 +617,7 @@ private:
const
SymbolTable
symbol_table
;
public:
StdPriorStatement
(
const
string
&
name_arg
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
,
const
SymbolTable
&
symbol_table_arg
);
...
...
@@ -627,6 +633,7 @@ private:
public:
CorrPriorStatement
(
const
string
&
name_arg1
,
const
string
&
name_arg2
,
const
PriorDistributions
&
prior_shape_arg
,
const
expr_t
&
variance_arg
,
const
OptionsList
&
options_list_arg
,
const
SymbolTable
&
symbol_table_arg
);
...
...
preprocessor/DynareBison.yy
View file @
d6155b1e
...
...
@@ -33,6 +33,7 @@ using namespace std;
class
ParsingDriver
;
#
include
"ExprNode.hh"
#
include
"CodeInterpreter.hh"
/*
Little
hack
:
we
redefine
the
macro
which
computes
the
locations
,
because
we
need
to
access
the
location
from
within
the
parsing
driver
for
error
...
...
@@ -75,6 +76,7 @@ class ParsingDriver;
SymbolType symbol_type_val;
vector<string *> *vector_string_val;
vector<int> *vector_int_val;
PriorDistributions prior_distributions_val;
};
%{
...
...
@@ -175,13 +177,13 @@ class ParsingDriver;
%type <node_val> expression expression_or_empty
%type <node_val> equation hand_side
%type <string_val> non_negative_number signed_number signed_integer date_number
%type <string_val> filename symbol
prior_distribution
vec_of_vec_value vec_value_list
%type <string_val> filename symbol vec_of_vec_value vec_value_list
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
%type <string_val> range
prior_pdf_string
vec_value_w_inf vec_value_1_w_inf
%type <string_val> range vec_value_w_inf vec_value_1_w_inf
%type <symbol_type_val> change_type_arg
%type <vector_string_val> change_type_var_list
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
%type <prior_distributions_val> prior_pdf prior_distribution
%%
%start statement_list;
...
...
@@ -1030,24 +1032,21 @@ estimated_elem1 : STDERR symbol
}
;
estimated_elem2 : prior_pdf
_string
COMMA estimated_elem3
estimated_elem2 : prior_pdf COMMA estimated_elem3
{
driver.estim_params.prior = *$1;
delete $1;
driver.estim_params.prior = $1;
}
| expression_or_empty COMMA prior_pdf
_string
COMMA estimated_elem3
| expression_or_empty COMMA prior_pdf COMMA estimated_elem3
{
driver.estim_params.init_val = $1;
driver.estim_params.prior = *$3;
delete $3;
driver.estim_params.prior = $3;
}
| expression_or_empty COMMA expression_or_empty COMMA expression_or_empty COMMA prior_pdf
_string
COMMA estimated_elem3
| expression_or_empty COMMA expression_or_empty COMMA expression_or_empty COMMA prior_pdf COMMA estimated_elem3
{
driver.estim_params.init_val = $1;
driver.estim_params.low_bound = $3;
driver.estim_params.up_bound = $5;
driver.estim_params.prior = *$7;
delete $7;
driver.estim_params.prior = $7;
}
| expression
{
...
...
@@ -1161,36 +1160,36 @@ estimated_bounds_elem : STDERR symbol COMMA expression COMMA expression ';'
;
prior_distribution : BETA
{ $$ =
new string("1")
; }
{ $$ =
eBeta
; }