Commit Graph

57 Commits (7e770f69e791e705ab535126e0157130dc9d40c6)

Author SHA1 Message Date
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 b901b7af86
Global reindentation of MEX sources 2019-12-20 16:30:24 +01: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 aaaa897a2a
k_order_perturbation MEX: improve input handling and sanitization 2019-07-09 17:33: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 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 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 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 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 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 a93c6681c7
clang: can’t print non POD type through variadic function 2019-04-01 16:05:47 +02:00
Sébastien Villemot 4c11e9e9ec
Dynare++ kord and MEX: various modernizations and improvements 2019-03-07 19:46:15 +01:00
Sébastien Villemot 6d99b6d120
Dynare++ kord library: various modernizations and simplifications 2019-03-05 18:35:35 +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 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 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 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 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
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
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 c121aa14b1 Remove oo_.dr.{nstatic,npred,nboth,nfwrd,nspred,nsfwrd}
Replace them by equivalents in M_ (and an extra one: M_.dynamic).

IMPORTANT POINT: oo_.dr.npred used to count both purely backward and mixed/both
variables. This was the cause of lots of confusion. The new M_.npred only
counts purely backward variables.

We now have the following indentities:

M_.npred + M_.nboth + M_.nfwrd + M_.nstatic = M_.endo_nbr
M_.nspred = M_.npred + M_.nboth
M_.nsfwrd = M_.nfwrd + M_.nboth
M_.ndynamic = M_.npred + M_.nboth + M_.nfwrd
2012-11-16 20:05:13 +01:00
Michel Juillard f5f5ca1a83 removing printing used for debugging 2012-08-01 18:38:42 +02:00
Michel Juillard 2244af9c62 adding pruning option for 3rd order 2012-07-31 21:50:59 +02:00
Michel Juillard 84164dc57e adding possibility to pass derivative matrices to k_order_perturbation
MEX function
2012-07-07 21:21:28 +02:00
Sébastien Villemot a66594caed Add MEXEXT define to build system, adapt relevant DLL and Windows packaging
Closes: #235
2012-01-09 12:39:09 +01:00
Sébastien Villemot 5fa666e448 k-order perturbation: cosmetic change related to mxGetPr/mxGetData 2011-05-20 10:59:40 +02:00
Sébastien Villemot 0f9ec8b2dc K-order DLL: add test for NaN/Inf in param/steady-state vectors to avoid crashes (thanks to J. Pfeifer for reporting this) 2011-02-07 11:12:57 +01:00
Sébastien Villemot 02652f6eb8 Updated copyright notices 2011-02-04 17:27:33 +01:00
Sébastien Villemot cc2a9d90ac Global reindentation of MEX source files 2011-02-04 16:53:12 +01:00
Houtan Bastani a11817cfa4 k-order: added support for m-files, added tests and modified manual 2010-12-22 09:48:05 +01:00
Houtan Bastani d69d225b82 k-order: removed unused variable from class definition 2010-12-17 12:16:32 +01:00
Houtan Bastani b63590712c fixed bug in argument number check and removed unused variable 2010-12-14 18:42:29 +01:00
Houtan Bastani e32c8b1b76 k_order_perturbation: remove instances of mexErrMsgTxt and mexErrMsgIdAndTxt 2010-09-23 10:44:39 +02:00
Sébastien Villemot aa8963c1db K-order DLL: code simplification 2010-09-20 19:24:23 +02:00
Sébastien Villemot d7754ca288 K-order DLL: make it compatible with changes introduced in
648c3cd177
2010-09-20 18:30:00 +02:00
Sébastien Villemot 8589be3d4b K-order DLL: cosmetic changes
- remove unused argument of the DLL
- fix documentation inside source file
2010-08-30 17:11:58 +02:00
Sébastien Villemot a4769fc80d K-order DLL: no longer create an extra MAT file (useless and undocumented) 2010-08-30 17:11:26 +02:00