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
Dynare
dynare
Commits
28ffa9c5
Commit
28ffa9c5
authored
May 28, 2015
by
Houtan Bastani
Browse files
Merge branch 'rmExtraExo'
parents
60b3577a
61ffed3e
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
preprocessor/ComputingTasks.cc
View file @
28ffa9c5
This diff is collapsed.
Click to expand it.
preprocessor/ComputingTasks.hh
View file @
28ffa9c5
...
...
@@ -97,6 +97,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
ForecastStatement
:
public
Statement
...
...
@@ -108,6 +109,7 @@ public:
ForecastStatement
(
const
SymbolList
&
symbol_list_arg
,
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
RamseyModelStatement
:
public
Statement
...
...
@@ -120,6 +122,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
RamseyPolicyStatement
:
public
Statement
...
...
@@ -132,6 +135,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
DiscretionaryPolicyStatement
:
public
Statement
...
...
@@ -144,6 +148,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
RplotStatement
:
public
Statement
...
...
@@ -153,6 +158,7 @@ private:
public:
RplotStatement
(
const
SymbolList
&
symbol_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
UnitRootVarsStatement
:
public
Statement
...
...
@@ -191,6 +197,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
DynareSensitivityStatement
:
public
Statement
...
...
@@ -201,6 +208,7 @@ public:
DynareSensitivityStatement
(
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
ObservationTrendsStatement
:
public
Statement
...
...
@@ -214,6 +222,7 @@ public:
ObservationTrendsStatement
(
const
trend_elements_t
&
trend_elements_arg
,
const
SymbolTable
&
symbol_table_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
OsrParamsStatement
:
public
Statement
...
...
@@ -224,6 +233,7 @@ public:
OsrParamsStatement
(
const
SymbolList
&
symbol_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
OsrStatement
:
public
Statement
...
...
@@ -236,6 +246,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
DynaTypeStatement
:
public
Statement
...
...
@@ -247,6 +258,7 @@ public:
DynaTypeStatement
(
const
SymbolList
&
symbol_list_arg
,
const
string
&
filename_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
DynaSaveStatement
:
public
Statement
...
...
@@ -258,6 +270,7 @@ public:
DynaSaveStatement
(
const
SymbolList
&
symbol_list_arg
,
const
string
&
filename_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
ModelComparisonStatement
:
public
Statement
...
...
@@ -310,6 +323,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
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
EstimatedParamsInitStatement
:
public
Statement
...
...
@@ -324,6 +338,7 @@ public:
const
bool
use_calibration_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
EstimatedParamsBoundsStatement
:
public
Statement
...
...
@@ -335,6 +350,7 @@ public:
EstimatedParamsBoundsStatement
(
const
vector
<
EstimationParams
>
&
estim_params_list_arg
,
const
SymbolTable
&
symbol_table_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
OptimWeightsStatement
:
public
Statement
...
...
@@ -352,6 +368,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
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
/*! \todo Make model_tree a member instead of a pointer */
...
...
@@ -373,6 +390,7 @@ public:
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
//! Return the Planner Objective
StaticModel
*
getPlannerObjective
()
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
BVARDensityStatement
:
public
Statement
...
...
@@ -457,6 +475,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
MSSBVARForecastStatement
:
public
Statement
...
...
@@ -525,6 +544,7 @@ public:
ShockDecompositionStatement
(
const
SymbolList
&
symbol_list_arg
,
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
ConditionalForecastStatement
:
public
Statement
...
...
@@ -534,6 +554,7 @@ private:
public:
ConditionalForecastStatement
(
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
PlotConditionalForecastStatement
:
public
Statement
...
...
@@ -545,6 +566,7 @@ private:
public:
PlotConditionalForecastStatement
(
int
periods_arg
,
const
SymbolList
&
symbol_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
CalibSmootherStatement
:
public
Statement
...
...
@@ -557,6 +579,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
ExtendedPathStatement
:
public
Statement
...
...
@@ -734,6 +757,7 @@ public:
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
StdPriorStatement
:
public
BasicPriorStatement
...
...
@@ -749,6 +773,7 @@ public:
const
SymbolTable
&
symbol_table_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
CorrPriorStatement
:
public
BasicPriorStatement
...
...
@@ -767,6 +792,7 @@ public:
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
PriorEqualStatement
:
public
Statement
...
...
@@ -794,6 +820,7 @@ public:
void
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
;
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
BasicOptionsStatement
:
public
Statement
...
...
@@ -824,6 +851,7 @@ public:
OptionsStatement
(
const
string
&
name_arg
,
const
string
&
subsample_name_arg
,
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
StdOptionsStatement
:
public
BasicOptionsStatement
...
...
@@ -837,6 +865,7 @@ public:
const
SymbolTable
&
symbol_table_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
CorrOptionsStatement
:
public
BasicOptionsStatement
...
...
@@ -852,6 +881,7 @@ public:
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
void
writeCOutput
(
ostream
&
output
,
const
string
&
basename
);
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
OptionsEqualStatement
:
public
Statement
...
...
@@ -879,6 +909,7 @@ public:
void
get_base_name
(
const
SymbolType
symb_type
,
string
&
lhs_field
)
const
;
virtual
void
checkPass
(
ModFileStructure
&
mod_file_struct
,
WarningConsolidation
&
warnings
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
class
ModelDiagnosticsStatement
:
public
Statement
...
...
@@ -895,6 +926,7 @@ private:
public:
Smoother2histvalStatement
(
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
virtual
Statement
*
cloneAndReindexSymbIds
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
);
};
#endif
preprocessor/DataTree.cc
View file @
28ffa9c5
/*
* Copyright (C) 2003-201
4
Dynare Team
* Copyright (C) 2003-201
5
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -50,6 +50,31 @@ DataTree::~DataTree()
delete
*
it
;
}
void
DataTree
::
reindex
(
SymbolTable
&
orig_symbol_table
)
{
variable_node_map
.
clear
();
unary_op_node_map
.
clear
();
binary_op_node_map
.
clear
();
trinary_op_node_map
.
clear
();
external_function_node_map
.
clear
();
first_deriv_external_function_node_map
.
clear
();
second_deriv_external_function_node_map
.
clear
();
reindexLocalVars
(
orig_symbol_table
);
}
void
DataTree
::
reindexLocalVars
(
SymbolTable
&
orig_symbol_table
)
{
map
<
int
,
expr_t
>
orig_local_variables_table
=
local_variables_table
;
local_variables_table
.
clear
();
for
(
map
<
int
,
expr_t
>::
const_iterator
it
=
orig_local_variables_table
.
begin
();
it
!=
orig_local_variables_table
.
end
();
it
++
)
AddLocalVariable
(
symbol_table
.
getID
(
orig_symbol_table
.
getName
(
it
->
first
)),
it
->
second
->
cloneDynamicReindex
(
*
this
,
orig_symbol_table
));
}
expr_t
DataTree
::
AddNonNegativeConstant
(
const
string
&
value
)
{
...
...
preprocessor/DataTree.hh
View file @
28ffa9c5
/*
* Copyright (C) 2003-201
4
Dynare Team
* Copyright (C) 2003-201
5
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -233,10 +233,13 @@ public:
//! Returns the minimum lag (as a negative number) of the given symbol in the whole data tree (and not only in the equations !!)
/*! Returns 0 if the symbol is not used */
int
minLagForSymbol
(
int
symb_id
)
const
;
inline
SymbolTable
*
getSymbolTable
()
const
{
return
&
symbol_table
;
};
//! Write the Header for getPowerDeriv when use_dll is used
void
writePowerDerivCHeader
(
ostream
&
output
)
const
;
//! Write getPowerDeriv
void
writePowerDeriv
(
ostream
&
output
,
bool
use_dll
)
const
;
void
reindex
(
SymbolTable
&
orig_symbol_table
);
void
reindexLocalVars
(
SymbolTable
&
orig_symbol_table
);
//! Thrown when trying to access an unknown variable by deriv_id
class
UnknownDerivIDException
{
...
...
preprocessor/DynamicModel.cc
View file @
28ffa9c5
...
...
@@ -4202,6 +4202,23 @@ DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno)
static_only_equations_lineno
.
push_back
(
lineno
);
}
void
DynamicModel
::
reindex
(
SymbolTable
&
orig_symbol_table
)
{
ModelTree
::
reindex
(
orig_symbol_table
);
reindexStaticOnlyEquations
(
orig_symbol_table
);
}
void
DynamicModel
::
reindexStaticOnlyEquations
(
SymbolTable
&
orig_symbol_table
)
{
vector
<
BinaryOpNode
*>
eqbak
=
static_only_equations
;
static_only_equations
.
clear
();
for
(
size_t
i
=
0
;
i
<
eqbak
.
size
();
i
++
)
addStaticOnlyEquation
(
eqbak
[
i
]
->
cloneDynamicReindex
(
*
this
,
orig_symbol_table
),
static_only_equations_lineno
[
i
]);
}
size_t
DynamicModel
::
staticOnlyEquationsNbr
()
const
{
...
...
preprocessor/DynamicModel.hh
View file @
28ffa9c5
...
...
@@ -244,9 +244,15 @@ public:
//! Adds an equation marked as [static]
void
addStaticOnlyEquation
(
expr_t
eq
,
int
lineno
);
//! reindex Dynamic Model after removal of extra exogenous
void
reindex
(
SymbolTable
&
orig_symbol_table
);
//! reindex equations marked as [static]
void
reindexStaticOnlyEquations
(
SymbolTable
&
orig_symbol_table
);
//! Returns number of static only equations
size_t
staticOnlyEquationsNbr
()
const
;
//! Returns number of dynamic only equations
size_t
dynamicOnlyEquationsNbr
()
const
;
...
...
preprocessor/ExprNode.cc
View file @
28ffa9c5
...
...
@@ -360,6 +360,12 @@ NumConstNode::cloneDynamic(DataTree &dynamic_datatree) const
return
dynamic_datatree
.
AddNonNegativeConstant
(
datatree
.
num_constants
.
get
(
id
));
}
expr_t
NumConstNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
return
dynamic_datatree
.
AddNonNegativeConstant
(
datatree
.
num_constants
.
get
(
id
));
}
int
NumConstNode
::
maxEndoLead
()
const
{
...
...
@@ -1000,6 +1006,12 @@ VariableNode::cloneDynamic(DataTree &dynamic_datatree) const
return
dynamic_datatree
.
AddVariable
(
symb_id
,
lag
);
}
expr_t
VariableNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
return
dynamic_datatree
.
AddVariable
(
dynamic_datatree
.
symbol_table
.
getID
(
orig_symbol_table
.
getName
(
symb_id
)),
lag
);
}
int
VariableNode
::
maxEndoLead
()
const
{
...
...
@@ -2252,6 +2264,13 @@ UnaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const
return
buildSimilarUnaryOpNode
(
substarg
,
dynamic_datatree
);
}
expr_t
UnaryOpNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
expr_t
substarg
=
arg
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
);
return
buildSimilarUnaryOpNode
(
substarg
,
dynamic_datatree
);
}
int
UnaryOpNode
::
maxEndoLead
()
const
{
...
...
@@ -3477,6 +3496,14 @@ BinaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const
return
buildSimilarBinaryOpNode
(
substarg1
,
substarg2
,
dynamic_datatree
);
}
expr_t
BinaryOpNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
expr_t
substarg1
=
arg1
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
);
expr_t
substarg2
=
arg2
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
);
return
buildSimilarBinaryOpNode
(
substarg1
,
substarg2
,
dynamic_datatree
);
}
int
BinaryOpNode
::
maxEndoLead
()
const
{
...
...
@@ -4153,6 +4180,15 @@ TrinaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const
return
buildSimilarTrinaryOpNode
(
substarg1
,
substarg2
,
substarg3
,
dynamic_datatree
);
}
expr_t
TrinaryOpNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
expr_t
substarg1
=
arg1
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
);
expr_t
substarg2
=
arg2
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
);
expr_t
substarg3
=
arg3
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
);
return
buildSimilarTrinaryOpNode
(
substarg1
,
substarg2
,
substarg3
,
dynamic_datatree
);
}
int
TrinaryOpNode
::
maxEndoLead
()
const
{
...
...
@@ -4925,6 +4961,17 @@ ExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
return
dynamic_datatree
.
AddExternalFunction
(
symb_id
,
dynamic_arguments
);
}
expr_t
ExternalFunctionNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
vector
<
expr_t
>
dynamic_arguments
;
for
(
vector
<
expr_t
>::
const_iterator
it
=
arguments
.
begin
();
it
!=
arguments
.
end
();
it
++
)
dynamic_arguments
.
push_back
((
*
it
)
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
));
return
dynamic_datatree
.
AddExternalFunction
(
dynamic_datatree
.
symbol_table
.
getID
(
orig_symbol_table
.
getName
(
symb_id
)),
dynamic_arguments
);
}
expr_t
ExternalFunctionNode
::
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
{
...
...
@@ -5220,6 +5267,18 @@ FirstDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
inputIndex
);
}
expr_t
FirstDerivExternalFunctionNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
vector
<
expr_t
>
dynamic_arguments
;
for
(
vector
<
expr_t
>::
const_iterator
it
=
arguments
.
begin
();
it
!=
arguments
.
end
();
it
++
)
dynamic_arguments
.
push_back
((
*
it
)
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
));
return
dynamic_datatree
.
AddFirstDerivExternalFunction
(
dynamic_datatree
.
symbol_table
.
getID
(
orig_symbol_table
.
getName
(
symb_id
)),
dynamic_arguments
,
inputIndex
);
}
expr_t
FirstDerivExternalFunctionNode
::
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
{
...
...
@@ -5455,6 +5514,18 @@ SecondDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
inputIndex1
,
inputIndex2
);
}
expr_t
SecondDerivExternalFunctionNode
::
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
{
vector
<
expr_t
>
dynamic_arguments
;
for
(
vector
<
expr_t
>::
const_iterator
it
=
arguments
.
begin
();
it
!=
arguments
.
end
();
it
++
)
dynamic_arguments
.
push_back
((
*
it
)
->
cloneDynamicReindex
(
dynamic_datatree
,
orig_symbol_table
));
return
dynamic_datatree
.
AddSecondDerivExternalFunction
(
dynamic_datatree
.
symbol_table
.
getID
(
orig_symbol_table
.
getName
(
symb_id
)),
dynamic_arguments
,
inputIndex1
,
inputIndex2
);
}
expr_t
SecondDerivExternalFunctionNode
::
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
{
...
...
preprocessor/ExprNode.hh
View file @
28ffa9c5
...
...
@@ -410,6 +410,9 @@ public:
//! Add ExprNodes to the provided datatree
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
=
0
;
//! Add ExprNodes to the provided datatree, changing the symbol id from those provided in orig_symbol_table
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
=
0
;
//! Move a trend variable with lag/lead to time t by dividing/multiplying by its growth factor
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
=
0
;
...
...
@@ -471,6 +474,7 @@ public:
virtual
expr_t
replaceTrendVar
()
const
;
virtual
expr_t
detrend
(
int
symb_id
,
bool
log_trend
,
expr_t
trend
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
;
virtual
bool
isInStaticForm
()
const
;
};
...
...
@@ -534,6 +538,7 @@ public:
virtual
expr_t
replaceTrendVar
()
const
;
virtual
expr_t
detrend
(
int
symb_id
,
bool
log_trend
,
expr_t
trend
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
;
virtual
bool
isInStaticForm
()
const
;
};
...
...
@@ -612,6 +617,7 @@ public:
virtual
expr_t
replaceTrendVar
()
const
;
virtual
expr_t
detrend
(
int
symb_id
,
bool
log_trend
,
expr_t
trend
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
;
virtual
bool
isInStaticForm
()
const
;
};
...
...
@@ -703,6 +709,7 @@ public:
virtual
expr_t
replaceTrendVar
()
const
;
virtual
expr_t
detrend
(
int
symb_id
,
bool
log_trend
,
expr_t
trend
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
;
//! Function to write out the oPowerNode in expr_t terms as opposed to writing out the function itself
expr_t
unpackPowerDeriv
()
const
;
...
...
@@ -774,6 +781,7 @@ public:
virtual
expr_t
replaceTrendVar
()
const
;
virtual
expr_t
detrend
(
int
symb_id
,
bool
log_trend
,
expr_t
trend
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
;
virtual
bool
isInStaticForm
()
const
;
};
...
...
@@ -850,6 +858,7 @@ public:
virtual
expr_t
replaceTrendVar
()
const
;
virtual
expr_t
detrend
(
int
symb_id
,
bool
log_trend
,
expr_t
trend
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
=
0
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
=
0
;
virtual
expr_t
removeTrendLeadLag
(
map
<
int
,
expr_t
>
trend_symbols_map
)
const
;
virtual
bool
isInStaticForm
()
const
;
};
...
...
@@ -880,6 +889,7 @@ public:
virtual
expr_t
toStatic
(
DataTree
&
static_datatree
)
const
;
virtual
expr_t
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
};
class
FirstDerivExternalFunctionNode
:
public
AbstractExternalFunctionNode
...
...
@@ -914,6 +924,7 @@ public:
virtual
expr_t
toStatic
(
DataTree
&
static_datatree
)
const
;
virtual
expr_t
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
};
class
SecondDerivExternalFunctionNode
:
public
AbstractExternalFunctionNode
...
...
@@ -950,6 +961,7 @@ public:
virtual
expr_t
toStatic
(
DataTree
&
static_datatree
)
const
;
virtual
expr_t
buildSimilarExternalFunctionNode
(
vector
<
expr_t
>
&
alt_args
,
DataTree
&
alt_datatree
)
const
;
virtual
expr_t
cloneDynamic
(
DataTree
&
dynamic_datatree
)
const
;
virtual
expr_t
cloneDynamicReindex
(
DataTree
&
dynamic_datatree
,
SymbolTable
&
orig_symbol_table
)
const
;
};
#endif
preprocessor/ExternalFunctionsTable.cc
View file @
28ffa9c5
/*
* Copyright (C) 2010-201
1
Dynare Team
* Copyright (C) 2010-201
5
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -24,7 +24,6 @@
#include
<iostream>
#include
"ExternalFunctionsTable.hh"
#include
"SymbolTable.hh"
ExternalFunctionsTable
::
ExternalFunctionsTable
()
{
...
...
@@ -115,3 +114,44 @@ ExternalFunctionsTable::addExternalFunction(int symb_id, const external_function
externalFunctionTable
[
symb_id
]
=
external_function_options_chng
;
}
void
ExternalFunctionsTable
::
reindex
(
SymbolTable
&
new_symbol_table
,
SymbolTable
&
orig_symbol_table
)
{
external_function_table_type
orig_externalFunctionTable
=
externalFunctionTable
;
externalFunctionTable
.
clear
();
for
(
external_function_table_type
::
const_iterator
it
=
orig_externalFunctionTable
.
begin
();
it
!=
orig_externalFunctionTable
.
end
();
it
++
)
try
{
external_function_options
new_external_function_options
;
if
(
it
->
second
.
firstDerivSymbID
==
eExtFunNotSet
||
it
->
second
.
firstDerivSymbID
==
eExtFunSetButNoNameProvided
)
new_external_function_options
.
firstDerivSymbID
=
it
->
second
.
firstDerivSymbID
;
else
new_external_function_options
.
firstDerivSymbID
=
new_symbol_table
.
getID
(
orig_symbol_table
.
getName
(
it
->
second
.
firstDerivSymbID
));
if
(
it
->
second
.
secondDerivSymbID
==
eExtFunNotSet
||
it
->
second
.
secondDerivSymbID
==
eExtFunSetButNoNameProvided
)
new_external_function_options
.
secondDerivSymbID
=
it
->
second
.
secondDerivSymbID
;
else
new_external_function_options
.
secondDerivSymbID
=
new_symbol_table
.
getID
(
orig_symbol_table
.
getName
(
it
->
second
.
secondDerivSymbID
));
new_external_function_options
.
nargs
=
it
->
second
.
nargs
;
bool
new_track_nargs
=
true
;
if
(
it
->
second
.
nargs
==
eExtFunNotSet
)
{
new_track_nargs
=
false
;
new_external_function_options
.
nargs
=
eExtFunSetDefaultNargs
;
}
addExternalFunction
(
new_symbol_table
.
getID
(
orig_symbol_table
.
getName
(
it
->
first
)),
new_external_function_options
,
new_track_nargs
);
}
catch
(...)
{
cerr
<<
"Error: problem encountered when reindexing external functions table."
<<
endl
;