Commit Graph

951 Commits (10af04c6d88070d61a0b8d6521364947413d2866)

Author SHA1 Message Date
Sébastien Villemot 10af04c6d8
Use Unicode copyright symbol (in UTF-8 encoding) in all source files
It is now supported by the MATLAB editor (as of R2022a).

The old ASCII notation is left in some files that we copy as-is from other
sources (e.g. in the contrib/ and m4/ subdirectories).

The particles submodule is not updated at this point, because it is in an
inconsistent state.

[skip ci]
2022-04-13 14:54:25 +02:00
Sébastien Villemot b4ce69db3a
Remove options_.slowc field
There was no user interface, and the feature that it provides has lost
relevance over time.

Note that algorithms for block and/or bytecode still internally use some
equivalent of this parameter, but its initial value will no longer be
modifiable (which could lead to bugs, see commit
e49e7e906f).
2022-03-31 17:39:43 +02:00
Sébastien Villemot c5a3658110
Block trust region: cosmetics
In particular, avoid using the deprecated dble() function. Rather use the
real() cast function, with the appropriate kind parameter.
2022-03-29 10:34:35 +02:00
Stéphane Adjemian (Ryûk) b9bc1e7cb1
Revert update if residuals or jacobian have NaNs (block_trust_region). 2022-03-25 19:42:40 +01:00
Stéphane Adjemian (Ryûk) 79cad99446
Harmonise exit codes and fix convergence test. 2022-03-25 19:42:40 +01:00
Stéphane Adjemian (Ryûk) f2bf98ee76
Return the value of info as a third argument (block_trust_region). 2022-03-25 19:42:40 +01:00
Sébastien Villemot 8c16d1745e
block_trust_region MEX: first part of handling complex values returned by solved function
If solved function returns complex values (with nonzero imaginary part), turn
them into NaNs. This mimics the behaviour of the use_dll case.

Next step will be to adapt the trust region algorithm to diminish radius when
there are NaNs.

Incidentally, bump the required GCC version to 9, since we use the %re and %im
components of complex values in Fortran.
2022-03-21 18:55:42 +01:00
Sébastien Villemot d5472d2338
Tighten input sanity checks of various MEX files
Note that the unitary test in lyapunov_solver.m that checks sparse matrix input
had to be removed. Previously, this test was passing by chance (because the
sparse test matrices had actually no zero element, hence the internal double
float storage was the same as in the dense case). Now it consistently fails
with the additional checks in disclyap_fast MEX.
2022-03-18 22:49:46 +01:00
Sébastien Villemot 4f6d8a198a
k_order_perturbation MEX: convert complex elements of residuals or derivatives matrices to NaNs 2022-03-18 16:45:33 +01:00
Sébastien Villemot 2d73ae2971
Bytecode: fix typo 2022-03-16 15:00:09 +01:00
Sébastien Villemot 96fb676be7
Bytecode: fix stack_solve_algo=4 when a “solve backward/forward” block follows a “solve two boundaries” block
When solving a “Solve two boundarise” block with stack_solve_algo=4, the
“slowc” variable is modified. This would affect the resolution of further
“solve backward/forward” blocks, which would yield results.

The fix consists in saving and restoring “slowc”.
2022-03-15 17:42:03 +01:00
Sébastien Villemot 65e18fe883
Bytecode: fix stack_solve_algo=4 on linear blocks
Only one iteration is performed on linear blocks. But in the case of
stack_solve_algo=4 it is not enough, since it will not find the right optimal
path lenght at the first iteration (even though that optimal path length is
ufnitary).
2022-03-01 11:29:29 +01:00
Sébastien Villemot dbbbb75874
Bytecode: fix typo, replace “substract” by “subtract” 2022-02-28 18:47:20 +01:00
Sébastien Villemot 67a003aa73
Bytecode: fix stack_solve_algo=1 (relaxation method)
There were various issues with the construction of sparse submatrices.

By the way, refactor and document the code to make it more readable.
2022-02-28 18:47:20 +01:00
Sébastien Villemot 811e53f9ad
Bytecode: document matrix computation routines 2022-02-28 18:47:20 +01:00
Sébastien Villemot 59b8ee9c33
Bytecode: remove unused matrix subtraction routine 2022-02-28 18:47:20 +01:00
Sébastien Villemot a7cc466285
Bytecode: fix bug in sparse matrix multiplication routines
Since those routines compute Aᵀ·B, the number of rows of the output is equal to
the number of columns of A.
2022-02-28 12:18:58 +01:00
Sébastien Villemot 8536b63827
Bytecode: remove superfluous debug information 2022-02-18 14:17:37 +01:00
Sébastien Villemot 972461c326
Bytecode: add debugging information about input arguments 2022-02-17 17:41:10 +01:00
Sébastien Villemot a376d8c9fe
Fix steady state computation with bytecode+block and solve_algo ⩽ 4 or ⩾ 9
– Temporary terms were not correctly passed between blocks
– solve_algo ⩾ 9 was incorrectly passed through bytecode own’s solver instead
  of through dynare_solve
2022-02-17 17:28:37 +01:00
Sébastien Villemot ceb3ec2487
Bytecode: remove unused constructors 2022-02-15 16:54:41 +01:00
Sébastien Villemot 863fa2de1c
Bytecode: perfect foresight simulation of *linear* “Solve forward simple/complete” blocks was giving was results 2022-02-15 16:54:41 +01:00
Sébastien Villemot 803e3721ec
Bytecode: correctly handle M_.{endo_names,exo_names,param_names}, which are now cell arrays 2022-02-14 15:06:07 +01:00
Sébastien Villemot 92e82cfa0a
Bytecode: remove unused function prototype 2022-02-14 14:40:34 +01:00
Sébastien Villemot 188df7711d
Bytecode: fix simulation of blocks “Solve forward/backward complete” with stack_solve_algo={0,1,4}
The problem would also manifest at steady state computation with solve_algo=6.

It could crash or give incorrect results.
2022-02-11 12:00:25 +01:00
Sébastien Villemot d74cb031d2
Bytecode: fix error message about convergence failure that can happen in Solve Backward Complete as well 2022-02-10 17:27:07 +01:00
Sébastien Villemot cdb4f872b2
Bytecode: fix crash with stack_solve_algo=1 on “Solve forward/backward” blocks 2022-02-10 17:15:24 +01:00
Sébastien Villemot ef6e4c7745
Bytecode: remove unused code 2022-02-10 16:58:39 +01:00
Sébastien Villemot 0caefa1593
Bytecode: exit gracefully when M_ does not exist 2022-02-09 14:32:25 +01:00
Sébastien Villemot 8d3e0587dc
k_order_mean MEX: check number of output arguments
Incidentally, this fixes a gfortran warning
2022-02-04 14:38:30 +01:00
Sébastien Villemot 964763ef4d
pthread Fortran interface: fix internal type for representing pthread_t structure 2022-02-04 12:33:19 +01:00
Sébastien Villemot 39f47dc957
local_state_space_iteration_k MEX now uses the Fortran code (instead of the C++ code)
Closes: #1802
2022-02-04 11:49:46 +01:00
NormannR 5f828e241f Parallelizes local_state_space_iteration_fortran 2022-01-31 18:44:48 +01:00
Sébastien Villemot 79132ebe55
Build system: no longer use deprecated LFLAGS from mkoctfile
By the way, drop the -static-* flags from LDFLAGS in Windows mkoctfile stub. It
is no more needed and creates duplicates in the link command line (since those
flags are already in DL_LDFLAGS).
2022-01-24 12:52:24 +01:00
Sébastien Villemot 0c68e7336b
perfect_foresight_problem MEX: error out properly when called MATLAB function triggers an exception
Closes: #1832
2022-01-03 18:11:31 +01:00
Sébastien Villemot ae5be8d717
Build system: add provisions for k_order_mean MEX under Octave 2021-12-16 10:42:37 +01:00
Sébastien Villemot 1144de4167
Bump version number 2021-12-08 14:23:26 +01:00
Sébastien Villemot 5f675eee18
Add erfc() primitive 2021-12-07 17:00:59 +01:00
Normann Rion cf829fb28e
A few fixes for k-order welfare assesment in `evaluate_planner_objective`
As suggested in !1962
2021-12-07 12:19:30 +01:00
Sébastien Villemot 10698ba896
Fix building of source package
Bug introduced in 06fd42c19b.
2021-11-26 19:15:27 +01:00
Sébastien Villemot 06fd42c19b
Drop the dynare_simul_ MEX in favour of the new Fortran k_order_simul MEX 2021-11-26 17:37:53 +01:00
NormannR f889a25e86 Amend the k_order_welfare routine for it to return the adequate output variables 2021-11-24 17:16:03 +01:00
NormannR 45aad05670 Implements a Fortran routine `k_order_moment` to compute the k-order unconditional moment of the vector of endogenous variables using simulation 2021-11-24 17:09:12 +01:00
NormannR cb5971d60f Fix typo in local_state_space_iteration_fortran 2021-11-24 14:32:37 +01:00
Sébastien Villemot e155c5cbb2
macOS: fix compilation of MEX files against Homebrew’s octave
It is necessary to link MEX files against Octave libraries, as under Windows.
2021-10-25 18:02:46 +02:00
Sébastien Villemot ebec02c6e4
local_state_space_iteration_2 MEX: yet more fixes to comments
In particular, use ε instead of u in mathematical expressions for consistency
with the C++ variable name.
2021-10-22 17:57:29 +02:00
Sébastien Villemot 0be7e0a0d7
local_state_space_iteration_2 MEX: more fixes to comments 2021-10-21 16:34:57 +02:00
Sébastien Villemot 05ea09eee9
local_state_space_iteration_2 MEX: error out properly when trying to use with BLAS+MATLAB+parallelization
By the way, rename the C preprocessor symbol so that it is undefined by
default.
2021-10-20 15:50:34 +02:00
Sébastien Villemot e3b1f9e79a
local_state_space_iteration_2 MEX: various fixes to comments 2021-10-20 15:39:58 +02:00
Sébastien Villemot ce282dc29c
local_state_space_iteration_2 MEX: fix bug when there are more shocks that states
The code that computes ghx·yhat+ghu·u (both with and without pruning) was
making the implicit assumption that q⩽n, i.e. that the number of shocks is less
than or equal to the number of states. If q>n, it would try to read invalid
memory references in ghx and yhat, and would thus either crash or return dummy
results.

Closes: #1820
2021-10-14 16:18:17 +02:00