Commit Graph

255 Commits (edede274f27e1fcd4d43037e0cebae105c37adbd)

Author SHA1 Message Date
Houtan Bastani a93c6681c7
clang: can’t print non POD type through variadic function 2019-04-01 16:05:47 +02:00
Houtan Bastani 51d7508c7f
dynare++: _SC_AVPHYS_PAGES is not defined on macOS 2019-04-01 15:47:35 +02:00
Houtan Bastani 4120ce6730
dynare++: include needed on macOS 2019-04-01 14:54:20 +02:00
Sébastien Villemot 418cfa558b
Dynare++: fix compilation failure under macOS
We still need to properly define available memory.

[skip ci]
2019-04-01 11:22:04 +02:00
Sébastien Villemot 149fde1e74
Dynare++: detect Windows by testing for _WIN32 rather than __MINGW32__ 2019-04-01 11:16:04 +02:00
Sébastien Villemot 860e1e1c75
Dynare++: improve comments 2019-03-29 18:46:52 +01:00
Sébastien Villemot c41216819a
Dynare++: give more explicit names to some methods on quasi-triangular matrices 2019-03-29 15:28:26 +01:00
Sébastien Villemot 39896d8d0a
Dynare++: drop unused codepaths 2019-03-29 15:26:04 +01:00
Sébastien Villemot 44b40bbf09
Dynare++: improvements to comments
[skip ci]
2019-03-28 18:59:34 +01:00
Sébastien Villemot 5958848145
Dynare++: improve comments using Unicode (first batch)
[skip ci]
2019-03-27 19:22:51 +01:00
Sébastien Villemot 449553e7b6
Dynare++: various improvements 2019-03-08 15:32:30 +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 598f0193d5
Dynare++ kord library: make test failures fatal
Required an increase for the error tolerance of SW-like models tests.

By the way, decrease the tolerance for the small model.
2019-03-07 11:34:30 +01:00
Sébastien Villemot a7de121b01
Dynare++ kord library: some equations were incorrectly omitted from residual error checking 2019-03-07 10:39:33 +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 29daae72b4
Dynare++: minor modernization 2019-03-01 18:40:46 +01:00
Sébastien Villemot 81d9b08050
Dynare++ tensor library: various modernizations/improvements 2019-02-27 19:07:01 +01:00
Sébastien Villemot fc35f3a384
Dynare++: make more explicit the interface for extracting the Symmetry of an IntSequence 2019-02-27 17:01:37 +01:00
Sébastien Villemot 9751e6e199
Dynare++: simplify IntSequence by moving a special-purpose constructor into Symmetry 2019-02-27 15:43:22 +01:00
Sébastien Villemot 07ef21fdc7
Dynare++: more explicit interface for unfolding an IntSequence wrt a Symmetry 2019-02-27 15:29:06 +01:00
Sébastien Villemot d86101327e
Dynare++: more explicit interface for inserting into a IntSequence 2019-02-27 14:39:47 +01:00
Sébastien Villemot a062ea2b69
Dynare++ tensor library: various modernizations 2019-02-26 18:59:45 +01:00
Sébastien Villemot 1639f75a3c
Dynare++: improve interface to not-in-place matrix multiplications 2019-02-26 18:59:45 +01:00
Sébastien Villemot e3967bda9a
Dynare++: improve interface to matrix transpose 2019-02-26 18:59:45 +01:00
Sébastien Villemot 16cc191298
Dynare++ tensor library: last batch of modernizations of testsuite 2019-02-26 18:59:45 +01:00
Sébastien Villemot c44545bb18
Dynare++: add some comments 2019-02-26 12:43:04 +01:00
Sébastien Villemot 82e7f9250d
Dynare++: make the sparse tensors assignable 2019-02-22 17:44:07 +01:00
Sébastien Villemot 8751de896b
Dynare++: make tensor containers assignable 2019-02-22 16:54:00 +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 790c56612c
Dynare++ tensor library: changes to exception handling
- TL_RAISE now unconditionally raises an exception
- rathe use TL_RAISE_IF at some places, to save a test in non-debug mode
2019-02-20 18:07:07 +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 c8c6ec58a6
Dynare++: simplify TLException class 2019-02-20 17:23:37 +01:00
Sébastien Villemot ff57451474
Dynare++: simplifications made possible by new init-list constructor of IntSequence 2019-02-20 17:04:37 +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 9e1df25580
Dynare++: various simplifications 2019-02-20 14:36:35 +01:00
Sébastien Villemot 02d6f86487
Dynare++ tensor library: use smart pointers in fold() and unfold() methods 2019-02-20 14:25:32 +01:00
Sébastien Villemot 72a445c348
Dynare++ tensor library doc: update for TLStatic; fix typo 2019-02-20 14:00:00 +01:00
Sébastien Villemot c0224a640c
Dynare++: small optimization in unfolded tensor indexing 2019-02-20 13:06:17 +01:00
Sébastien Villemot 30b8681731
Dynare++: make multinomial coeffs computation a method of IntSequence
Also improve on the comments.
2019-02-20 12:37:59 +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 0f37649755
Dynare++ tensor library: modernize normal moments computation 2019-02-19 12:53:02 +01:00
Sébastien Villemot d08ca8ca7f
Dynare++ tensor library: modernization of Kronecker product classes 2019-02-19 12:47:40 +01:00
Sébastien Villemot e91f48f2ce
Dynare++: modernize kord tests 2019-02-14 15:47:58 +01:00
Sébastien Villemot db6df6c73c
Dynare++ kord test: use modern pseudo-random number generator 2019-02-14 11:45:15 +01:00
Sébastien Villemot 49f85ceaca
Dynare++: rollback the std::shared_ptr change in Vector and ConstVector
The performance cost is too high to warrant the change.
2019-02-14 11:29:18 +01:00
Sébastien Villemot 23c9257f00
Dynare++: rollback the std::shared_ptr change in IntSequence
The performance cost is too high to warrant the change.
2019-02-14 11:05:19 +01:00
Sébastien Villemot 8dbc08e2c2
Dynare++: display real time elapsed in kord tests
Previously, only CPU time was displayed, which is misleading with
multithreading.
2019-02-13 18:31:03 +01:00
Sébastien Villemot 08a91079ce
Dynare++: change default # of threads to # logical CPUs divided by 2
Having twice less threads seems to give a better performance, probably because
BLAS is parallel.
2019-02-13 18:29:34 +01:00
Sébastien Villemot 579be3c5e2
Dynare tensor library tests: further modernizations 2019-02-13 16:35:06 +01:00
Sébastien Villemot 002e3d3770
Dynare++ tensor library: various simplifications/modernizations 2019-02-12 17:30:10 +01:00
Sébastien Villemot d9f0345213
Drop support for MatIO < 1.5 2019-02-12 15:58:29 +01:00
Sébastien Villemot 8e52940181
Dynare++ tensor library: first batch of simplifications for tests
Also make test failures fatal.
2019-02-12 15:18:24 +01:00
Sébastien Villemot 44d47ee560
Dynare++: refactor iterator over symmetries
Simplify the logic of iteration. Adapt the range-based for loop syntax.
2019-02-12 12:17:07 +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 19cc08b7e5
Dynare++: modernization and simplification of the IntSequence class
Similarly to Vector, it now uses a std::shared_ptr for managing the underlying
data.
2019-02-06 19:00:46 +01:00
Sébastien Villemot 099a1de607
Dynare++: further simplification in Vector class 2019-02-06 19:00:46 +01:00
Sébastien Villemot af722f438f
Dynare++: drop remaining "using namespace std" 2019-02-06 19:00:46 +01:00
Sébastien Villemot 8698b4c540
Dynare++: fix computation of IRFs
Since the introduction of the --burn option (in Dynare++ shipped with Dynare
4.3.0), the IRFs reported by Dynare++ were wrong.

The IRFs are computed using a generalized IRF method: the result is
the (average) difference between a simulation with shock and a simulation
without shock. The problem was that the two simulations were not using the same
starting point.

Closes #1634
2019-02-05 17:18:21 +01:00
Sébastien Villemot 3e5b4084b8
Dynare++: fix bug in new threading code
At the end of a thread, we must first notify the main thread waiting on the
condition variable, then unlock the mutex. We must do these two operations in
that order, otherwise there is a possibility of having the main process
destroying the condition variable before the thread tries to notify it (if all
other threads terminate at the same time and bring the counter down to zero).
For that reason, we cannot use std::notify_all_at_thread_exit().

Bug introduced in commit 752a02a36.
2019-02-02 09:05:02 +01:00
Sébastien Villemot 566d237ec3
Dynare++ tensor library: small simplification 2019-01-31 19:01:41 +01:00
Sébastien Villemot 342e8c7508
Dynare++ tensor library: further notation fixes in documentation
Also fix extensions of source files.
2019-01-31 19:01:41 +01:00
Sébastien Villemot a612c59ff3
Dynare++: remove leftover file from the transition away from CWEB 2019-01-31 19:01:40 +01:00
Sébastien Villemot c15602c658
Dynare++: convert doc of Sylvester module to LaTeX
Previously it was plain TeX.

This allows us to remove the test for pdfetex.
2019-01-31 12:14:12 +01:00
Sébastien Villemot 268d540d58
Dynare++: add tl.tex to distributed tarball
By the way, simplify Makefile rules.
2019-01-31 12:11:28 +01:00
Sébastien Villemot 4f7330cb52
Dynare++: add LaTeX overview of the Tensor Library
The material of this document comes from the introduction to the library that
had been lost in the move away from CWEB (formerly tl/cc/main.web).

This file gives a good overview of the library. It has been adapted from TeX to
LaTeX. Also I fixed a mistake in the Faà di Bruno's tensor formula.
2019-01-30 19:07:57 +01:00
Sébastien Villemot a122927872
Dynare++: another change related to default number of threads
Forgotten in commit 733308807.
2019-01-29 20:31:06 +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 edda6e3038
Dynare++ multithreading: simplification of mutex interface 2019-01-29 15:53:44 +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 3ce051d819
Dynare++ sylvester equation solver: various simplifications and improvements
In particular, the test binary now errors out in case of test failure.
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 a2f2814cb2
Dynare++: ensure that all calls to BLAS/LAPACK use the correct LD values
Many BLAS/LAPACK calls were making the assumption that LD==rows when passing
matrices. In some cases this was correct (because of implementation details,
in particular because how the copy constructor of GeneralMatrix is implemented).
But in other cases it was a bug.

With this commit, the actual value for LD is systematically used (this fixes
existing bugs and prevent possible future ones if the implementation details
were changed).
2019-01-24 15:27:09 +01:00
Sébastien Villemot fefccd4a1b
Reverts changes mistakenly added to commit f484942154. 2019-01-22 18:21:57 +01:00
Sébastien Villemot f484942154
Update dseries submodule 2019-01-22 18:10:16 +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 49c06f5c7f
Dynare++ / sylvester equation solver: print solver method when debugging
By the way, simplify copy constructor/assignment.
2019-01-22 11:58:28 +01:00
Sébastien Villemot f655c170b6
Dynare++ / sylvester equation solver: second batch of modernizations 2019-01-17 10:20:49 +01:00
Sébastien Villemot b0a7826cb9
Dynare++ / sylvester equation solver: first batch of modernizations 2019-01-15 19:04:13 +01:00
Sébastien Villemot 2666a4ce45
Dynare++: "make check" now fails if a numerical integration test fails
By the way, reactivate two tests that actually pass.
2019-01-15 19:04:13 +01:00
Sébastien Villemot 325b1a3bb5
Dynare++: remove quasi-Monte Carlo Normal quadrature
This quadrature is supposed to generate quadrature points that are
quasi-normally distributed. Basically it applies the inverse normal CDF to the
Halton low-discrepancy sequence.

The problem is that it gives poor numerical accuracy, and therefore fails the
tests.

Since it is actually used nowhere in Dynare++, remove that code.
2019-01-15 19:04:10 +01:00
Sébastien Villemot 8ebcd7cae6
Dynare++: 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 now done in
Dynare).

Ref #1632
2019-01-15 19:04:04 +01:00
Sébastien Villemot 2a82177304
Dynare++: enforce C++ Emacs mode for bison/flex files 2019-01-15 19:03:58 +01:00
Sébastien Villemot b8791e9f13
Dynare++: various modernizations of numerical integration library 2019-01-14 18:56:49 +01:00
Sébastien Villemot 4a72266d05
Dynare++: use std::unique_ptr for memory management of workers in thread groups 2019-01-14 12:35:46 +01:00
Sébastien Villemot 8bc450f5ac
Various modernizations 2019-01-10 18:24:04 +01:00
Sébastien Villemot d5fcfb6566
Remove class MemoryFile, rather rely on C++ I/O streams 2019-01-10 17:52:02 +01:00
Sébastien Villemot a8f12c5b76
A few more modernizations with clang-tidy 2019-01-10 14:50:49 +01:00
Sébastien Villemot e45d230a3d
Rename .dat file to standard .hh extension 2019-01-10 14:29:58 +01:00
Sébastien Villemot 6076a4ff0c
Remove Emacs local mode variable
No longer needed now that files have C++-specific extensions.
2019-01-10 14:26:14 +01:00
Sébastien Villemot 38c24347ff
Use C++14 std::conditional_t (instead of custom IF template) 2019-01-09 17:26:28 +01:00
Sébastien Villemot 922014c2fa
Port to C++11 using keyword
Performed using modernize-use-using from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html
2019-01-09 17:21:14 +01:00
Sébastien Villemot 60fd92ddce
Port to C++11 override keyword
Performed using modernize-use-override from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-override.html
2019-01-09 16:26:42 +01:00
Sébastien Villemot 9656904d41
Port to C++11 nullptr keyword
Performed using modernize-use-nullptr from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2019-01-09 16:25:31 +01:00
Sébastien Villemot 7df31f68d9
Port to C++ delete keyword
Performed using modernize-use-equals-delete from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-delete.html
2019-01-09 16:23:04 +01:00
Sébastien Villemot 197cbea919
Port to C++11 syntax for default constructors
Performed using modernize-use-equals-default from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html
2019-01-09 16:16:29 +01:00
Sébastien Villemot 1052046954
Port to C++11 emplace() method on containers
Performed using modernize-use-emplace from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html
2019-01-09 16:00:05 +01:00