Commit Graph

994 Commits (7dd2dd5e24a343fbeaf3522ea5e535c27d8b9f95)

Author SHA1 Message Date
Sébastien Villemot a922505bbe
Another fix for Fedora, needed for building MEX for Octave 2020-11-13 10:05:40 +01:00
Sébastien Villemot 3a42c234fe
Fix build failures on Fedora
— FCFLAGS needs to contain the compilation flags used when compiling Octave,
  otherwise it fails at configure stage when looking for gfortran
— Explicitly add -L$OCTLIBDIR, because with Octave 5 it is no longer there, and
  on Fedora the Octave libraries are no in the default linker search path
2020-11-05 18:52:11 +01:00
Sébastien Villemot f7ee0b9441
Build system: add missing -fPIC flag for Fortran 2008 MEX files under Octave 2020-11-05 15:40:14 +01:00
Sébastien Villemot 4e16ffcda2
Fortran MEX interface: minor fix for interface to dgemv 2020-10-21 18:17:41 +02:00
Sébastien Villemot ce5aa33a33
k-order DLL: no longer write journal file on-disk, unless options_.debug = true
Closes: #1735
2020-10-15 17:19:30 +02:00
Stéphane Adjemian (Charybdis) e690c5de5a
Merge Enterprise/block_trust_region into enterprise. 2020-09-24 16:05:55 +02:00
Stéphane Adjemian (Charybdis) 17e6421ea3
Merged master into enterprise.
Fixed conflict in
 - doc/manual/source/running-dynare.rst
2020-09-23 15:28:19 +02:00
Sébastien Villemot 73253a0620
Bytecode + Block decomposition: fix crash with purely forward variables
After simulating a block containing purely forward variables (thus of type
“evaluate backward”), the it_ variable of the evaluator would be left in an
inconsistent state (typically 0, which means that taking the value of a lagged
variable would lead to an invalid read).

By the way, fix a symmetric problem for backward blocks (which could
potentially create a invalid read for purely backward models).

Ref. #1727
2020-09-22 16:45:44 +02:00
Sébastien Villemot 8803bc1479
Bytecode: minor improvement to debugging information 2020-09-22 16:42:33 +02:00
Sébastien Villemot 865ab47fa9
Provide block_trust_region MEX under solve_algo 13 and 14
- block trust region solver now available under solve_algo=13
  It is essentially the same as solve_algo=4, except that Jacobian by finite
  difference is not handled. A test file is added for that case
- block trust region solver with shortcut for equations that can be evaluated
  is now available under solve_algo=14 (in replacement of the pure-MATLAB solver)

Closes: Enterprise/dynare#3
2020-09-18 18:01:56 +02:00
Sébastien Villemot 7e21bf2a10
Block trust region MEX: use MATLAB’s dmperm for the Dulmage-Mendelsohn decomposition
It turns out that MATLAB’s implementation is significantly faster than my own
Fortran implementation.
2020-09-18 17:55:58 +02:00
Sébastien Villemot 35a162c6a6
Block trust region MEX: fix memory leak in MATLAB function closure 2020-09-18 17:55:58 +02:00
Sébastien Villemot adf1fdb009
Block trust region MEX: add safety check for squareness of blocks 2020-09-18 17:55:58 +02:00
Sébastien Villemot 9430b4e9ca
Block trust region MEX: add debugging information 2020-09-18 17:55:57 +02:00
Stéphane Adjemian (Odysseus) 248ad18846 Merge remote-tracking branch 'Dynare/master' into enterprise
Fixed conflicts in:

 - .gitlab-ci.yml
 - matlab/dynare_config.m
 - matlab/dynare_solve.m
 - matlab/initvalf.m
 - matlab/perfect-foresight-models/make_ex_.m
 - matlab/perfect-foresight-models/perfect_foresight_setup.m
 - mex/build/matlab/Makefile.am
 - mex/build/matlab/configure.ac
 - mex/build/octave/Makefile.am
 - mex/build/octave/configure.ac
 - mex/sources/Makefile.am
 - preprocessor
 - tests/Makefile.am
2020-09-17 14:53:32 +02:00
Sébastien Villemot f6c2471eef
New MEX for solving discrete Lyapunov equations with doubling algorithm
This is a Fortran 2008 rewrite of disclyap_fast.m.

Closes: #1737
2020-07-30 16:34:35 +02:00
Sébastien Villemot 3f53a94981
Add dpotrf to Fortran 2008 BLAS/LAPACK bindings 2020-07-30 16:34:35 +02:00
Sébastien Villemot ea18431230
Various improvements to mjdgges MEX 2020-07-30 16:34:33 +02:00
Sébastien Villemot f4a31a0d1f
Various improvements to Fortran 2008 interface to MATLAB MEX functions
— add interface for more functions (cell, logical, struct)
— add new mexPrintf wrapper that trims and prints a newline
— functions that take indices of type mwIndex now 1-based indices
— improve the wrapper for mxArrayToString so that it returns a character scalar
2020-07-30 14:45:50 +02:00
Sébastien Villemot 49b35be90a
Preprocessor: various improvements to the use_dll mode
In particular, higher order derivatives are now returned as sparse matrices by
the static/dynamic files, instead of 3-column matrices (which was inconsistent
with the M-file mode).
2020-06-23 19:38:49 +02:00
Sébastien Villemot 400979fd44
macOS: fix handling LDFLAGS when building MEX for Octave
If something was already in LDFLAGS, it was concatenated without a whitespace,
leading to failure.
2020-06-15 18:29:42 +02:00
Sébastien Villemot 31a9a5e9ab
Bytecode MEX: various fixes to debug mode 2020-05-13 12:22:20 +02:00
Sébastien Villemot f4f296edd6
Preprocessor update
— various refactoring and bugfixes in block decomposition
— small bugfix for PAC models
2020-05-06 18:17:25 +02:00
Sébastien Villemot 6e0f104d7e
Bump minimal MATLAB version to R2014a
Ref. #1713
2020-04-07 16:32:32 +02:00
Sébastien Villemot 43ed7b2b69
Merge remote-tracking branch 'community/master' into enterprise 2020-03-27 16:28:41 +01:00
Sébastien Villemot fbfff18378
Preprocessor: various refactorings of block decomposition
Adapt bytecode MEX accordingly.
2020-03-20 18:51:37 +01:00
Sébastien Villemot 144bdf34ba
k-order MEX: fix crash on Octave when higher-order derivatives have numerical zero
In Octave, when some values given to the sparse() function are numerically
zero, then the nzmax of the generated sparse matrix is shrinked accordingly;
while under MATLAB, the nzmax is the length of the vector of values, zeros
included.

The check at the top of
DynamicModelMFile::unpackSparseMatrixAndCopyIntoTwoDMatData() would then fail
under Octave if some higher-derivatives had an element which is symbolically
non-zero but numerically zero.

We therefore relax the check, and accordingly adapt the code that handles
numerical zeros.

This bug was uncovered by tests/pruning/AnSchorfheide_pruned_state_space.mod,
which was failing under Octave.
2020-02-18 12:18:39 +01:00
Sébastien Villemot ae3f150c99
MS-SBVAR MEX: various simplifications and modernizations 2020-02-10 16:25:03 +01:00
Sébastien Villemot 5f9b9db31e
Build system: add missing Fortran 2008 files to source tarball 2020-01-16 16:54:47 +01:00
Sébastien Villemot 7e770f69e7
Remove workaround for errors in MEX files
Because at some point throwing exceptions from MEX files (with mexErrMsgTxt())
was not working under Windows 64-bit, we had designed a workaround to avoid
using exceptions.

Most MEX files were returning an error code as their first (or sometimes last)
argument, and that code would have to be checked from the MATLAB code.

Since this workaround is no longer needed, this commit removes it. As a
consequence, the interface of many MEX files is modified.

For some background, see https://www.dynare.org/pipermail/dev/2010-September/000895.html
2020-01-10 18:33:11 +01:00
Sébastien Villemot 89dc67eb46
Convert mjdgges MEX to Fortran 2008 2020-01-09 09:23:07 +01:00
Sébastien Villemot dd1e4d238b
Build system: remove useless rules for preprocessed Fortran 2008 files
Automake actually provides such rules.
2020-01-08 18:37:26 +01:00
Sébastien Villemot c0c95e1ceb
Add Fortran 2008 interface for a subset of BLAS/LAPACK functions 2020-01-06 18:29:47 +01:00
Sébastien Villemot ce9eca366d
Add Fortran 2008 interface for a subset of MEX functions 2020-01-06 18:29:47 +01:00
Sébastien Villemot 47e4649026
Add support for Fortran 2008 in MEX files
By the same token, remove unused support for Fortran 77.
2020-01-06 18:29:47 +01:00
Sébastien Villemot 4e314a529b
Bump minimal required Octave version to 4.4 2020-01-06 18:29:47 +01:00
Sébastien Villemot 39ed7c6742
Bump version number to 4.7-unstable 2019-12-20 17:20:07 +01:00
Sébastien Villemot b901b7af86
Global reindentation of MEX sources 2019-12-20 16:30:24 +01:00
Sébastien Villemot 996bdd6c64 New local_state_space_iteration_k MEX, for nonlinear filters at k-order
It applies the approximated policy function to a set of particles, using
Dynare++ routines.

There is support for parallelization, using Dynare++ multithreading
model (itself based on C++11 threads; we don’t use OpenMP because it is
incompatible with MKL). For the time being, default to a single thread. This
should be later refined through empirical testing.
2019-12-20 11:31:56 +01:00
Houtan Bastani 0c77f7e92f
macOS packaging: compile against the version of Octave distributed via https://octave-app.org (currently 4.4.1) 2019-12-10 15:14:16 +01:00
Sébastien Villemot fe0fdf2ccb
Fix Fortran flags under MEX for MATLAB
There was a typo in fedeeaad9f.

By the way, use the modern Fortran compiler when trying to detect slicot.
2019-12-03 18:48:19 +01:00
Sébastien Villemot 6a26926892
Add new block_trust_region MEX
This MEX solves nonlinear systems of equations using a trust region algorithm.
The problem is subdivided in smaller problems by doing a block
triangularisation of the Jacobian at the guess value, using the
Dulmage-Mendelsohn algorithm.

The interface of the MEX is simply:

  [x, info] = block_trust_region(f, guess_value);

Where f is either a function handle or a string designating a function.
f must take one argument (the evaluation point), and return either one or two
arguments (the residuals and, optionally, the Jacobian).

On success, info=0; on failure, info=1.
2019-12-03 16:17:16 +01:00
Sébastien Villemot 93bd817ccb
Add Fortran 2008 interface for a subset of BLAS/LAPACK functions 2019-12-03 16:17:12 +01:00
Sébastien Villemot ba466d22c8
Add Fortran 2008 interface for a subset of MEX functions 2019-12-03 16:17:08 +01:00
Sébastien Villemot fedeeaad9f
Add support for Fortran 2008 in MEX files
By the same token, remove unused support for Fortran 77.
2019-12-03 16:17:00 +01:00
Sébastien Villemot 5cae192487
Build system: really error out if some dependency is missing
The changes in 8065e9d439 were not working as
intended, because AC_CHECK_PROG expect values and not actions. Hence
AC_MSG_ERROR was not properly executed.

By the way, simplify some test conditions using && instead of if/then/fi
blocks.
2019-11-28 14:43:44 +01:00
Sébastien Villemot 9e222734a8
Bytecode: fix logic in routine that substracts two sparse matrices
The logic of the dynSparseMatrix::Sparse_substract_SA_SB() routine was
incorrect.

In some cases, it would read past the last nonzero elements of the A matrix,
and consequently write past the number of allocated nonzero elements of the C
matrix.

This would lead to crashes and, probably, to wrong results under certain
circumstances.

Closes: #1652
2019-11-27 16:57:47 +01:00
Sébastien Villemot 8065e9d439
Build system: by default, error out if some dependency is missing
In particular, if either MATLAB or Octave is missing, one needs to pass either
--disable-matlab or --disable-octave.

Moreover, several new configure flags have been introduced for disabling some
components:
--disable-doc
--disable-dynare++
--disable-mex-dynare++
--disable-mex-ms-sbvar
--disable-mex-kalman-steady-state
2019-11-26 13:53:42 +01:00
Sébastien Villemot 42f172dec3
perfect_foresight_problem MEX: optimization for linear models
When the model is linear, there is no need to reevaluate the Jacobian for each
time period, since it is invariant.

Closes: #1662
2019-11-14 14:45:10 +01:00
Houtan Bastani afcdf46e80
capitalize Cepremap and Matlab, uncapitalize DYNARE 2019-10-02 14:09:21 +02:00
Houtan Bastani f8eb982767
octave configure: remove unnecessary library linking for macOS 2019-09-24 15:22:36 +02:00
Sébastien Villemot 6ff7d4c56c
C++17: use structured bindings instead of std::tie 2019-09-11 16:06:35 +02:00
Sébastien Villemot 0d0a0a9bbb
Bump to C++17
This means we now require GCC 8.

Boost filesystem library is no longer needed.

Ref preprocessor#16
2019-09-11 15:06:12 +02:00
Sébastien Villemot 8b0d5f4b86
Windows: ensure that libgomp is statically linked 2019-09-10 15:17:15 +02:00
Sébastien Villemot 35acc111ff
Windows package: fix random build failure due to race condition
The MEX files are built out-of-tree (because we want to do them in parallel).
This would create a potential race condition if several builds want to create
the symlinks under mex/matlab/ or mex/octave/.

The solution is to disable those symlinks for out-of-tree builds.
2019-09-04 11:39:52 +02:00
Sébastien Villemot bae1fa255a
Add scripts and CI job for building Windows package
The scripts are based the former “dynare-build” project. They have been
overhauled and simplified.

Building a Windows package (both installer and zip archive) is as easy as
running “make -C windows” (provided the right Debian packages are installed,
use the “windows/install-packages.sh” script for that purpose).

The layout of MEX files for Octave in the package has been
changed (mex/octave/win32/ and mex/octave/win64/ instead of mex/octave32/ and
mex/octave/), for consistency with MATLAB MEX.
2019-09-03 21:36:47 +02:00
Houtan Bastani 1501032a3f
replace use of old-style casts 2019-07-30 15:15:23 -04:00
Sébastien Villemot 4030169db9
k_order_perturbation MEX: number of threads is now configurable 2019-07-09 17:33:14 +02:00
Sébastien Villemot 5b6c3bb452
k_order_perturbation MEX: small simplification in handling of NameLists 2019-07-09 17:33:14 +02:00
Sébastien Villemot aaaa897a2a
k_order_perturbation MEX: improve input handling and sanitization 2019-07-09 17:33:05 +02:00
Sébastien Villemot f8af21819e
Simplify the interface to perfect_foresight_problem MEX 2019-07-09 14:33:17 +02:00
Sébastien Villemot 984c60acb9
Various improvements related to the MEX R2018a API
— Use MX_HAS_INTERLEAVED_COMPLEX for testing for the new API

— Use the typed access functions under the new API, with one exception: we do
  not use mxGetDoubles() instead of mxGetPr(), because it would just complexif
  the code without any value added

For more details, see:
https://fr.mathworks.com/help/matlab/matlab_external/upgrade-mex-files-to-use-interleaved-complex.html
2019-07-09 11:54:12 +02:00
Sébastien Villemot f45738c09e
local_state_space_iteration_2 MEX: fix error message 2019-06-28 17:49:02 +02:00
Sébastien Villemot 67a49fc67b
k-order MEX: fix incorrect variable name in comment 2019-06-28 15:24:30 +02:00
Sébastien Villemot ca1a1ae0f2
local_state_space_iterations_2 MEX: minor stylistic improvement 2019-06-27 17:34:10 +02:00
Sébastien Villemot 7d9b2a557b
perfect_foresight_problem MEX: number of threads is now configurable 2019-06-27 17:00:12 +02:00
Sébastien Villemot 9557061fa3
Add new num_procs MEX file for getting number of available processing units 2019-06-27 14:34:09 +02:00
Sébastien Villemot e96f180c50
Implement mxIsScalar() for MATLAB < R2015a (8.5) 2019-06-25 20:31:13 +02:00
Sébastien Villemot 7c39b12b7b
Always compile MEX files with OpenMP (when they can take advantage of it)
As a consequence, remove the --enable-openmp option of the configure script.
2019-06-25 17:26:17 +02:00
Sébastien Villemot 82cef48eb4
A_times_B_kronecker_C MEX: remove the OpenMP codepath
Testing shows that it is slower than the BLAS path.
2019-06-25 17:26:14 +02:00
Sébastien Villemot c6a09a65e9
kronecker MEX: improve comments using UTF-8 2019-06-25 14:34:18 +02:00
Sébastien Villemot 7347554db5
perfect_foresight_problem MEX: fix compilation under Windows 2019-06-25 11:14:01 +02:00
Sébastien Villemot 5b591fac42
New perfect_foresight_problem MEX file
It constructs the stacked residuals and jacobian of the perfect foresight
problem.

It is an almost perfect replacement for the perfect_foresight_problem.m
routine, while being much more efficient.

Note however that the DLL never return complex numbers (it instead puts NaNs at
the place where there would have been complex). This may create problems for
some MOD files; the algorithms will need to be adapted to use a more
line-search method.
2019-06-24 17:53:59 +02:00
Sébastien Villemot ec05451d1a
Remove symmetric elements in 3rd model derivatives 2019-06-17 16:18:07 +02:00
Sébastien Villemot 1d22536bc5
Add back workaround for MKL with DGGES and VSL
The workaround was removed in de159c0480, but it
is still needed for MATLAB R2009b.
2019-05-21 17:28:11 +02:00
Sébastien Villemot 4d17c8b10d
Dynare++: move multithreading abstraction to the "utils" module 2019-05-02 12:38:56 +02:00
Sébastien Villemot faa3185bdf
local state space iterations 2 DLL: various modernizations and simplifications 2019-04-30 15:54:49 +02:00
Sébastien Villemot 1199d4abae
kronecker DLLs: various modernizations and simplifications 2019-04-30 15:54:48 +02:00
Sébastien Villemot de159c0480
mjdgges DLL: convert to C++ (for consistency with other DLLs)
Various modernizations and simplifications.

Also remove a workaround for a LAPACK bug in DGGES (the VSL argument was
apparently referenced even though JOBVSL="N"). Hopefully the bug has been fixed
everywhere now.
2019-04-30 15:54:45 +02:00
Sébastien Villemot b115b76e0d
Kalman steady state DLL: various modernizations and simplifications 2019-04-30 15:54:43 +02:00
Sébastien Villemot 80267f56e5
Block kalman filter DLL: various modernizations and simplifications 2019-04-30 15:54:40 +02:00
Sébastien Villemot f5e2bfc30a
Ask GCC to warn about C-style casts (-Wold-style-cast)
Adapt the code accordingly.
2019-04-23 13:03:20 +02:00
Sébastien Villemot 76e7acab7c
block_kalman_filter DLL: fix header file extension 2019-04-23 09:33:28 +02:00
Sébastien Villemot f953374dba
More Unicode copyright symbol 2019-04-16 14:34:05 +02:00
Sébastien Villemot c9bdc2c885
Dynare++: simplify methods for getting number of columns and rows of a matrix
Previously there were GeneralMatrix::numRows() and TwoDMatrix::nrows() for doing
the same thing (and same for columns and Const versions).

Merge these two into GeneralMatrix::nrows().
2019-04-16 12:44:02 +02:00
Sébastien Villemot be170f131c
k-order DLL: fix compilation error on Windows introduced by b1ba53ce0
Ref #217
2019-04-16 12:13:30 +02:00
Sébastien Villemot 57848930c6
Use Unicode copyright symbol (in UTF-8 encoding)
Do not use it in MATLAB source files, since unfortunately the MATLAB editor
does not support UTF-8.
2019-04-16 11:42:16 +02:00
Sébastien Villemot e281f35213
Lift upper restriction on approximation order
Ref #217
2019-04-15 17:34:01 +02:00
Sébastien Villemot b1ba53ce05
dynare_simul_ DLL: adapt for an arbitrary approximation order
The last input argument is now a struct containing matrices g_0, g_1,…
Typically one can pass oo_.dr for this argument.

Ref #217
2019-04-15 17:34:01 +02:00
Sébastien Villemot 68aa1ace8f
k-order DLL: in use_dll mode, get model derivatives from preprocessor at an arbitrary order
Ref #217
2019-04-15 17:34:01 +02:00
Sébastien Villemot a101457cf0
k-order DLL: fix wrong assertion in MATLAB mode
Bug introduced in 4c6e911d6 (only apparent under Octave, since under MATLAB
assertions are skipped).

Ref #217
2019-04-15 17:34:01 +02:00
Sébastien Villemot 2169341639
Move source code of gensylv and dynare_simul_ MEX to the same place as other MEX 2019-04-15 17:34:01 +02:00
Sébastien Villemot 4c6e911d69
k-order DLL: in MATLAB mode, get model derivatives from preprocessor at an arbitrary order
We no longer use the old ‘modfile.dynamic’ compatibility layer. We directly
call the ‘modfile.dynamic_g*’ functions.

Ref #217
2019-04-12 18:26:31 +02:00
Sébastien Villemot c31ba8bebf
k-order DLL: in ‘use_dll’ mode, compute # of temp. terms. using M_.dynamic_tmp_nbr
The preprocessor no longer exports the ‘ntt’ symbol in the MEX.

Ref #217
2019-04-12 18:26:31 +02:00
Sébastien Villemot d7dd7214c7
k-order DLL: convert model derivatives from Dynare to Dynare++ format at an arbitrary order
Ref #217
2019-04-12 18:26:30 +02:00
Sébastien Villemot 2dc988b69d
k-order DLL: make model derivatives storage ready for an arbitrary order 2019-04-10 19:00:49 +02:00
Sébastien Villemot 85f472c74b
Dynare++: new helpers for constructing {Const,}{TwoD,General}Matrix from mxArray* 2019-04-10 19:00:49 +02:00
Sébastien Villemot d0b4429fb6
k-order DLL: misc minor improvements 2019-04-10 09:41:58 +02:00
Sébastien Villemot b556290d60
k-order DLL: simplify and better document correspondence between Dynare and Dynare++ variable orderings 2019-04-10 09:23:32 +02:00
Sébastien Villemot efa1f39e71
k-order DLL: finally adapt for M_.{endo,exo}_names as cell arrays 2019-04-08 18:47:49 +02:00
Sébastien Villemot 86a607a4fc
k-order DLL: make the output arguments ready for arbitrary order 2019-04-08 18:47:49 +02:00
Sébastien Villemot bdc95f23aa
Make MEX build system forward-compatible with Automake 2.0
We now use a symbolic link farm to make source file accessible from build
directories.

Closes #466
2019-04-05 16:55:11 +02:00
Sébastien Villemot dee230bf32
Minor shell modernization 2019-04-05 12:12:24 +02:00
Sébastien Villemot fa64a25825
qmc_sequence DLL: various modernizations and simplifications 2019-04-03 19:04:36 +02:00
Sébastien Villemot dd09264b03
k-order DLL: return unfolded matrices in 5th output argument
Thus we can remove unfolding code from k_order_pert.m.
2019-04-02 19:16:13 +02:00
Sébastien Villemot 20cbc30450
k-order DLL: various simplifications 2019-04-02 19:16:10 +02:00
Houtan Bastani 7e46d8267c
mac: make build system work with clang and gcc 2019-04-01 17:38:42 +02:00
Houtan Bastani a93c6681c7
clang: can’t print non POD type through variadic function 2019-04-01 16:05:47 +02:00
Sébastien Villemot fb4d14c0a2
Fix build failure with MATLAB ≤ R2011a with recent GCC 2019-03-25 18:47:50 +01:00
Sébastien Villemot c46023ad56
POSIX shell stylistic improvements 2019-03-25 18:47:49 +01:00
Sébastien Villemot 4c11e9e9ec
Dynare++ kord and MEX: various modernizations and improvements 2019-03-07 19:46:15 +01:00
Sébastien Villemot 14f85cf448
Dynare++ kord library: various modernizations and improvements
Note that I removed several #define whose purpose was to avoid typing "typename
ctraits<t>::…". Even though this tends to complicates the code, this is
probably safer, especially since the #define was capturing a free variable (t).
2019-03-06 18:43:04 +01:00
Sébastien Villemot 6d99b6d120
Dynare++ kord library: various modernizations and simplifications 2019-03-05 18:35:35 +01:00
Sébastien Villemot 7fd95a6b72
Dynare++ kord library: use modern pseudo-random number generators 2019-03-05 12:29:17 +01:00
Sébastien Villemot 58bdee12c3
Dynare++ tensor library: refactor static stuff
- encapsulate it more clearly
- make it thread safe
- put back the Pascal triangle initialization stuff removed in 9512a32ad0
2019-02-21 19:00:50 +01:00
Sébastien Villemot b72857d4ce
Dynare++: the get() method of tensor containers now return a reference
Previously it was returning a pointer, which is non-standard for containers,
and was leading to ugly dereferencing everywhere.
2019-02-20 18:06:58 +01:00
Sébastien Villemot b5793ddd22
Dynare++: use std::unique_ptr for storage inside tensor containers 2019-02-20 17:04:34 +01:00
Sébastien Villemot 9f4986e90e
Add missing Dynare++ header file to MEX builds 2019-02-19 18:53:21 +01:00
Sébastien Villemot 9512a32ad0
Dynare++: remove duplicate implementation of the Pascal triangle
As a consequence, the singleton implementation has to be made thread-safe.

Also implement the singleton pattern using a namespace, rather than a static
instance.
2019-02-19 16:46:04 +01:00
Sébastien Villemot 5fcf563c61
Dynare++: factorize and optimize code for integer exponentiation
There were two implementations of integer exponentiation. Merge them into a new
file under utils/cc/.

By the way, optimize it using exponentiation by squaring.
2019-02-19 15:50:07 +01:00
Sébastien Villemot 9dfb556740
k-order DLL: fix bug introduced in 1f7d3beddc
For the IntSequence class, the initialization with {} and () are no longer
equivalent.
2019-02-12 19:09:28 +01:00
Sébastien Villemot 1f7d3beddc
Dynare++ tensor library: modernize the Symmetry class
We now use a initializer list constructor for creating symmetries of the form
$y^n$, $y^n u^m$, $y^nu^m\sigma^k$.

The constructor taking a single integer is used to initialize a symmetry of a
given length.

Similar changes are made to IntSequence.

This behavior is similar to std::vector.
2019-02-11 16:45:07 +01:00
Sébastien Villemot af722f438f
Dynare++: drop remaining "using namespace std" 2019-02-06 19:00:46 +01:00
Sébastien Villemot 733308807d
Dynare++: by default, use as many threads as there are logical CPUs
The former default was 2 threads, since Dynare++ was written at a time when
hyper-threading was being generalized (but multiple cores were not).
2019-01-29 16:34:25 +01:00
Sébastien Villemot 752a02a36c
Dynare++: use C++11 threads (instead of POSIX threads API)
On Windows, this means that a POSIX threads implementation is no longer needed,
since C++11 threads are implemented using native Windows threads.

On GNU/Linux and macOS, POSIX threads are still used under the hood.

A new m4 macro (AX_CXX11_THREAD) is used to add the proper compilation
flags (instead of AX_PTHREAD).
2019-01-28 18:44:24 +01:00
Sébastien Villemot a9e51ac4c0
Dynare++ sylvester equation solver: remove the SylvMemory class, not actually used 2019-01-25 18:43:21 +01:00
Sébastien Villemot 1ef1dedc65
Refactor GeneralMatrix and ConstGeneralMatrix classes
- Remove the GeneralMatrix(const ConstVector &) constructor, since it is hides
  a memory allocation (copying the ConstVector into a fresh Vector). This
  helped detecting and fixing several unneeded memory allocations. Some other
  memory allocations are now more visible (with an explicit Vector{}
  constructor).

- Add checks in GeneralMatrix(Vector, …) and ConstGeneralMatrix(ConstVector, …)
  constructors for verifying that the {Const,}Vector has unit-stride (this was
  an implicit assumption so far) and is large enough for storing rows*cols
  elements.

- Add GeneralMatrix::operator=(const ConstGeneralMatrix &).

- Delete ConstGeneralMatrix::operator=().
2019-01-24 15:27:23 +01:00
Sébastien Villemot c711d34d1d
Dynare++ / sylvester equation solver: refactor Vector and ConstVector classes
- these classes now encapsulate a std::shared_ptr<{const, }double>, so that
  they do not perform memory management, and several {Const,}Vector instances
  can transparently share the same underlying data

- make converting constructor from ConstVector to Vector explicit, since that
  entails memory allocation (but the reverse conversion is almost costless, so
  keep it implicit); do the same for GeneralMatrix/ConstGeneralMatrix,
  TwoDMatrix/ConstTwoDMatrix

- remove the constructors that were extracting a row/column from a matrix, and
  replace them by getRow() and getCol() methods on {Const,}GeneralMatrix

- rename and change the API of the complex version Vector::add(), so that it is
  explicit that it deals with complex numbers

- add constructors that take a MATLAB mxArray
2019-01-22 16:13:22 +01:00
Sébastien Villemot 3c5afded8e
k-order DLL: fix build failure 2019-01-10 19:45:11 +01:00
Sébastien Villemot e45d230a3d
Rename .dat file to standard .hh extension 2019-01-10 14:29:58 +01:00
Sébastien Villemot 188d6296d7
Dynare++: finish to apply Dynare C++ coding style and extensions (.cc/.hh) 2019-01-08 17:12:05 +01:00
Sébastien Villemot ce1ef47093
dynare++ / tensor library (TL): move away from CWEB
By the way apply Dynare C++ coding style and extensions (.cc/.hh).
2019-01-08 16:09:25 +01:00
Sébastien Villemot 84255f9e9a
dynare++/integ: move away from CWEB
By the way apply Dynare C++ coding style and extensions (.cc/.hh).
2019-01-04 17:28:20 +01:00
Sébastien Villemot df772325a2
dynare++/kord: move away from CWEB
By the way apply Dynare C++ coding style and extensions (.cc/.hh).
2019-01-04 16:32:05 +01:00
Sébastien Villemot dcac799289
Fix check for QZ eigenvalue criterium
The criterium was previously incorrectly applied to the square absolute value of
eigenvalues. Rather apply it to the absolute value itself (as done in
mjdgges.m and the AIM solver).

Closes #1632
2019-01-02 16:37:30 +01:00
Sébastien Villemot 736d43c4e6
Bump minimal MATLAB version requirement to 7.9 (R2009b) 2018-11-13 15:59:16 +01:00
Sébastien Villemot c6f5c804d9
Gensylv MEX also needs MatIO (because Dynare++ code does) 2018-11-12 12:56:01 +01:00
Sébastien Villemot 331a27398a
Fix another memory leak in k-order DLL
Re Dynare/dynare#1490.
2018-11-08 17:30:48 +01:00
Sébastien Villemot 50a09a687e
C++11 modernization
Incidentally, fix a memory leak related to DynamicModelAC instantiation, using
a std::unique_ptr (see Dynare/dynare#1490).
2018-11-08 17:24:19 +01:00
Sébastien Villemot afc9f94854
On Windows, statically link the pthread library
Otherwise the DLL is dynamically linked against libwinpthread. This regression
was introduced by commit 671fe4bcd.
2018-11-07 14:38:04 +01:00
Sébastien Villemot 671fe4bcd4
Build system improvements on Windows (MinGW / MSYS2)
- Use the -static flag when linking Dynare++, so that shipping libquadmath and
  libgcc DLL in the installer is no longer needed.

- Use AM_CXXFLAGS and AM_LDFLAGS variables for changing flags, since CXXFLAGS
  and LDFLAGS are user variables. Also, this avoids passing these flags down to
  configure scripts in subdirectories.

- Check for the SZIP library in the configure test for the MatIO, this is
  needed under MSYS2.

- Statically link MatIO and GSL in MEX files for MATLAB, this is needed under
  MSYS2.
2018-11-06 12:17:56 +01:00
Sébastien Villemot ffb36e5713 Remove obsolete kludges for MinGW 2018-10-02 17:10:36 +02:00
Sébastien Villemot 59642c3312 C output of preprocessor now splits generated fcts into several smaller fcts
Adapt the k-order DLL as a consequence.
2018-10-01 16:13:12 +02:00
Sébastien Villemot feeda74dfb Remove spurious executable permission 2018-09-27 12:24:57 +02:00
Sébastien Villemot d03cc56587 solve_algo=7 and stack_solve_algo=2 are now allowed under Octave
The gmres() function has been implemented (actually since Octave 3.4.1!).
2018-08-02 15:20:39 +02:00
Sébastien Villemot 932e5f946c Update preprocessor submodule
Adapt bytecode DLL as a consequence.
2018-07-18 17:52:44 +02:00
Sébastien Villemot cb46a2697e Fix invalid memory write in k-order DLL
The bug would show at order 3 when the last output argument (derivs) is not
requested (in practice every 3rd order solution without pruning). The DLL would
still attempt to write into it, causing an invalid memory access.
2018-07-02 16:37:46 +02:00
Sébastien Villemot b2c554623f Various fixes related to the new layout of generated files 2018-06-28 18:14:40 +02:00
Sébastien Villemot a1b8bd39b2 Move the location of various generated files on the filesystem
- M and MEX files are now under +${MODELNAME}/
- bytecode, C source and JSON now under ${MODELNAME}/model/
2018-06-27 17:03:39 +02:00
Houtan Bastani f5bf76deb5 fix mex build system for macOS 2018-06-27 15:04:33 +02:00
Sébastien Villemot a71e0ebee4 Add a compile-time check for MATLAB version, as we already do for Octave 2018-06-06 14:31:25 +02:00
Sébastien Villemot e1a3c40ef0 Fix compilation of MS-SBVAR DLL under Octave 4.4 2018-06-05 17:07:45 +02:00
Sébastien Villemot e669321eec Require C++14 for MEX files
Needed because bytecode DLL uses some preprocessor code which is C++14.
2018-06-05 11:34:41 +02:00
Sébastien Villemot 02084ce310 Remove qzcomplex Oct-file
It's actually not needed. The QZ complex decomposition can be obtained in
Octave on real matrices by casting them to the complex type.
2018-05-17 12:11:15 +02:00
Sébastien Villemot 3f674f0f26 Enforce minimal Octave version in the configure script 2018-05-16 10:50:27 +02:00
Sébastien Villemot e2c2f2d966 Remove fallbacks for ilu, linsolve and ordschur under Octave
These functions are all included in Octave 4.2.
2018-05-16 10:48:44 +02:00
Sébastien Villemot f665379fcc Kludge for bug in MinGW, that defines __STDC_UTF_16__ but not char16_t
This breaks the matrix.h of older MATLABs (e.g. R2009a). Also see <uchar.h>.
2018-05-15 19:29:17 +02:00
Sébastien Villemot fbddfc0aae Require C99 when compiling MEX files, since mjdgges now uses C99 features 2018-05-15 14:53:56 +02:00
Sébastien Villemot 7a2aa211bf Make mjdgges DLL compatible with MATLAB interleaved complex API
This API was introduced in MATLAB 9.4 (R2018a), because the internal
representation of complex numbers has changed.
2018-05-14 15:16:09 +02:00
Houtan Bastani fdf9a8a453 move preprocessor to submodule 2018-02-16 16:44:16 +01:00
Houtan Bastani fb6a11f544 move estimation-dll to its own repository: https://github.com/DynareTeam/estimation-dll.git 2017-09-22 15:31:23 +02:00
Sébastien Villemot 1ff5c3f571 Fix various typos (thanks lintian). 2017-06-28 15:06:54 +02:00
Ferhat Mihoubi 119e5b4dfa Corrects bugs in bytecode related to the use of finite instead of isfinite and to mxMalloc tests 2017-06-05 18:51:43 +02:00
Stéphane Adjemian (Charybdis) e3769670df Updated AC_INIT 2017-05-19 18:54:32 +02:00
Stéphane Adjemian (Charybdis) 1bf81c9f5a Fixed copyright notices. 2017-05-18 18:36:38 +02:00
Stéphane Adjemian (Charybdis) b4448937cc Fixed indentation of c/h/cc/hh files. 2017-05-16 16:30:27 +02:00
Stéphane Adjemian (Charybdis) a53636e24e Fixed copyright notices. 2017-05-16 14:11:15 +02:00
Ferhat Mihoubi 981e31c8c3 Fix issues in bytecode with option extended_path related to the size of endo_simul and exo_simul
(cherry picked from commit ab7acc49e30fbcb292d63d58281581a308716b4c)
2017-05-08 18:40:18 +02:00
Ferhat Mihoubi e248d8bf59 Fix memory and periods issues in bytecode
(cherry picked from commit fa5dd681abcb3243a5ee9be1f71fdfc51bced1cd)
2017-05-08 18:39:44 +02:00
Ferhat Mihoubi 857fc3c4f4 Corrects several bugs related to bytecode:
- Memory allocation is checked
- The amount of memory allocated for conditional forecast is corrected
2017-04-05 11:48:40 +02:00
Stéphane Adjemian (Charybdis) 8925e7ca1f Cosmetic patch (remove some warnings about potentially uninitialized variables in bytecode). 2017-02-13 19:22:26 +01:00
Stéphane Adjemian (Charybdis) 537e384122 Fixed make parallel mode (missing dependency in automake). 2016-12-01 23:25:01 +01:00
Stéphane Adjemian (Charybdis) 1229372a6c Defines M_PI (cross compilation for Octave). 2016-12-01 13:32:54 +01:00
Stéphane Adjemian (Charybdis) 23642b3b6b Defines M_PI, M_SQRT2 and finite() in bytecode...
... Which are not in standard C/C++ (otherwise compilation of the mex for Octave
with -std=c++11 fails).
2016-12-01 13:32:54 +01:00
Houtan Bastani e3fbefc616 mjdgges: fix bug where qz_criterium was not taken into account if a threshold argument is also passed 2016-10-27 11:19:34 +02:00
Houtan Bastani 8b17af05d5 bytecode: work around for isnan and isinf bug in C++ standard, glibc <= 2.23.
Fixed by https://sourceware.org/bugzilla/show_bug.cgi?id=19439
2016-10-11 16:01:27 +02:00
Michel Juillard 5d38280f27 remove one instance of dynamic exception specification
closes issue #1250
2016-07-16 00:13:47 +02:00
ferhat ac2e5cfd52 - In extended path
- fix an error with results print out
  - fix an error withe exogenous initialization
2015-11-19 17:03:05 +01:00
ferhat 77f5d572de Fix the output arguments in case of bytecode failure 2015-11-06 15:06:17 +01:00
Stéphane Adjemian (Charybdis) 2ec1579cd0 Fixed warnings in bytecode compilation.
Removed unused variables.
2015-10-19 18:01:38 +02:00
ferhat 7c5272d852 Allows to compute the extended path and the conditional forecasts with bytecode 2015-09-22 15:39:49 +02:00
Sébastien Villemot d0628af1f2 No longer compile ordschur.oct for Octave >= 4.0.
The function is now an Octave builtin.
2015-03-17 17:53:11 +01:00
Houtan Bastani 1b869b26a7 fix dates for changes in 86c3c0fb1b and a40323d2fb 2015-01-08 18:39:04 +01:00
ferhat 86c3c0fb1b Checks that fields endo_names, exo_names and param_names exist 2015-01-06 10:30:52 +01:00
ferhat 24b2993f50 Solves issues in deterministic simulation:
- replaces maximum_endo_(lead|lag) by maximum_(lead|lag) to determine the maximum number of lead and lag in deterministic simulation
- allows to use bytecode in solve_perfect_foresight_model.m
- Adds model information in bytecode
2014-12-17 09:37:43 +01:00
Houtan Bastani cf910cb64f build system: add flag for mex compilation on OS X 10.9 2014-07-24 12:18:38 +02:00
Sébastien Villemot 9b5a09958c Fixes to make install.
- fix DESTDIR for preprocessor and MEX files (it was duplicated)
- don't install libdynare++.a
2014-07-18 12:15:36 +02:00
Houtan Bastani 8d2b79a224 make install, closes #576 2014-07-16 16:18:06 +02:00
Sébastien Villemot 41295ad602 Minor cleanups in k_order_perturbation DLL. 2014-03-21 17:26:55 +01:00
Sébastien Villemot 050b495a52 Fix an invalid memory access in k_order_perturbation DLL.
In the case where a 2nd/3rd derivative is symbolically not zero but numerically
zero at the evaluation point, the last lines of the g2/g3 matrices (in
KordpDynare::calcDerivativesAtSteady()) where uninitialized (these matrices
store the sparse hessian/3rd-deriv in coordinate list form, i.e. with 3 columns
and as many rows as non-zero elements). When reconstructing the dense
hessian/3rd-deriv matrix out of g2/g3, this would result in invalid memory
accesses.
2014-03-21 17:26:48 +01:00
Sébastien Villemot 9d32204790 Ensure that -lpthread is statically linked under MinGW. 2014-03-10 17:25:39 +01:00
Sébastien Villemot 75ae191d33 Upgrade to a newer version of the AX_BOOST_BASE macro.
Our workaround for cross-compilation has been incorporated upstream.
2014-03-03 11:13:27 +01:00
Michel Juillard 45f7de33e8 sobol qmc_sequence MEX: dimension larger than 1111 returns a proper
Matlab error message instead of crashing
2014-02-15 21:11:42 +01:00
Sébastien Villemot 5308da2cad Upgrade the minimum requirement to MATLAB 7.5 (R2007b). 2014-02-03 15:52:54 +01:00
Sébastien Villemot e5d4defb41 Fix handling of qz_criterium in k_order_perturbation MEX.
If the MEX file was called with options_.qz_criterium=[], it would not use a
correct default value (but would use NaN).

Closes #574
2014-01-27 15:33:37 +01:00
Sébastien Villemot 66d48f5917 Compatibility fixes for Octave 3.8.
- no longer use OCTAVE_QUIT in MEX files; this seems now only possible in
  oct-files. (Ref #304)
- do not build linsolve.oct on Octave >= 3.8, it is available natively.
- do not add strjoin.m to the patch on Octave >= 3.8, it is available natively.
- default_save_options has been renamed save_default_options.
2014-01-03 11:05:39 +01:00
Sébastien Villemot 85f001885e Estimation DLL: fix bug with creating MAT files
Similar problem to #446
2013-12-06 14:46:44 +01:00
Houtan Bastani a8d07308a9 ms-sbvar: support ctrl-c changes in submodule, #304 2013-12-05 16:13:58 +01:00
Sébastien Villemot 7ada720e7b Bump version number 2013-12-02 17:55:10 +01:00
Houtan Bastani 830c09760e preprocessor: remove clang warning on declaration of const static double in class definition 2013-11-22 14:59:34 +01:00