Sébastien Villemot
1d71386f01
Further templating of helpers for writing output files
...
So that more stuff is computed at compile-time (using constexpr features).
2022-07-12 16:23:28 +02:00
Sébastien Villemot
9c3eeb7c8d
Refactor code for writing derivatives w.r.t. parameters
2022-07-12 16:18:16 +02:00
Sébastien Villemot
8da663a110
Further factorization in methods for writing static and dynamic files
2022-07-12 16:05:15 +02:00
MichelJuillard
3e1f9dbb82
use @inbounds blocks instead of @inbounds for each line
2022-07-12 13:07:33 +02:00
MichelJuillard
a4556896db
Julia functions Float64 -> <: Real
2022-07-12 11:15:51 +02:00
Sébastien Villemot
5174c3b52c
Minor simplification
2022-07-11 22:30:50 +02:00
Sébastien Villemot
f38c8278ae
Refactor methods for writing static and dynamic files
...
– factorize common code between the static and the dynamic version
– reorganise language-specific code into dedicated functions
– use a function template in the main helper to do some computations
at compile-time (using constexpr features)
2022-07-11 22:29:28 +02:00
Sébastien Villemot
c8b046ec86
Simplification using non-default std::ofstream constructor
2022-07-11 22:17:36 +02:00
Sébastien Villemot
6d2d73a5d7
Bytecode: refactor output methods around an enum class similar to ExprNodeOutputType
...
By the way, add assertions to ensure that assignment LHS output type is only
used on VariableNode(s) and AbstractExternalFunctionNode(s).
2022-07-06 16:46:40 +02:00
Sébastien Villemot
3b99ac5df0
Remove unused parameters to various methods
2022-06-24 17:11:38 +02:00
Sébastien Villemot
9bd2973034
Refactor bytecode output around a new BytecodeWriter class and operator<< overloads
2022-06-24 13:10:04 +02:00
Sébastien Villemot
13dc0a1144
Use operator""s to replace some calls to std::string constructor
...
By the way, remove other unnecessary calls to that constructor.
2022-06-22 12:47:11 +02:00
Sébastien Villemot
83693e4427
Bytecode: stop using unsigned integers where signed ones avoid unnecessary casts
2022-06-20 17:49:31 +02:00
Sébastien Villemot
5cd5676c8e
Bytecode: directly use several enums inside instruction classes
2022-06-20 15:19:08 +02:00
Sébastien Villemot
82751d21fe
Remove useless debugging code
2022-06-17 12:46:32 +02:00
Sébastien Villemot
a85730313c
Split CodeInterpreter.hh into two headers
...
– a generic one: CommonEnums.hh
– and a bytecode-specific one: Bytecode.hh
By the way, rename global constant “near_zero” into “power_deriv_near_zero”,
for clarity.
2022-06-16 17:53:23 +02:00
Sébastien Villemot
9b04c5436e
Block decomposition: fix crash when a variable appears in an equation but has zero symbolic derivative
2022-06-13 16:32:58 +02:00
Sébastien Villemot
ee8ee7c27f
Optimization: use move semantics in a few more places
2022-06-13 14:27:19 +02:00
Sébastien Villemot
c94dfb848c
C++20 modernization: use initialization within range-based for loop
...
In particular, use this feature in many loops which feature a special treatment
for the first iteration, using a boolean variable (replacing iterator
manipulation). By the way, also use std::exchange() to simultaneously test the
value of this variable and update it.
2022-06-07 14:35:59 +02:00
Sébastien Villemot
9ace2dc413
C++17 modernization: take advantage of class template argument deduction
2022-06-07 14:35:26 +02:00
Sébastien Villemot
0b5c88109f
Various simplifications
2022-06-07 14:34:30 +02:00
Sébastien Villemot
8b5e33b87a
Avoid name clash between function parameter and class member
2022-06-03 20:38:07 +02:00
Sébastien Villemot
171cd65566
Fix bytecode compilation of external function nodes
2022-05-20 11:43:02 +02:00
Sébastien Villemot
591b5e5f9e
Always create bytecode output
...
And, symmetrically, when the “bytecode” option is requested by the user, always
create the .m static/dynamic files.
The “bytecode” option therefore no longer modifies the preprocessor output.
2022-05-19 14:49:46 +02:00
Sébastien Villemot
0284b249f5
Remove unused “bytecode” argument in {Static,Dynamic}Model::computingPass()
2022-05-19 14:10:22 +02:00
Sébastien Villemot
3e94250582
C++17 modernization: use std::optional in ExprNode::getPacOptimizingShareAndExprNodes()
2022-05-16 19:10:16 +02:00
Sébastien Villemot
0eb11d3323
C++17 modernization: use std::optional in expression matching functions
2022-05-16 19:10:16 +02:00
Sébastien Villemot
3496d77eb4
C++17 modernization: use std::optional to store orig diff vars in VAR and TCM
...
By the way, remove the unused TrendComponentModelTable::getOrigDiffVar() method.
2022-05-16 19:10:16 +02:00
Sébastien Villemot
06d05e9a8d
C++17 modernization: use std::optional for SymbolTable::getEquationNumberForMultiplier()
2022-05-16 19:10:16 +02:00
Sébastien Villemot
fa7a926143
C++17 modernization: use std::optional for the storage of orig_symb_id and orig_lead_lag in SymbolTable
...
For the diff and unaryOp auxvar types, these value may be set or unset
depending on the complexity of the expression represented by the auxvar.
2022-05-16 19:10:15 +02:00
Sébastien Villemot
fc037a4352
Simplify printing of booleans using std::boolalpha
2022-05-16 19:10:15 +02:00
Sébastien Villemot
92d3b8166a
C++17 modernization: use std::optional for equation line numbers
2022-05-16 19:10:15 +02:00
Sébastien Villemot
0b51294994
C++17 modernization: use std::optional for trend variables in TCM
2022-05-16 19:10:15 +02:00
Sébastien Villemot
b42ee40b55
C++20 modernization: use contains() method on containers
2022-05-04 17:37:57 +02:00
Sébastien Villemot
54ca5d9cc0
Improve messages during model normalization
...
– Indicate whether we are trying to normalize the static or dynamic model
– If failed to normalize the static model, suggest to use the “no_static”
option
– Remove a superfluous error message
2022-04-19 17:11:13 +02:00
Sébastien Villemot
bfdcc546ec
Julia: adapt DynamicSetAuxiliarySeries.jl for TimeDataFrame objects
2022-04-01 17:34:37 +02:00
Sébastien Villemot
71edfd05e4
Add new “log” option to “var” statement
...
When an endogenous is declared with “var(log)”, say “y”:
– creates an auxiliary named “LOG_y”
– replaces “y(±l)” everywhere by “exp(LOG_y(±l))”
– adds a new auxiliary equation “y=exp(LOG_y)”
– adds a new definition “LOG_y=log(y)” in set_auxiliary_variables.m and
dynamic_set_auxiliary_series.m files
This option also works in conjunction with “deflator=…”, such as “var(log,
deflator=…)” (the “log” must appear befor “deflator”). There are no provisions
for combining “log” with “log_deflator”, because that would not make much sense
from an economic point of view (amounts to taking the log two times).
Ref. dynare#349
2022-03-30 17:46:07 +02:00
Sébastien Villemot
b78ac1d31f
Bytecode: fix temporary terms for dynamic derivatives in “evaluate” mode
...
The temporary terms for dynamic derivatives were only computed in the
“simulate” mode.
2022-02-18 12:38:06 +01:00
Sébastien Villemot
01bea3f5e7
TCM: remove useless 3rd dimension of A0 and A0star (supposedly for lags)
2022-01-28 16:38:50 +01:00
Sébastien Villemot
1e77f7c5a7
SymbolTable::getOrigSymbIdForAuxVar() now also works on unaryOp and diffForward auxvars
...
This is a more natural semantics.
Incidentally, this fixes a bug in the variable mapping (M_.mapping) where some
endogenous, appearing in a log() in a VAR or TCM, would not be mentioned (e.g.
in the var-expectations/7/example1.mod test, and many others).
2022-01-28 16:30:11 +01:00
Sébastien Villemot
289b4773d7
Fix matching of diff leads/lags in TCM and PAC models
...
The logic was flawed in several ways. In particular, the test files
pac/trend-component-{3,10,11}/example1.mod would return A0 and A0star matrices
where the (2,2) element was incorrectly zero.
2022-01-28 15:53:41 +01:00
Sébastien Villemot
b709da7f17
Fix SymbolTable’s getOrigSymbIdForAuxVar() and getUltimateOrigSymbID() so that they never return -1
...
The case of a diff aux var corresponding to a complex expression was not
correctly handled, and could lead to a value -1 being returned by these
methods.
2022-01-28 15:53:39 +01:00
Sébastien Villemot
5e8b478ccf
Add check to ensure that column indices in derivative matrices do not overflow
...
Closes : #89
2022-01-21 14:31:29 +01:00
Sébastien Villemot
6c7c2bc321
Simplification using std::set range constructor
2022-01-21 11:05:17 +01:00
Sébastien Villemot
aa0e06bc7d
Refactor handling of var_expectation_model statements
...
Creates a VarExpectationModelTable analogous to PacModelTable.
2022-01-20 16:26:15 +01:00
Sébastien Villemot
e1e5118373
Refactor the code that substitutes unary ops in model equations
...
In particular, make it more visible that the substitution also occurs in PAC
equations (and not only in VAR and TCM equations).
2022-01-19 15:56:44 +01:00
Sébastien Villemot
d149d3a76c
PAC: substitute unary ops in “growth” expressions (in “pac_model” and “pac_target_info”)
...
Ref. dynare#1837
2022-01-18 12:40:15 +01:00
Sébastien Villemot
5572e478f1
Indentation fix
2022-01-06 14:46:38 +01:00
Sébastien Villemot
a8fce06dc4
PAC: new options “auxname” and “kind” to “pac_model”
2021-12-16 15:40:47 +01:00
Sébastien Villemot
ea6fb40db7
PAC: new “pac_target_info” block and “pac_target_nonstationary” operator
...
Ref. Madysson/estimation-codes#5
2021-12-16 15:40:47 +01:00