Merge branch 'master' into ecb-master

time-shift
Stéphane Adjemia (Scylla) 2018-11-30 21:34:56 +01:00
commit 650c78f99d
Signed by untrusted user who does not match committer: stepan
GPG Key ID: A6D44CB9C64CE77B
108 changed files with 740 additions and 786 deletions

View File

@ -52,7 +52,7 @@ testsuite_matlab:
dependencies: dependencies:
- build_binaries - build_binaries
.testsuite_octave_template: &testsuite_octave_definition .testsuite_octave_template:
stage: test stage: test
variables: variables:
OPENBLAS_NUM_THREADS: 1 OPENBLAS_NUM_THREADS: 1
@ -74,13 +74,13 @@ testsuite_matlab:
- build_binaries - build_binaries
testsuite_octave_auto: testsuite_octave_auto:
<<: *testsuite_octave_definition extends: .testsuite_octave_template
only: only:
- tags - tags
- schedules - schedules
testsuite_octave_manual: testsuite_octave_manual:
<<: *testsuite_octave_definition extends: .testsuite_octave_template
except: except:
- tags - tags
- schedules - schedules

View File

@ -27,8 +27,6 @@ EXTRA_DIST = \
COPYING \ COPYING \
CONTRIBUTING.md \ CONTRIBUTING.md \
windows/dynare.nsi \ windows/dynare.nsi \
windows/mexopts-win32.bat \
windows/mexopts-win64.bat \
windows/README.txt \ windows/README.txt \
osx \ osx \
examples \ examples \

4
NEWS
View File

@ -11,7 +11,7 @@ The Windows packages are already available for download at:
The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon.
This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2018a) This release is compatible with MATLAB versions 7.5 (R2007b) to 9.4 (R2018a)
and with GNU Octave versions 4.4. and with GNU Octave versions 4.4.
Here is a list of the problems identified in version 4.5.5 and that have been Here is a list of the problems identified in version 4.5.5 and that have been
@ -57,7 +57,7 @@ The Windows packages are already available for download at:
The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon.
This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2018a) This release is compatible with MATLAB versions 7.5 (R2007b) to 9.4 (R2018a)
and with GNU Octave versions 4.2. and with GNU Octave versions 4.2.
Here is a list of the problems identified in version 4.5.4 and that have been Here is a list of the problems identified in version 4.5.4 and that have been

170
README.md
View File

@ -7,8 +7,6 @@
# Dynare # Dynare
[![Join the chat at https://gitter.im/DynareTeam](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/DynareTeam?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Described on the homepage: <http://www.dynare.org/> Described on the homepage: <http://www.dynare.org/>
Most users should use the precompiled package available for your OS, also Most users should use the precompiled package available for your OS, also
@ -40,19 +38,19 @@ Note that if you obtain the source code via git, you will need to install more t
The first section of this page gives general instructions, which apply to all platforms. Then some specific platforms are discussed. The first section of this page gives general instructions, which apply to all platforms. Then some specific platforms are discussed.
**NB**: Here, when we refer to 32-bit or 64-bit, we refer to the type of MATLAB installation, not the type of Windows installation. It is perfectly possible to run a 32-bit MATLAB on a 64-bit Windows: in that case, instructions for Windows 32-bit should be followed. To determine the type of your MATLAB installation, type: **Note:** Here, when we refer to 32-bit or 64-bit, we refer to the type of MATLAB installation, not the type of Windows installation. It is perfectly possible to run a 32-bit MATLAB on a 64-bit Windows: in that case, instructions for Windows 32-bit should be followed. To determine the type of your MATLAB installation, type:
```matlab ```matlab
>> computer >> computer
``` ```
at the MATLAB prompt: if it returns `PCWIN`, then you have a 32-bit MATLAB; if it returns `PCWIN64`, then you have a 64-bit MATLAB. at the MATLAB prompt: if it returns `PCWIN64`, `GLNX64` or `MACI64`, then you
have a 64-bit MATLAB; if it returns `PCWIN`, `MACI` or `GLNX`, then you have a
32-bit MATLAB.
**Contents** **Contents**
1. [**General Instructions**](#general-instructions) 1. [**General Instructions**](#general-instructions)
1. [**Debian or Ubuntu**](#debian-or-ubuntu) 1. [**Debian or Ubuntu**](#debian-or-ubuntu)
1. [**Fedora**](#fedora)
1. [**Windows**](#windows) 1. [**Windows**](#windows)
1. [**Windows Subsystem for Linux**](#windows-subsystem-for-linux)
1. [**macOS**](#macos) 1. [**macOS**](#macos)
## General Instructions ## General Instructions
@ -63,14 +61,16 @@ A number of tools and libraries are needed in order to recompile everything. You
- A POSIX compliant shell and an implementation of Make (mandatory) - A POSIX compliant shell and an implementation of Make (mandatory)
- The [GNU Compiler Collection](http://gcc.gnu.org/), with gcc, g++ and gfortran (mandatory) - The [GNU Compiler Collection](http://gcc.gnu.org/), with gcc, g++ and gfortran (mandatory)
- MATLAB (if you want to compile MEX for MATLAB) - MATLAB (if you want to compile the MEX for MATLAB)
- [GNU Octave](http://www.octave.org), with the development headers (if you want to compile MEX for Octave) - [GNU Octave](http://www.octave.org), with the development headers (if you
want to compile the MEX for Octave)
- [Boost libraries](http://www.boost.org), version 1.36 or later (with the filesystem library compiled) - [Boost libraries](http://www.boost.org), version 1.36 or later (with the filesystem library compiled)
- [Bison](http://www.gnu.org/software/bison/), version 2.5 or later (only if you get the source through Git) - [Bison](http://www.gnu.org/software/bison/), version 3.0 or later (only if you get the source through Git)
- [Flex](http://flex.sourceforge.net/), version 2.5.4 or later (only if you get the source through Git) - [Flex](http://flex.sourceforge.net/), version 2.5.4 or later (only if you get the source through Git)
- [Autoconf](http://www.gnu.org/software/autoconf/), version 2.62 or later (only if you get the source through Git) (see [Installing an updated version of Autoconf in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) - [Autoconf](http://www.gnu.org/software/autoconf/), version 2.62 or later (only if you get the source through Git) (see [Installing an updated version of Autoconf in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake))
- [Automake](http://www.gnu.org/software/automake/), version 1.11.2 or later (only if you get the source through Git) (see [Installing an updated version of AutoMake in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) - [Automake](http://www.gnu.org/software/automake/), version 1.11.2 or later (only if you get the source through Git) (see [Installing an updated version of AutoMake in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake))
- [CWEB](http://www-cs-faculty.stanford.edu/%7Eknuth/cweb.html), with its tools `ctangle` and `cweave` (only if you want to build Dynare++ and get the source through Git) - [CWEB](http://www-cs-faculty.stanford.edu/%7Eknuth/cweb.html), with its tools
`ctangle` and `cweave` (only if you want to build the k-order DLL or Dynare++, and get the source through Git)
- An implementation of BLAS and LAPACK: either [ATLAS](http://math-atlas.sourceforge.net/), [OpenBLAS](http://xianyi.github.com/OpenBLAS/), Netlib ([BLAS](http://www.netlib.org/blas/), [LAPACK](http://www.netlib.org/lapack/)) or [MKL](http://software.intel.com/en-us/intel-mkl/) (only if you want to build Dynare++) - An implementation of BLAS and LAPACK: either [ATLAS](http://math-atlas.sourceforge.net/), [OpenBLAS](http://xianyi.github.com/OpenBLAS/), Netlib ([BLAS](http://www.netlib.org/blas/), [LAPACK](http://www.netlib.org/lapack/)) or [MKL](http://software.intel.com/en-us/intel-mkl/) (only if you want to build Dynare++)
- An implementation of [POSIX Threads](http://en.wikipedia.org/wiki/POSIX_Threads) (optional, for taking advantage of multi-core) - An implementation of [POSIX Threads](http://en.wikipedia.org/wiki/POSIX_Threads) (optional, for taking advantage of multi-core)
- [MAT File I/O library](http://sourceforge.net/projects/matio/) (if you want to compile Markov-Switching code, the estimation DLL, k-order DLL and Dynare++) - [MAT File I/O library](http://sourceforge.net/projects/matio/) (if you want to compile Markov-Switching code, the estimation DLL, k-order DLL and Dynare++)
@ -109,8 +109,6 @@ If you have MATLAB, you need to indicate both the MATLAB location and version. F
``` ```
Note that the MATLAB version can also be specified via the MATLAB family product release (R2009a, R2008b, ...). Note that the MATLAB version can also be specified via the MATLAB family product release (R2009a, R2008b, ...).
**NB**: For MATLAB versions strictly older than 7.1, you need to explicitly give the MEX extension, via `MEXEXT` variable of the configure script (for example, `MEXEXT=dll` for Windows with MATLAB \< 7.1).
Alternatively, you can disable the compilation of MEX files for MATLAB with the `--disable-matlab` flag, and MEX files for Octave with `--disable-octave`. Alternatively, you can disable the compilation of MEX files for MATLAB with the `--disable-matlab` flag, and MEX files for Octave with `--disable-octave`.
You may need to specify additional options to the configure script, see the platform specific instructions below. You may need to specify additional options to the configure script, see the platform specific instructions below.
@ -119,14 +117,14 @@ Note that if you don't want to compile the C/C++ programs with debugging informa
``` ```
./configure CFLAGS="-O3" CXXFLAGS="-O3" ./configure CFLAGS="-O3" CXXFLAGS="-O3"
``` ```
To remove debugging information for Matlab mex functions, the analagous call would be: To remove debugging information for MATLAB MEX functions, the analagous call would be:
``` ```
./configure MATLAB_MEX_CFLAGS="-O3" MATLAB_MEX_CXXFLAGS="-O3" ./configure MATLAB_MEX_CFLAGS="-O3" MATLAB_MEX_CXXFLAGS="-O3"
``` ```
If you want to give a try to the parallelized versions of some mex files (`A_times_B_kronecker_C` and `sparse_hessian_times_B_kronecker_C` used to get the reduced form of the second order approximation of the model) you can add the `--enable-openmp` flag, for instance: If you want to give a try to the parallelized versions of some mex files (`A_times_B_kronecker_C` and `sparse_hessian_times_B_kronecker_C` used to get the reduced form of the second order approximation of the model) you can add the `--enable-openmp` flag, for instance:
``` ```
./configure --with-matlab=/usr/local/matlab78 MATLAB_VERSION=7.8 --enable-openmp ./configure --with-matlab=/usr/local/MATLAB/R2013a MATLAB_VERSION=8.1 --enable-openmp
``` ```
If the configuration goes well, the script will tell you which components are correctly configured and will be built. If the configuration goes well, the script will tell you which components are correctly configured and will be built.
@ -151,12 +149,12 @@ Note that running the testsuite with Octave requires the additional packages
### Check ### Check
The Git source comes with unit tests (in the matlab functions) and integration tests (under the `tests` subfolder). All the tests can be run with: The Git source comes with unit tests (in the MATLAB functions) and integration tests (under the `tests` subfolder). All the tests can be run with:
``` ```
make check make check
``` ```
In the `tests` subfolder. If Dynare has been compiled against Matlab and Octave, the tests will be run with Matlab and Octave. Depending on In the `tests` subfolder. If Dynare has been compiled against MATLAB and Octave, the tests will be run with MATLAB and Octave. Depending on
your PC, this can take several hours. It is possible to run the tests only with Matlab: your PC, this can take several hours. It is possible to run the tests only with MATLAB:
``` ```
make check-matlab make check-matlab
``` ```
@ -170,7 +168,7 @@ subset of the integration tests, with:
``` ```
make deterministic_simulations make deterministic_simulations
``` ```
This will run all the integration tests in `tests/deterministic_simulations` with Matlab and Octave. Again, it is possible to do this only with Matlab: This will run all the integration tests in `tests/deterministic_simulations` with MATLAB and Octave. Again, it is possible to do this only with MATLAB:
``` ```
make m/deterministic_simulations make m/deterministic_simulations
``` ```
@ -178,7 +176,7 @@ or with Octave:
``` ```
make o/deterministic_simulations make o/deterministic_simulations
``` ```
Finally if you want to run a single integration test, e.g. `deterministic_simulations/lbj/rbc.mod` with Matlab: Finally if you want to run a single integration test, e.g. `deterministic_simulations/lbj/rbc.mod` with MATLAB:
``` ```
make deterministic_simulations/lbj/rbc.m.trs make deterministic_simulations/lbj/rbc.m.trs
``` ```
@ -202,26 +200,13 @@ in the `tests` folder to delete files that were created by the run of the testsu
## Debian or Ubuntu ## Debian or Ubuntu
All the prerequisites are packaged. All the prerequisites are packaged:
The easiest way to install the pre-requisites in Debian is to use Debian's dynare package and do
(requires that you have added the `deb-src` repositories to your `sources.list`):
```
apt-get build-dep dynare
```
followed by (only for building the master branch):
```
apt-get install texlive-fonts-extra
```
which is missing in Debian's list of pre-requisites.
Alternatively, if you want to build everything, manually install the following packages:
- `build-essential` (for gcc, g++ and make) - `build-essential` (for gcc, g++ and make)
- `gfortran` - `gfortran`
- `liboctave-dev` (or `octave3.2-headers` on older systems) - `liboctave-dev`
- `libboost-graph-dev` and `libboost-filesystem-dev` - `libboost-graph-dev` and `libboost-filesystem-dev`
- `libgsl-dev` (or `libgsl0-dev` on older systems) - `libgsl-dev`
- `libmatio-dev` - `libmatio-dev`
- `libslicot-dev` and `libslicot-pic` - `libslicot-dev` and `libslicot-pic`
- `libsuitesparse-dev` - `libsuitesparse-dev`
@ -235,65 +220,92 @@ Alternatively, if you want to build everything, manually install the following p
- `texlive-formats-extra` (for Eplain) - `texlive-formats-extra` (for Eplain)
- `texlive-latex-extra` (for fullpage.sty) - `texlive-latex-extra` (for fullpage.sty)
- `texlive-fonts-extra` (for ccicons) - `texlive-fonts-extra` (for ccicons)
- `texlive-latex-recommended` (or `latex-beamer` on older systems) - `texlive-latex-recommended`
- `texlive-science` (or `texlive-math-extra` on older systems) (for amstex) - `texlive-science` (for amstex)
- `texinfo` - `texinfo`
- `lmodern` (for macroprocessor PDF) - `lmodern` (for macroprocessor PDF)
- `latex2html` - `latex2html`
- `doxygen` - `doxygen`
You can load all necessary packages at once with You can install them all at once with:
``` ```
sudo apt install build-essential gfortran liboctave-dev libboost-graph-dev libboost-filesystem-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-extra-utils texlive-formats-extra texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texinfo lmodern latex2html doxygen apt install build-essential gfortran liboctave-dev libboost-graph-dev libboost-filesystem-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-extra-utils texlive-formats-extra texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texinfo lmodern latex2html doxygen
``` ```
## Fedora
**NB**: Documentation still in progress…
- `octave-devel`
- `boost-devel`
- `gsl-devel`
- `matio-devel`
- `flex`
- `bison`
- `autoconf`
- `automake`
- `texlive`
- `texinfo`
- `latex2html`
- `doxygen`
## Windows ## Windows
We no longer support compilation on Windows. To use the unstable version of Dynare on a Windows system, please download it from the [Dynare website](http://www.dynare.org/download/dynare-unstable). - Install [MSYS2](http://www.msys2.org) (pick the 64-bit version)
- Run a MSYS MinGW 64-bit shell
## Windows Subsystem for Linux - Update the system:
Dynare can also be compiled from source for the Windows Subsystem for Linux (WSL). The WSL offers Windows 10 Anniversary Update users easy access to a Linux environment. To install the WSL, see https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
To install most of the build dependencies, make sure that the local `rootfs/etc/apt/sources.list` contains
``` ```
deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse pacman -Syu
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse ```
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse You may be asked to close the window at the end of the
first upgrade batch, in which case you should rerun the upgrade in a new
window to complete the upgrade.
- Install all needed dependencies:
```
pacman -S git autoconf automake-wrapper bison flex make tar texinfo mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-boost mingw-w64-x86_64-gsl mingw-w64-x86_64-matio mingw-w64-x86_64-openblas
```
- **(Optional)** compile and install `ctangle`, needed for the k-order MEX file and for
Dynare++ (*i.e.* if you want to solve models at order ≥ 3)
```
wget ftp://ftp.cs.stanford.edu/pub/cweb/cweb.tar.gz
mkdir cweb
cd cweb
tar xf ../cweb.tar.gz
make ctangle
mkdir -p /usr/local/bin
cp ctangle.exe /usr/local/bin/
cd ..
```
- **(Optional)** compile and install SLICOT, needed for the `kalman_steady_state`
MEX file
```
wget https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz
tar xf slicot_5.0+20101122.orig.tar.gz
cd slicot-5.0+20101122
make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran slicot.a
mkdir -p /usr/local/lib
cp slicot.a /usr/local/lib/libslicot64_pic.a
cd ..
```
- Clone and prepare the Dynare sources:
```
git clone --recursive https://git.dynare.org/Dynare/dynare.git
cd dynare
autoreconf -si
```
- Configure Dynare:
```
./configure --with-boost-system=boost_system-mt --with-boost-filesystem=boost_filesystem-mt --with-slicot=/usr/local --with-matlab=<…> MATLAB_VERSION=<…> --disable-octave
```
where the path and version of MATLAB are specified. Note that you should use
the MSYS2 notation and not put spaces in the MATLAB path, so you probably want
to use something like `/c/Progra~1/MATLAB/…`.
- Compile:
```
make
```
- Run the testsuite:
```
make -C tests check-matlab
``` ```
in addition to the regular ```deb``` entries.
NB: you cannot edit this file from Windows as this will make the file unreadable for the WSL (rendering WSL unable to detect any package). Therefore, use any Linux editor of your choice.
After that, run **Note:** The above assumes that you have a 64-bit version of MATLAB. It can be
``` adapted to a 32-bit MATLAB with the following modifications:
apt update
apt-get build-dep dynare - run the MSYS MinGW 32-bit shell
``` - replace `x86_64` by `i686` in packages names on the `pacman` command-line
If you are building the unstable version, you might also need to install other packages required, e.g - for SLICOT, remove the `-fdefault-integer-8` option, and instead copy the
```apt-get install texlive-fonts-extra``` library into `/usr/local/lib/libslicot_pic.a`
NB: it might be necessary to preface your calls by ```sudo``` in case you do not have root access with the current user
**Note:** Compiling the MEX files for Octave and the documentation under MSYS2 is
currently not supported.
After this, prepare the source and configure the build tree as described for Linux above.
## macOS ## macOS
To simply use a snapshot of Dynare, you have two choices. On Matlab, you can To simply use a snapshot of Dynare, you have two choices. On MATLAB, you can
use the [snapshot build](http://www.dynare.org/snapshot/macosx/) provided by use the [snapshot build](http://www.dynare.org/snapshot/macosx/) provided by
Dynare. On Octave, you can simply install [Homebrew](https://brew.sh/) and run Dynare. On Octave, you can simply install [Homebrew](https://brew.sh/) and run
```brew install dynare --HEAD``` (See the Install Dynare (unstable) section of ```brew install dynare --HEAD``` (See the Install Dynare (unstable) section of
@ -330,7 +342,7 @@ folder where you want Dynare installed.
- `cd dynare` - `cd dynare`
- `PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH"` - `PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH"`
- `autoreconf -si` - `autoreconf -si`
- `./configure --disable-octave --with-matlab=/Applications/MATLAB_R2017b.app MATLAB_VERSION=R2017b`, adjusting the Matlab path and version to accord with your local installation. If you don't have Matlab, simply type `./configure --disable-octave` - `./configure --disable-octave --with-matlab=/Applications/MATLAB_R2017b.app MATLAB_VERSION=R2017b`, adjusting the MATLAB path and version to accord with your local installation. If you don't have MATLAB, simply type `./configure --disable-octave`
- `make -j` - `make -j`
- **(Optional)** To then build mex files for Octave, run - **(Optional)** To then build mex files for Octave, run
- `cd mex/build/octave` - `cd mex/build/octave`

View File

@ -30,9 +30,9 @@ AC_PROG_CXX
AC_CANONICAL_HOST AC_CANONICAL_HOST
case ${host_os} in case ${host_os} in
*mingw32*) *mingw32*)
# On mingw32, we don't want dynamic libgcc # On Windows, we want Dynare++ to be statically linked
# Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions) AM_LDFLAGS="-static"
LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -static-libgfortran" AC_SUBST([AM_LDFLAGS])
have_windows="yes" have_windows="yes"
;; ;;
*cygwin*) *cygwin*)
@ -51,7 +51,8 @@ esac
# Use C++ for testing headers # Use C++ for testing headers
AC_LANG([C++]) AC_LANG([C++])
CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses" AM_CXXFLAGS="-Wall -Wno-parentheses"
AC_SUBST([AM_CXXFLAGS])
# If default 'ar' is not available, try to find one with a host prefix (see ticket #145) # If default 'ar' is not available, try to find one with a host prefix (see ticket #145)
AC_CHECK_PROGS([AR], [ar ${host_alias}-ar]) AC_CHECK_PROGS([AR], [ar ${host_alias}-ar])
@ -125,11 +126,6 @@ AM_CONDITIONAL([HAVE_CWEAVE], [test "x$CWEAVE" != "x"])
AC_PROG_F77 AC_PROG_F77
AC_F77_LIBRARY_LDFLAGS AC_F77_LIBRARY_LDFLAGS
case ${host_os} in case ${host_os} in
*mingw32*)
# Hack to get static linking of libgfortran on MinGW
# (-static-libgfortran doesn't act on gcc/g++)
FLIBS=`echo $FLIBS | sed 's/-lgfortran/-Wl,-Bstatic -lgfortran -Wl,-Bdynamic/'`
;;
*darwin*) *darwin*)
# * OS X doesn't need to link against the Fortran libraries because # * OS X doesn't need to link against the Fortran libraries because
# everything is contained within the vecLib framework. # everything is contained within the vecLib framework.
@ -144,12 +140,6 @@ fi
AM_CONDITIONAL([HAVE_BLAS], [test x"$ax_blas_ok" = "xyes"]) AM_CONDITIONAL([HAVE_BLAS], [test x"$ax_blas_ok" = "xyes"])
AM_CONDITIONAL([HAVE_LAPACK], [test x"$ax_lapack_ok" = "xyes"]) AM_CONDITIONAL([HAVE_LAPACK], [test x"$ax_lapack_ok" = "xyes"])
case ${host_os} in
*mingw32*)
# Ensure that -lpthread is statically linked under MinGW
PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic"
;;
esac
AX_PTHREAD AX_PTHREAD
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
@ -185,6 +175,13 @@ AC_ARG_ENABLE([matlab], AS_HELP_STRING([--disable-matlab], [disable compilation
if test "x$enable_matlab" = "xyes"; then if test "x$enable_matlab" = "xyes"; then
AC_CONFIG_SUBDIRS([mex/build/matlab]) AC_CONFIG_SUBDIRS([mex/build/matlab])
AX_MATLAB AX_MATLAB
AX_MATLAB_ARCH
if test "${MATLAB_ARCH}" = win32 -o "${MATLAB_ARCH}" = win64; then
MATLAB_BATCH_OPTIONS='-nosplash -automation -wait -sd "$(CURDIR)"'
else
MATLAB_BATCH_OPTIONS='-nosplash -nodisplay'
fi
AC_SUBST([MATLAB_BATCH_OPTIONS])
fi fi
AM_CONDITIONAL([ENABLE_MATLAB], [test "x$enable_matlab" = "xyes"]) AM_CONDITIONAL([ENABLE_MATLAB], [test "x$enable_matlab" = "xyes"])
AM_CONDITIONAL([HAVE_CMD_LINE_MATLAB], [test "x$ax_enable_matlab" = "xyes" -a "x$have_windows" = "x"]) AM_CONDITIONAL([HAVE_CMD_LINE_MATLAB], [test "x$ax_enable_matlab" = "xyes" -a "x$have_windows" = "x"])

View File

@ -472,7 +472,7 @@ In order to run Dynare, you need one of the following:
@itemize @itemize
@item @item
MATLAB version 7.5 (R2007b) or above (MATLAB R2009b 64-bit for macOS); MATLAB version 7.9 (R2009b) or above;
@item @item
GNU Octave version 4.2.1 or above. GNU Octave version 4.2.1 or above.
@ -599,36 +599,29 @@ Octave comes with built-in functionality for compiling mex-files.
@node Prerequisites on Windows @node Prerequisites on Windows
@subsection Prerequisites on Windows @subsection Prerequisites on Windows
If you are using MATLAB under Windows, install a C++ compiler on your machine and configure it with There is no prerequisite on Windows. Dynare now ships a compilation environment
MATLAB. There are at least two free compilers you can use. First, there is Microsoft's Visual Studio that can be used with the @code{use_dll} option.
Community (@uref{https://www.visualstudio.com/}), which has the largest history of MATLAB support, but
requires much space on the hard-disk. Second, since MATLAB R2015b, MATLAB supports the MinGW-w64 C/C++
Compiler from TDM-GCC. To install this compiler, use the Add-Ons menu of MATLAB. Search for MinGW or
select it from Features.
For older version of MATLAB, in particular before R2014a, it may sometimes make sense to use the gcc compiler
provided by Cygwin. However, integrating it in MATLAB can be quite cumbersome and should be considered as a
legacy option. For details, see
@uref{http://www.dynare.org/DynareWiki/ConfigureMatlabWindowsForMexCompilation,instructions
on the Dynare wiki}.
@node Prerequisites on Debian GNU/Linux and Ubuntu @node Prerequisites on Debian GNU/Linux and Ubuntu
@subsection Prerequisites on Debian GNU/Linux and Ubuntu @subsection Prerequisites on Debian GNU/Linux and Ubuntu
Users of MATLAB under Linux need to have a working compilation environment installed. If not already present, Users of MATLAB under GNU/Linux need a working compilation environment
it can be installed via @code{apt-get install build-essential}. installed. If not already present, it can be installed via @code{apt install
build-essential}.
Users of Octave under Linux should install the package for MEX file compilation Users of Octave under GNU/Linux should install the package for MEX file compilation
(under Debian or Ubuntu, it is called @file{liboctave-dev}). (under Debian or Ubuntu, it is called @file{liboctave-dev}).
@node Prerequisites on macOS @node Prerequisites on macOS
@subsection Prerequisites on macOS @subsection Prerequisites on macOS
[TO BE UPDATED]
If you are using MATLAB under macOS, you should install the latest If you are using MATLAB under macOS, you should install the latest
version of XCode: see version of XCode: see
@uref{http://www.dynare.org/DynareWiki/InstallOnMacOSX,instructions on @uref{http://www.dynare.org/DynareWiki/InstallOnMacOSX,instructions on
the Dynare wiki}. the Dynare wiki}.
@node Configuration @node Configuration
@section Configuration @section Configuration
@ -848,6 +841,13 @@ line numbering directives.
Passing this option removes all empty from the macro expanded mod file created Passing this option removes all empty from the macro expanded mod file created
when the @code{savemacro} option is used. when the @code{savemacro} option is used.
@item onlymodel
Instructs the preprocessor to print only information about the model in the
driver file; no Dynare commands (other than the shocks statement and parameter
initializations) are printed and hence no computational tasks performed. NB:
the same ancillary files are created as would otherwise be created (dynamic,
static files, etc.).
@item nolog @item nolog
Instructs Dynare to no create a logfile of this run in Instructs Dynare to no create a logfile of this run in
@file{@var{FILENAME}.log}. The default is to create the logfile. @file{@var{FILENAME}.log}. The default is to create the logfile.
@ -923,22 +923,14 @@ command).
Prevent Dynare from printing the output of the steps leading up to the Prevent Dynare from printing the output of the steps leading up to the
preprocessor as well as the preprocessor output itself. preprocessor as well as the preprocessor output itself.
@item mingw @item mexext=mex|mexw32|mexw64|mexmaci64|mexa64
Tells Dynare that your MATLAB is configured for compiling MEX files with the The mex extension associated with your platform to be used when compiling
MinGW-compiler from TDM-GCC (@pxref{Compiler installation}). This option is output associated with @code{use_dll}. NB: Dynare is able to set this
only available under Windows, and is used in conjunction with automatically, so you should not need to set it yourself.
@code{use_dll}.
@item msvc @item matlabroot=@var{<<path>>}
Tells Dynare that your MATLAB is configured for compiling MEX files with The path to the Matlab installation for use with @code{use_dll}. NB: Dynare is
Microsoft Visual C++ (@pxref{Compiler installation}). This option is able to set this automatically, so you should not need to set it yourself.
only available under Windows, and is used in conjunction with
@code{use_dll}.
@item cygwin
Tells Dynare that your MATLAB is configured for compiling MEX files with
Cygwin (@pxref{Compiler installation}). This option is only available
under Windows, and is used in conjunction with @code{use_dll}.
@item parallel[=@var{CLUSTER_NAME}] @item parallel[=@var{CLUSTER_NAME}]
Tells Dynare to perform computations in parallel. If @var{CLUSTER_NAME} Tells Dynare to perform computations in parallel. If @var{CLUSTER_NAME}
@ -15074,7 +15066,7 @@ Cycles: The Cycle is the Trend,'' @i{NBER Working Paper}, 10734
Amisano, Gianni and Tristani, Oreste (2010): ``Euro area inflation persistence in an estimated nonlinear DSGE model'', @i{Journal of Economic Dynamics and Control}, 34(10), 1837--1858 Amisano, Gianni and Tristani, Oreste (2010): ``Euro area inflation persistence in an estimated nonlinear DSGE model'', @i{Journal of Economic Dynamics and Control}, 34(10), 1837--1858
@item @item
Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2013): ``The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,'' @i{NBER Working Paper}, 18983 Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2018): ``The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,'' @i{Review of Economic Studies}, 85(1), 1--49
@item @item
Andrews, Donald W.K (1991): ``Heteroskedasticity and autocorrelation consistent covariance matrix estimation'', Andrews, Donald W.K (1991): ``Heteroskedasticity and autocorrelation consistent covariance matrix estimation'',
@ -15098,10 +15090,10 @@ and Control}, 19, 711--734
@item @item
Brooks, Stephen P., and Andrew Gelman (1998): ``General methods for Brooks, Stephen P., and Andrew Gelman (1998): ``General methods for
monitoring convergence of iterative simulations,'' @i{Journal of monitoring convergence of iterative simulations,'' @i{Journal of
computational and graphical statistics}, 7, pp. 434--455 Computational and Graphical Statistics}, 7, pp. 434--455
@item @item
Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): ``The simplex simulated annealing approach to continuous non-linear optimization,'' @i{Computers chem. Engng}, 20(9), 1065-1080 Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): ``The simplex simulated annealing approach to continuous non-linear optimization,'' @i{Computers & Chemical Engineering}, 20(9), 1065-1080
@item @item
Chib, Siddhartha and Srikanth Ramamurthy (2010): Chib, Siddhartha and Srikanth Ramamurthy (2010):

View File

@ -26,7 +26,7 @@ noinst_LIBRARIES = libinteg.a
libinteg_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) precalc_quadrature.dat libinteg_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) precalc_quadrature.dat
libinteg_a_CPPFLAGS = -I../../sylv/cc -I../../tl/cc -I$(top_srcdir)/mex/sources libinteg_a_CPPFLAGS = -I../../sylv/cc -I../../tl/cc -I$(top_srcdir)/mex/sources
libinteg_a_CXXFLAGS = $(PTHREAD_CFLAGS) libinteg_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)

View File

@ -2,5 +2,5 @@ noinst_PROGRAMS = quadrature-points
quadrature_points_SOURCES = quadrature-points.cpp quadrature_points_SOURCES = quadrature-points.cpp
quadrature_points_CPPFLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc quadrature_points_CPPFLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc
quadrature_points_CXXFLAGS = $(PTHREAD_CFLAGS) quadrature_points_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
quadrature_points_LDADD = ../cc/libinteg.a ../../tl/cc/libtl.a ../../parser/cc/libparser.a ../../sylv/cc/libsylv.a ../../utils/cc/libutils.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) quadrature_points_LDADD = ../cc/libinteg.a ../../tl/cc/libtl.a ../../parser/cc/libparser.a ../../sylv/cc/libsylv.a ../../utils/cc/libutils.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)

View File

@ -2,8 +2,8 @@ check_PROGRAMS = tests
tests_SOURCES = tests.cpp tests_SOURCES = tests.cpp
tests_CPPFLAGS = -I../cc -I../../tl/cc -I../../sylv/cc -I$(top_srcdir)/mex/sources tests_CPPFLAGS = -I../cc -I../../tl/cc -I../../sylv/cc -I$(top_srcdir)/mex/sources
tests_CXXFLAGS = $(PTHREAD_CFLAGS) tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
tests_LDFLAGS = $(LDFLAGS_MATIO) tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO)
tests_LDADD = ../../tl/cc/libtl.a ../../sylv/cc/libsylv.a ../cc/libinteg.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) tests_LDADD = ../../tl/cc/libtl.a ../../sylv/cc/libsylv.a ../cc/libinteg.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO)
check-local: check-local:

View File

@ -54,7 +54,7 @@ noinst_LIBRARIES = libkord.a
libkord_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) libkord_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES)
libkord_a_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources $(CPPFLAGS_MATIO) libkord_a_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources $(CPPFLAGS_MATIO)
libkord_a_CXXFLAGS = $(PTHREAD_CFLAGS) libkord_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)
@ -64,8 +64,8 @@ check_PROGRAMS = tests
tests_SOURCES = tests.cpp tests_SOURCES = tests.cpp
tests_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources tests_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources
tests_CXXFLAGS = $(PTHREAD_CFLAGS) tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
tests_LDFLAGS = $(LDFLAGS_MATIO) tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO)
tests_LDADD = libkord.a ../tl/cc/libtl.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) tests_LDADD = libkord.a ../tl/cc/libtl.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO)
check-local: check-local:

View File

@ -22,9 +22,9 @@ dynare___SOURCES = \
$(GENERATED_FILES) $(GENERATED_FILES)
dynare___CPPFLAGS = -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I.. -I$(top_srcdir)/mex/sources -DDYNVERSION=\"$(PACKAGE_VERSION)\" $(BOOST_CPPFLAGS) $(CPPFLAGS_MATIO) dynare___CPPFLAGS = -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I.. -I$(top_srcdir)/mex/sources -DDYNVERSION=\"$(PACKAGE_VERSION)\" $(BOOST_CPPFLAGS) $(CPPFLAGS_MATIO)
dynare___LDFLAGS = $(LDFLAGS_MATIO) $(BOOST_LDFLAGS) dynare___LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO) $(BOOST_LDFLAGS)
dynare___LDADD = ../kord/libkord.a ../integ/cc/libinteg.a ../tl/cc/libtl.a ../parser/cc/libparser.a ../utils/cc/libutils.a ../sylv/cc/libsylv.a $(LIBADD_MATIO) $(noinst_LIBRARIES) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) dynare___LDADD = ../kord/libkord.a ../integ/cc/libinteg.a ../tl/cc/libtl.a ../parser/cc/libparser.a ../utils/cc/libutils.a ../sylv/cc/libsylv.a $(LIBADD_MATIO) $(noinst_LIBRARIES) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
dynare___CXXFLAGS = $(PTHREAD_CFLAGS) dynare___CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = dynglob.lex dynglob.y EXTRA_DIST = dynglob.lex dynglob.y

View File

@ -92,7 +92,7 @@ noinst_LIBRARIES = libtl.a
libtl_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) libtl_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES)
libtl_a_CPPFLAGS = -I../../sylv/cc $(CPPFLAGS_MATIO) libtl_a_CPPFLAGS = -I../../sylv/cc $(CPPFLAGS_MATIO)
libtl_a_CXXFLAGS = $(PTHREAD_CFLAGS) libtl_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)

View File

@ -2,8 +2,8 @@ check_PROGRAMS = tests
tests_SOURCES = factory.cpp factory.h monoms.cpp monoms.h tests.cpp tests_SOURCES = factory.cpp factory.h monoms.cpp monoms.h tests.cpp
tests_CPPFLAGS = -I../cc -I../../sylv/cc tests_CPPFLAGS = -I../cc -I../../sylv/cc
tests_CXXFLAGS = $(PTHREAD_CFLAGS) tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
tests_LDFLAGS = $(LDFLAGS_MATIO) tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO)
tests_LDADD = ../cc/libtl.a ../../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) tests_LDADD = ../cc/libtl.a ../../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO)
check-local: check-local:

View File

@ -44,6 +44,8 @@ AC_ARG_WITH(matio, AC_HELP_STRING([--with-matio=DIR], [prefix to MATIO installat
dnl If detected, libz and libhdf5 are added to LIBS, used for matio test dnl If detected, libz and libhdf5 are added to LIBS, used for matio test
LIBS="" LIBS=""
AC_CHECK_LIB([z], [compress]) AC_CHECK_LIB([z], [compress])
dnl szip is needed under MSYS2
AC_CHECK_LIB([szip], [SZ_Compress])
AC_CHECK_LIB([hdf5], [H5Fcreate]) AC_CHECK_LIB([hdf5], [H5Fcreate])
AC_CHECK_HEADER([matio.h], [], [has_matio=no]) AC_CHECK_HEADER([matio.h], [], [has_matio=no])

View File

@ -41,13 +41,13 @@ else
AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.1], [AC_MSG_ERROR([I can't determine the MEX file extension. Please explicitly indicate it to the configure script with the MEXEXT variable.])]) AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.1], [AC_MSG_ERROR([I can't determine the MEX file extension. Please explicitly indicate it to the configure script with the MEXEXT variable.])])
case $build_os in case $build_os in
*cygwin*) *cygwin*)
ax_cv_mexext=`$MATLAB/bin/mexext.bat | sed 's/\r//'` ax_cv_mexext=$("$MATLAB"/bin/mexext.bat | sed 's/\r//')
;; ;;
*mingw*) *mingw*)
ax_cv_mexext=`cd $MATLAB/bin && cmd /c mexext.bat | sed 's/\r//'` ax_cv_mexext=$(cd "$MATLAB"/bin && cmd /c mexext.bat | sed 's/\r//')
;; ;;
*) *)
ax_cv_mexext=`$MATLAB/bin/mexext` ax_cv_mexext=$("$MATLAB"/bin/mexext)
;; ;;
esac esac
fi]) fi])

View File

@ -22,7 +22,7 @@ AC_REQUIRE([AX_MATLAB_ARCH])
AC_REQUIRE([AX_MATLAB_VERSION]) AC_REQUIRE([AX_MATLAB_VERSION])
AC_REQUIRE([AC_PROG_SED]) AC_REQUIRE([AC_PROG_SED])
AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to 7.5 (R2007b) at least.])]) AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.9], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to 7.9 (R2009b) at least.])])
AC_MSG_CHECKING([for options to compile MEX for MATLAB]) AC_MSG_CHECKING([for options to compile MEX for MATLAB])

View File

@ -194,7 +194,7 @@ while fpar<B
end end
if MAX_nirfs_dsgevar if MAX_nirfs_dsgevar
IRUN = IRUN+1; IRUN = IRUN+1;
[fval,info,junk1,junk2,junk3,junk3,junk4,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); [fval,info,~,~,~,~,~,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names)); dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight)); DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1))); SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));

View File

@ -93,7 +93,7 @@ for j=1:nvar
d0={}; d0={};
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks if screen_shocks
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1); zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];

View File

@ -33,7 +33,7 @@ if isoctave
else else
% Add win32 specific paths for Dynare Windows package % Add win32 specific paths for Dynare Windows package
if strcmp(computer, 'PCWIN') if strcmp(computer, 'PCWIN')
tmp = [dynareroot '../mex/matlab/win32-7.5-8.6/']; tmp = [dynareroot '../mex/matlab/win32-7.9-8.6/'];
if exist(tmp, 'dir') if exist(tmp, 'dir')
mexpath = tmp; mexpath = tmp;
if modifypath if modifypath
@ -43,16 +43,8 @@ else
end end
% Add win64 specific paths for Dynare Windows package % Add win64 specific paths for Dynare Windows package
if strcmp(computer, 'PCWIN64') if strcmp(computer, 'PCWIN64')
if matlab_ver_less_than('7.8') if matlab_ver_less_than('9.4')
tmp = [dynareroot '../mex/matlab/win64-7.5-7.7/']; tmp = [dynareroot '../mex/matlab/win64-7.9-9.3/'];
if exist(tmp, 'dir')
mexpath = tmp;
if modifypath
addpath(mexpath);
end
end
elseif matlab_ver_less_than('9.4')
tmp = [dynareroot '../mex/matlab/win64-7.8-9.3/'];
if exist(tmp, 'dir') if exist(tmp, 'dir')
mexpath = tmp; mexpath = tmp;
if modifypath if modifypath
@ -60,7 +52,7 @@ else
end end
end end
else else
tmp = [dynareroot '../mex/matlab/win64-9.4/']; tmp = [dynareroot '../mex/matlab/win64-9.4-9.5/'];
if exist(tmp, 'dir') if exist(tmp, 'dir')
mexpath = tmp; mexpath = tmp;
if modifypath if modifypath

View File

@ -128,7 +128,7 @@ if realtime_==0
myopts=options_; myopts=options_;
myopts.plot_shock_decomp.type='qoq'; myopts.plot_shock_decomp.type='qoq';
myopts.plot_shock_decomp.realtime=0; myopts.plot_shock_decomp.realtime=0;
[z, junk] = plot_shock_decomposition(M_,oo_,myopts,[]); [z, ~] = plot_shock_decomposition(M_,oo_,myopts,[]);
else else
z = oo_; z = oo_;
end end
@ -287,7 +287,7 @@ if isstruct(aux)
yaux=aux.y; yaux=aux.y;
end end
[nvar , nterms, junk] = size(z); [nvar, nterms, ~] = size(z);
for j=1:nvar for j=1:nvar
for k =1:nterms for k =1:nterms
ztmp = squeeze(z(j,k,min((t0-3):-4:1):end)); ztmp = squeeze(z(j,k,min((t0-3):-4:1):end));

View File

@ -40,7 +40,7 @@ irf = icc1+(options_.periods-1)*ny ;
d1 = zeros(options_.periods*ny,1) ; d1 = zeros(options_.periods*ny,1) ;
ofs = (((options_.periods-1)*ny+1)-1)*jcf*8 ; ofs = (((options_.periods-1)*ny+1)-1)*jcf*8 ;
junk = fseek(fid,ofs,-1) ; [~] = fseek(fid,ofs,-1) ;
c = fread(fid,[jcf,ny],'float64')'; c = fread(fid,[jcf,ny],'float64')';
d1(ir) = c(:,jcf) ; d1(ir) = c(:,jcf) ;
@ -52,7 +52,7 @@ while i <= M_.maximum_lead || i <= options_.periods
irf1 = selif(irf,irf<=options_.periods*ny) ; irf1 = selif(irf,irf<=options_.periods*ny) ;
ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ; ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
junk = fseek(fid,ofs,-1) ; [~] = fseek(fid,ofs,-1) ;
c = fread(fid,[jcf,ny],'float64')' ; c = fread(fid,[jcf,ny],'float64')' ;
d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ; d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
@ -64,7 +64,7 @@ end
while i <= options_.periods while i <= options_.periods
ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ; ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
junk = fseek(fid,ofs,-1) ; [~] = fseek(fid,ofs,-1) ;
c = fread(fid,[jcf,ny],'float64')' ; c = fread(fid,[jcf,ny],'float64')' ;
d1(ir) = c(:,jcf)-c(:,icf)*d1(irf) ; d1(ir) = c(:,jcf)-c(:,icf)*d1(irf) ;

View File

@ -32,7 +32,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Get uniques % Get uniques
[junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names); [~, ~, index_uniques] = varlist_indices(varlist, M_.endo_names);
varlist = varlist(index_uniques); varlist = varlist(index_uniques);
msg = false; msg = false;

View File

@ -387,7 +387,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
end end
if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix
[junk, invhess] = compute_mh_covariance_matrix; [~, invhess] = compute_mh_covariance_matrix;
posterior_sampler_options.invhess = invhess; posterior_sampler_options.invhess = invhess;
end end
@ -409,7 +409,7 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
error('check_posterior_sampler_options:: This error should not occur, please contact developers.') error('check_posterior_sampler_options:: This error should not occur, please contact developers.')
end end
% % % if options_.load_mh_file && options_.use_mh_covariance_matrix, % % % if options_.load_mh_file && options_.use_mh_covariance_matrix,
% % % [junk, invhess] = compute_mh_covariance_matrix; % % % [~, invhess] = compute_mh_covariance_matrix;
% % % posterior_sampler_options.invhess = invhess; % % % posterior_sampler_options.invhess = invhess;
% % % end % % % end
[V1, D]=eig(invhess); [V1, D]=eig(invhess);

View File

@ -336,7 +336,7 @@ options_.conditional_variance_decomposition = [];
% Ramsey policy % Ramsey policy
options_.ramsey_policy = 0; options_.ramsey_policy = 0;
options_.instruments = []; options_.instruments = {};
options_.timeless = 0; options_.timeless = 0;
options_.ramsey.maxit = 500; options_.ramsey.maxit = 500;

View File

@ -63,7 +63,7 @@ end
%call steady_state_file if present to update parameters %call steady_state_file if present to update parameters
if options_.steadystate_flag if options_.steadystate_flag
% explicit steady state file % explicit steady state file
[junk,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ... [~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
options_,0); options_,0);
end end
[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params); [U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params);
@ -115,7 +115,7 @@ end
instr_id=nan(instr_nbr,1); instr_id=nan(instr_nbr,1);
for j=1:instr_nbr for j=1:instr_nbr
vj=deblank(Instruments(j,:)); vj=deblank(Instruments{j});
vj_id=strmatch(vj, endo_names, 'exact'); vj_id=strmatch(vj, endo_names, 'exact');
if ~isempty(vj_id) if ~isempty(vj_id)
instr_id(j)=vj_id; instr_id(j)=vj_id;
@ -129,7 +129,7 @@ iter=1;
for j=1:numel(Indices) for j=1:numel(Indices)
eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);']) eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead) if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
[junk,row,col]=find(lead_lag_incidence(iter,:)); [~,row,col]=find(lead_lag_incidence(iter,:));
eval(['A',Indices{j},'(:,row)=jacobia_(:,col);']) eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
iter=iter+1; iter=iter+1;
end end

View File

@ -409,7 +409,7 @@ for i = 1:Size
index_c = lead_lag_incidence(2,:); % Index of all endogenous variables present at time=t index_c = lead_lag_incidence(2,:); % Index of all endogenous variables present at time=t
index_s = lead_lag_incidence(2,1:n_static); % Index of all static endogenous variables present at time=t index_s = lead_lag_incidence(2,1:n_static); % Index of all static endogenous variables present at time=t
if n_static > 0 if n_static > 0
[Q, junk] = qr(jacob(:,index_s)); [Q, ~] = qr(jacob(:,index_s));
aa = Q'*jacob; aa = Q'*jacob;
else else
aa = jacob; aa = jacob;
@ -476,7 +476,7 @@ for i = 1:Size
if isfield(options_,'indeterminacy_continuity') if isfield(options_,'indeterminacy_continuity')
if options_.indeterminacy_msv == 1 if options_.indeterminacy_msv == 1
[ss,tt,w,q] = qz(E',D'); [ss,tt,w,q] = qz(E',D');
[ss,tt,w,junk] = reorder(ss,tt,w,q); [ss,tt,w,~] = reorder(ss,tt,w,q);
ss = ss'; ss = ss';
tt = tt'; tt = tt';
w = w'; w = w';

View File

@ -111,7 +111,7 @@ switch pshape(indx)
end end
if pshape(indx) ~= 5 if pshape(indx) ~= 5
[junk,k1] = max(dens); [~,k1] = max(dens);
if k1 == 1 || k1 == length(dens) if k1 == 1 || k1 == length(dens)
k = find(dens > 10); k = find(dens > 10);
dens(k) = NaN; dens(k) = NaN;

View File

@ -124,7 +124,7 @@ if isempty(reorder_jacobian_columns)
nsfwrd)))]; nsfwrd)))];
index_e2 = npred+nboth+(1:nboth); index_e2 = npred+nboth+(1:nboth);
[junk,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var)); [~,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var));
reorder_jacobian_columns = [nonzeros(lead_lag_incidence(:,order_var)'); ... reorder_jacobian_columns = [nonzeros(lead_lag_incidence(:,order_var)'); ...
nz+(1:exo_nbr)']; nz+(1:exo_nbr)'];
@ -138,7 +138,7 @@ dr.state_var = state_var;
jacobia = jacobia(:,reorder_jacobian_columns); jacobia = jacobia(:,reorder_jacobian_columns);
if nstatic > 0 if nstatic > 0
[Q, junk] = qr(jacobia(:,index_s)); [Q, ~] = qr(jacobia(:,index_s));
aa = Q'*jacobia; aa = Q'*jacobia;
else else
aa = jacobia; aa = jacobia;

View File

@ -50,7 +50,7 @@ elseif options_.steadystate_flag
k_inst = []; k_inst = [];
inst_nbr = size(options_.instruments,1); inst_nbr = size(options_.instruments,1);
for i = 1:inst_nbr for i = 1:inst_nbr
k_inst = [k_inst; strmatch(options_.instruments(i,:), M.endo_names, 'exact')]; k_inst = [k_inst; strmatch(options_.instruments{i}, M.endo_names, 'exact')];
end end
if inst_nbr == 1 if inst_nbr == 1
%solve for instrument, using univariate solver, starting at initial value for instrument %solve for instrument, using univariate solver, starting at initial value for instrument
@ -75,7 +75,7 @@ elseif options_.steadystate_flag
ys_init(k_inst) = inst_val; ys_init(k_inst) = inst_val;
exo_ss = [oo.exo_steady_state oo.exo_det_steady_state]; exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
[xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters [xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
[junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state [~,~,steady_state] = nl_func(inst_val); %compute and return steady state
else else
n_var = M.orig_endo_nbr; n_var = M.orig_endo_nbr;
xx = oo.steady_state(1:n_var); xx = oo.steady_state(1:n_var);
@ -85,7 +85,7 @@ else
if info1~=0 if info1~=0
check=81; check=81;
end end
[junk,junk,steady_state] = nl_func(xx); [~,~,steady_state] = nl_func(xx);
end end
@ -112,7 +112,7 @@ if options_.steadystate_flag
k_inst = []; k_inst = [];
instruments = options_.instruments; instruments = options_.instruments;
for i = 1:size(instruments,1) for i = 1:size(instruments,1)
k_inst = [k_inst; strmatch(instruments(i,:), endo_names, 'exact')]; k_inst = [k_inst; strmatch(instruments{i}, endo_names, 'exact')];
end end
ys_init=zeros(size(oo.steady_state)); %create starting vector for steady state computation as only instrument value is handed over ys_init=zeros(size(oo.steady_state)); %create starting vector for steady state computation as only instrument value is handed over
ys_init(k_inst) = x; %set instrument, the only value required for steady state computation, to current value ys_init(k_inst) = x; %set instrument, the only value required for steady state computation, to current value
@ -194,8 +194,8 @@ end
function result = check_static_model(ys,M,options_,oo) function result = check_static_model(ys,M,options_,oo)
result = false; result = false;
if (options_.bytecode) if (options_.bytecode)
[chck, res, junk] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ... [chck, res, ~] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
M.params, 'evaluate'); M.params, 'evaluate');
else else
res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ... res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
M.params); M.params);

View File

@ -88,7 +88,7 @@ exo_nbr = M.exo_nbr;
M.var_order_endo_names = M.endo_names(dr.order_var); M.var_order_endo_names = M.endo_names(dr.order_var);
[junk,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var)); [~,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var));
dr.i_fwrd_f = i_fwrd_f; dr.i_fwrd_f = i_fwrd_f;
nd = nnz(lead_lag_incidence) + M.exo_nbr; nd = nnz(lead_lag_incidence) + M.exo_nbr;
dr.nd = nd; dr.nd = nd;

View File

@ -105,7 +105,7 @@ k1 = find(kstate(:,2) == M_.maximum_endo_lag+2);
% Jacobian with respect to the variables with the highest lead % Jacobian with respect to the variables with the highest lead
fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:))); fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)));
B(:,nstatic+M_.npred+1:end) = fyp; B(:,nstatic+M_.npred+1:end) = fyp;
[junk,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var)); [~,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var));
A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=... A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=...
A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred); A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred);
C = Gy; C = Gy;
@ -162,7 +162,7 @@ kp = sum(kstate(:,2) <= M_.maximum_endo_lag+1);
E1 = [eye(nspred); zeros(kp-nspred,nspred)]; E1 = [eye(nspred); zeros(kp-nspred,nspred)];
H = E1; H = E1;
hxx = dr.ghxx(nstatic+[1:nspred],:); hxx = dr.ghxx(nstatic+[1:nspred],:);
[junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var)); [~,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)'; k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)';
[B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC); [B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC);
mexErrCheck('sparse_hessian_times_B_kronecker_C', err); mexErrCheck('sparse_hessian_times_B_kronecker_C', err);

View File

@ -82,14 +82,15 @@ if isoctave
'of models approximated at third order, will not be available.'], supported_octave_version()) 'of models approximated at third order, will not be available.'], supported_octave_version())
skipline() skipline()
elseif octave_ver_less_than('4.2') % Should match the test in mex/build/octave/configure.ac elseif octave_ver_less_than('4.2') % Should match the test in mex/build/octave/configure.ac
% and in m4/ax_mexopts.m4
skipline() skipline()
warning(['This version of Dynare has only been tested on Octave 4.2 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.']) warning(['This version of Dynare has only been tested on Octave 4.2 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
skipline() skipline()
end end
else else
if matlab_ver_less_than('7.5') % Should match the test in mex/build/matlab/configure.ac if matlab_ver_less_than('7.9') % Should match the test in mex/build/matlab/configure.ac
skipline() skipline()
warning('This version of Dynare has only been tested on MATLAB 7.5 (R2007b) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.'); warning('This version of Dynare has only been tested on MATLAB 7.9 (R2009b) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.');
skipline() skipline()
end end
end end
@ -191,7 +192,7 @@ end
if ispc if ispc
arch = getenv('PROCESSOR_ARCHITECTURE'); arch = getenv('PROCESSOR_ARCHITECTURE');
else else
[junk, arch] = system('uname -m'); [~, arch] = system('uname -m');
end end
if isempty(strfind(arch, '64')) if isempty(strfind(arch, '64'))
@ -226,6 +227,7 @@ if regexp(firstline, '\s*\/\/', 'once') == 1
end end
command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ; command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ;
command = [ command ' mexext=' mexext ' "matlabroot=' matlabroot '"'];
for i=1:length(varargin) for i=1:length(varargin)
command = [command ' ' varargin{i}]; command = [command ' ' varargin{i}];
end end
@ -240,6 +242,14 @@ if preprocessoroutput
end end
end end
% Under Windows, make sure the MEX file is unloaded (in the use_dll case),
% otherwise the preprocessor can't recompile it
if isoctave
clear([fname(1:end-4) '.static'], [fname(1:end-4) '.dynamic'])
else
clear(['+' fname(1:end-4) '/static'], ['+' fname(1:end-4) '/dynamic'])
end
[status, result] = system(command); [status, result] = system(command);
if status ~= 0 || preprocessoroutput if status ~= 0 || preprocessoroutput
disp(result) disp(result)

View File

@ -128,9 +128,9 @@ if ~isoctave && matlab_ver_less_than('8.1')
p{end+1} = '/missing/strsplit'; p{end+1} = '/missing/strsplit';
end end
% isrow is missing in Matlab<R2010b % isrow, iscolumn and ismatrix are missing in Matlab<R2010b
if ~isoctave && matlab_ver_less_than('7.11') if ~isoctave && matlab_ver_less_than('7.11')
p{end+1} = '/missing/isrow'; p{end+1} = '/missing/is-row-column-matrix';
end end
P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false); P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false);

View File

@ -235,8 +235,8 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood') if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood')
ana_deriv_old = options_.analytic_derivation; ana_deriv_old = options_.analytic_derivation;
options_.analytic_derivation = 2; options_.analytic_derivation = 2;
[junk1, junk2,junk3, junk4, hh] = feval(objective_function,xparam1, ... [~,~,~,~,hh] = feval(objective_function,xparam1, ...
dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
options_.analytic_derivation = ana_deriv_old; options_.analytic_derivation = ana_deriv_old;
elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1 && strcmp(func2str(objective_function),'dsge_likelihood')) elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1 && strcmp(func2str(objective_function),'dsge_likelihood'))
% with flag==0, we force to use the hessian from outer product gradient of optimizer 5 % with flag==0, we force to use the hessian from outer product gradient of optimizer 5
@ -373,9 +373,8 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
skipline() skipline()
end end
if options_.dsge_var if options_.dsge_var
[junk1,junk2,junk3,junk4,junk5,junk6,junk7,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =... [~,~,~,~,~,~,~,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =...
feval(objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); feval(objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
clear('junk1','junk2','junk3','junk4','junk5','junk6','junk7');
end end
elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
@ -519,7 +518,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
oo_.posterior.metropolis=oo_load_mh.oo_.posterior.metropolis; oo_.posterior.metropolis=oo_load_mh.oo_.posterior.metropolis;
end end
end end
[error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_); [error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_);
if options_.bayesian_irf if options_.bayesian_irf
if error_flag if error_flag
error('Estimation::mcmc: I cannot compute the posterior IRFs!') error('Estimation::mcmc: I cannot compute the posterior IRFs!')

View File

@ -454,38 +454,38 @@ if options_.block == 1
% Set restrict_state to postion of observed + state variables in expanded state vector. % Set restrict_state to postion of observed + state variables in expanded state vector.
oo_.dr.restrict_var_list = [k1(i_posA) M_.state_var(sort(i_posB))]; oo_.dr.restrict_var_list = [k1(i_posA) M_.state_var(sort(i_posB))];
% set mf0 to positions of state variables in restricted state vector for likelihood computation. % set mf0 to positions of state variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list); [~,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list);
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation. % Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list); [~,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list);
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing. % Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
bayestopt_.mf2 = var_obs_index_dr; bayestopt_.mf2 = var_obs_index_dr;
bayestopt_.mfys = k1; bayestopt_.mfys = k1;
oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))]; oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))];
[k2, i_posA, i_posB] = union(k3p, M_.state_var', 'rows'); [k2, i_posA, i_posB] = union(k3p, M_.state_var', 'rows');
bayestopt_.smoother_var_list = [k3p(i_posA); M_.state_var(sort(i_posB))']; bayestopt_.smoother_var_list = [k3p(i_posA); M_.state_var(sort(i_posB))'];
[junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:)); [~,~,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:));
[junk,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var); [~,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var);
bayestopt_.smoother_restrict_columns = ic; bayestopt_.smoother_restrict_columns = ic;
[junk,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list); [~,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list);
else else
% Define union of observed and state variables % Define union of observed and state variables
k2 = union(var_obs_index_dr,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows'); k2 = union(var_obs_index_dr,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows');
% Set restrict_state to postion of observed + state variables in expanded state vector. % Set restrict_state to postion of observed + state variables in expanded state vector.
oo_.dr.restrict_var_list = k2; oo_.dr.restrict_var_list = k2;
% set mf0 to positions of state variables in restricted state vector for likelihood computation. % set mf0 to positions of state variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2); [~,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation. % Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf1] = ismember(var_obs_index_dr,k2); [~,bayestopt_.mf1] = ismember(var_obs_index_dr,k2);
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing. % Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
bayestopt_.mf2 = var_obs_index_dr; bayestopt_.mf2 = var_obs_index_dr;
bayestopt_.mfys = k1; bayestopt_.mfys = k1;
[junk,ic] = intersect(k2,nstatic+(1:npred)'); [~,ic] = intersect(k2,nstatic+(1:npred)');
oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)']; oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
bayestopt_.smoother_var_list = union(k2,k3); bayestopt_.smoother_var_list = union(k2,k3);
[junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:)); [~,~,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:));
[junk,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)'); [~,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)');
bayestopt_.smoother_restrict_columns = ic; bayestopt_.smoother_restrict_columns = ic;
[junk,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list); [~,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list);
end end
if options_.analytic_derivation if options_.analytic_derivation

View File

@ -52,11 +52,11 @@ for i=1:m
else else
h = H(:,i); h = H(:,i);
end end
[Fh,junk1,junk2,flag] = feval(fcn, x+transpose(h), varargin{:}); [Fh,~,~,flag] = feval(fcn, x+transpose(h), varargin{:});
if flag if flag
G(:,i) = (Fh-F)/epsilon; G(:,i) = (Fh-F)/epsilon;
else else
[Fh,junk1,junk2,flag] = feval(fcn, x-transpose(h), varargin{:}); [Fh,~,~,flag] = feval(fcn, x-transpose(h), varargin{:});
if flag if flag
G(:,i) = (F-Fh)/epsilon; G(:,i) = (F-Fh)/epsilon;
else else

View File

@ -48,7 +48,7 @@ exo_ss = [oo.exo_steady_state; oo.exo_det_steady_state];
if length(M.aux_vars) > 0 && ~steadystate_flag && M.set_auxiliary_variables if length(M.aux_vars) > 0 && ~steadystate_flag && M.set_auxiliary_variables
h_set_auxiliary_variables = str2func([M.fname '.set_auxiliary_variables']); h_set_auxiliary_variables = str2func([M.fname '.set_auxiliary_variables']);
ys_init = h_set_auxiliary_variables(ys_init,exo_ss,M.params); ys_init = h_set_auxiliary_variables(ys_init,exo_ss,params);
end end
if options.ramsey_policy if options.ramsey_policy
@ -66,7 +66,7 @@ if options.ramsey_policy
fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in NaNs.\n') fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in NaNs.\n')
fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n') fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n')
for ii = 1:size(options.instruments,1) for ii = 1:size(options.instruments,1)
fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact'))) fprintf('\t %s \t %f \n',options.instruments{ii},ys_init(strmatch(options.instruments{ii},M.endo_names,'exact')))
end end
fprintf('evaluate_steady_state: The problem occured in the following equations: \n') fprintf('evaluate_steady_state: The problem occured in the following equations: \n')
fprintf('\t Equation(s): ') fprintf('\t Equation(s): ')
@ -87,7 +87,7 @@ if options.ramsey_policy
fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in complex numbers.\n') fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in complex numbers.\n')
fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n') fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n')
for ii = 1:size(options.instruments,1) for ii = 1:size(options.instruments,1)
fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact'))) fprintf('\t %s \t %f \n',options.instruments{ii},ys_init(strmatch(options.instruments{ii},M.endo_names,'exact')))
end end
fprintf('evaluate_steady_state: If those initial values are not admissable, change them using an initval-block.\n') fprintf('evaluate_steady_state: If those initial values are not admissable, change them using an initval-block.\n')
skipline(2) skipline(2)
@ -102,7 +102,7 @@ if options.ramsey_policy
fprintf('\nevaluate_steady_state: The steady state file does not solve the steady state for the Ramsey problem.\n') fprintf('\nevaluate_steady_state: The steady state file does not solve the steady state for the Ramsey problem.\n')
fprintf('evaluate_steady_state: Conditional on the following instrument values: \n') fprintf('evaluate_steady_state: Conditional on the following instrument values: \n')
for ii = 1:size(options.instruments,1) for ii = 1:size(options.instruments,1)
fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact'))) fprintf('\t %s \t %f \n',options.instruments{ii},ys_init(strmatch(options.instruments{ii},M.endo_names,'exact')))
end end
fprintf('evaluate_steady_state: the following equations have non-zero residuals: \n') fprintf('evaluate_steady_state: the following equations have non-zero residuals: \n')
for ii=n_multipliers+1:M.endo_nbr for ii=n_multipliers+1:M.endo_nbr
@ -150,7 +150,7 @@ if options.ramsey_policy
fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs.\n') fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs.\n')
fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n') fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n')
for i = 1:size(options.instruments,1) for i = 1:size(options.instruments,1)
fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact'))) fprintf('\t %s \t %f \n',options.instruments{i},ys(strmatch(options.instruments{i},M.endo_names,'exact')))
end end
fprintf('evaluate_steady_state: The problem occured in the following equations: \n') fprintf('evaluate_steady_state: The problem occured in the following equations: \n')
fprintf('\t Equation(s): ') fprintf('\t Equation(s): ')
@ -168,7 +168,7 @@ if options.ramsey_policy
fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs in the auxiliary equations.\n') fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs in the auxiliary equations.\n')
fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n') fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n')
for i = 1:size(options.instruments,1) for i = 1:size(options.instruments,1)
fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact'))) fprintf('\t %s \t %f \n',options.instruments{i},ys(strmatch(options.instruments{i},M.endo_names,'exact')))
end end
fprintf('evaluate_steady_state: The problem occured in the following equations: \n') fprintf('evaluate_steady_state: The problem occured in the following equations: \n')
fprintf('\t Auxiliary equation(s): ') fprintf('\t Auxiliary equation(s): ')
@ -186,7 +186,7 @@ if options.ramsey_policy
fprintf('\nevaluate_steady_state: The steady state for the Ramsey problem could not be computed.\n') fprintf('\nevaluate_steady_state: The steady state for the Ramsey problem could not be computed.\n')
fprintf('evaluate_steady_state: The steady state computation stopped with the following instrument values:: \n') fprintf('evaluate_steady_state: The steady state computation stopped with the following instrument values:: \n')
for i = 1:size(options.instruments,1) for i = 1:size(options.instruments,1)
fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact'))) fprintf('\t %s \t %f \n',options.instruments{i},ys(strmatch(options.instruments{i},M.endo_names,'exact')))
end end
fprintf('evaluate_steady_state: The following equations have non-zero residuals: \n') fprintf('evaluate_steady_state: The following equations have non-zero residuals: \n')
for ii=1:n_multipliers for ii=1:n_multipliers
@ -289,7 +289,7 @@ if check
%make sure ys contains auxiliary variables in case of problem with dynare_solve %make sure ys contains auxiliary variables in case of problem with dynare_solve
if length(M.aux_vars) > 0 && ~steadystate_flag if length(M.aux_vars) > 0 && ~steadystate_flag
if M.set_auxiliary_variables if M.set_auxiliary_variables
ys = h_set_auxiliary_variables(ys,exo_ss,M.params); ys = h_set_auxiliary_variables(ys,exo_ss,params);
end end
end end
resid = evaluate_static_model(ys,exo_ss,params,M,options); resid = evaluate_static_model(ys,exo_ss,params,M,options);
@ -307,15 +307,15 @@ if M.static_and_dynamic_models_differ
z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1); z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1);
zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1); zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1);
if options.bytecode if options.bytecode
[chck, r, junk]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1); [chck, r, ~]= bytecode('dynamic','evaluate', z, zx, params, ys, 1);
mexErrCheck('bytecode', chck); mexErrCheck('bytecode', chck);
elseif options.block elseif options.block
[r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr); [r, oo.dr] = feval([M.fname '.dynamic'], z', zx, params, ys, M.maximum_lag+1, oo.dr);
else else
iyv = M.lead_lag_incidence'; iyv = M.lead_lag_incidence';
iyr0 = find(iyv(:)); iyr0 = find(iyv(:));
xys = z(iyr0); xys = z(iyr0);
r = feval([M.fname '.dynamic'], z(iyr0), zx, M.params, ys, M.maximum_lag + 1); r = feval([M.fname '.dynamic'], z(iyr0), zx, params, ys, M.maximum_lag + 1);
end end
% Fail if residual greater than tolerance % Fail if residual greater than tolerance
if max(abs(r)) > options.solve_tolf if max(abs(r)) > options.solve_tolf

View File

@ -36,8 +36,6 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options,
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
debug = false;
ys = []; ys = [];
params = M.params; params = M.params;
info = 0; info = 0;
@ -102,49 +100,11 @@ end
% adding values for auxiliary variables % adding values for auxiliary variables
if length(M.aux_vars) > 0 && ~options.ramsey_policy if length(M.aux_vars) > 0 && ~options.ramsey_policy
if debug
ys0 = ys;
end
if M.set_auxiliary_variables if M.set_auxiliary_variables
ys = h_set_auxiliary_variables(ys,exo_ss,params); ys = h_set_auxiliary_variables(ys,exo_ss,params);
end end
if debug
ys1 = ys;
end
if M.set_auxiliary_variables
ys = h_set_auxiliary_variables(ys,exo_ss,params);
end
if debug
ys2 = ys;
end
if debug
if M.set_auxiliary_variables
ys = h_set_auxiliary_variables(ys,exo_ss,params);
end
ys3 = ys;
idx = find(abs(ys0-ys1)>0);
if ~isempty(idx)
M.endo_names{idx}
else
disp('1-invariant')
end
idx = find(abs(ys2-ys1)>0);
if ~isempty(idx)
M.endo_names{idx}
else
disp('2-invariant')
end
idx = find(abs(ys3-ys3)>0);
if ~isempty(idx)
M.endo_names{idx}
else
disp('3-invariant')
end
pause
end
end end
check1 = 0;
if steady_state_checkflag if steady_state_checkflag
% Check whether the steady state obtained from the _steadystate file is a steady state. % Check whether the steady state obtained from the _steadystate file is a steady state.
[residuals, check] = evaluate_static_model(ys, exo_ss, params, M, options); [residuals, check] = evaluate_static_model(ys, exo_ss, params, M, options);

View File

@ -55,7 +55,7 @@ if strcmpi(type,'posterior')
CutSample(M_, options_, estim_params_); CutSample(M_, options_, estim_params_);
%% initialize metropolis draws %% initialize metropolis draws
options_.sub_draws=n_draws; %set draws for sampling; changed value is not returned to base workspace options_.sub_draws=n_draws; %set draws for sampling; changed value is not returned to base workspace
[error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_); [error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_);
if error_flag if error_flag
error('EXECUTE_POSTERIOR_FUNCTION: The draws could not be initialized') error('EXECUTE_POSTERIOR_FUNCTION: The draws could not be initialized')
end end

View File

@ -319,8 +319,8 @@ if nargout > 5
end end
end end
[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ... [~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
oo_.dr.order_var)); oo_.dr.order_var));
GAM0 = zeros(M_.endo_nbr,M_.endo_nbr); GAM0 = zeros(M_.endo_nbr,M_.endo_nbr);
Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr); Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
GAM0(:,cols_b) = g1(:,cols_j); GAM0(:,cols_b) = g1(:,cols_j);
@ -651,7 +651,6 @@ is=is(find(gpp(is,2)==j));
if ~isempty(is) if ~isempty(is)
g22(sub2ind([n,n],gpp(is,3),gpp(is,4)))=gpp(is,5)'; g22(sub2ind([n,n],gpp(is,3),gpp(is,4)))=gpp(is,5)';
g22(sub2ind([n,n],gpp(is,4),gpp(is,3)))=gpp(is,5)';
end end
return return
@ -675,10 +674,8 @@ for is=1:length(gpp)
% indx = find(ic==find(d)); % indx = find(ic==find(d));
if fsparse if fsparse
g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,3),gpp(is,4)))=gpp(is,5); g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,3),gpp(is,4)))=gpp(is,5);
g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,4),gpp(is,3)))=gpp(is,5);
else else
g22(gpp(is,1),gpp(is,2),gpp(is,3),gpp(is,4))=gpp(is,5); g22(gpp(is,1),gpp(is,2),gpp(is,3),gpp(is,4))=gpp(is,5);
g22(gpp(is,1),gpp(is,2),gpp(is,4),gpp(is,3))=gpp(is,5);
end end
end end
@ -696,7 +693,6 @@ for is=1:length(rpp)
% d(rpp(is,2),rpp(is,3))=1; % d(rpp(is,2),rpp(is,3))=1;
% indx = find(ic==find(d)); % indx = find(ic==find(d));
r22(rpp(is,1),rpp(is,2),rpp(is,3))=rpp(is,4); r22(rpp(is,1),rpp(is,2),rpp(is,3))=rpp(is,4);
r22(rpp(is,1),rpp(is,3),rpp(is,2))=rpp(is,4);
end end
return return
@ -707,7 +703,6 @@ h2=zeros(r,m,m,npar);
for is=1:length(hp) for is=1:length(hp)
h2(hp(is,1),hp(is,2),hp(is,3),hp(is,4))=hp(is,5); h2(hp(is,1),hp(is,2),hp(is,3),hp(is,4))=hp(is,5);
h2(hp(is,1),hp(is,3),hp(is,2),hp(is,4))=hp(is,5);
end end
return return
@ -722,10 +717,4 @@ if ~isempty(is)
h2(sub2ind([m,npar],hp(is,3),hp(is,4)))=hp(is,5)'; h2(sub2ind([m,npar],hp(is,3),hp(is,4)))=hp(is,5)';
end end
is=is1(find(hp(is1,3)==j));
if ~isempty(is)
h2(sub2ind([m,npar],hp(is,2),hp(is,4)))=hp(is,5)';
end
return return

View File

@ -23,7 +23,7 @@ function [state_u,state_n] = get_dynare_random_generator_state()
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7')); matlab_random_streams = ~isoctave;
if matlab_random_streams% Use new matlab interface. if matlab_random_streams% Use new matlab interface.
if matlab_ver_less_than('7.12') if matlab_ver_less_than('7.12')

View File

@ -43,7 +43,7 @@ bk_number = record.Nblck ;
predicted_mhname = [ BaseName '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ; predicted_mhname = [ BaseName '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ;
all_mh_files = dir([BaseName '_mh*_blck*' ]); all_mh_files = dir([BaseName '_mh*_blck*' ]);
[junk,idx] = sort([all_mh_files.datenum]); [~,idx] = sort([all_mh_files.datenum]);
mhname = all_mh_files(idx(end)).name; mhname = all_mh_files(idx(end)).name;
if ~strcmpi(mhname,predicted_mhname) if ~strcmpi(mhname,predicted_mhname)

View File

@ -130,8 +130,8 @@ set_dynare_seed('default');
% Create directories % Create directories
[junk,junk]=mkdir(M_.fname); [~,~]=mkdir(M_.fname);
[junk,junk]=mkdir([M_.fname filesep 'Output']); [~,~]=mkdir([M_.fname filesep 'Output']);
% Load user configuration file. % Load user configuration file.
if isfield(options_, 'global_init_file') if isfield(options_, 'global_init_file')

View File

@ -108,7 +108,7 @@ comp_nbr0=comp_nbr;
for j=1:nvar for j=1:nvar
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks if screen_shocks
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1); zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];

View File

@ -135,7 +135,7 @@ comp_nbr0=comp_nbr;
for j=1:nvar for j=1:nvar
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks, if screen_shocks,
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1); zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];

View File

@ -42,7 +42,6 @@ end
pvalue_ks = DynareOptions.opt_gsa.pvalue_ks; pvalue_ks = DynareOptions.opt_gsa.pvalue_ks;
indx_irf = []; indx_irf = [];
indx_moment = []; indx_moment = [];
DynareOptions.nodisplay = 1;
init = ~DynareOptions.opt_gsa.load_stab; init = ~DynareOptions.opt_gsa.load_stab;
options_mcf.pvalue_ks = DynareOptions.opt_gsa.pvalue_ks; options_mcf.pvalue_ks = DynareOptions.opt_gsa.pvalue_ks;

View File

@ -34,6 +34,8 @@ if DynareOptions.TeX
else else
param_names_tex = options_mcf.param_names_tex; param_names_tex = options_mcf.param_names_tex;
end end
else
param_names_tex = strrep(options_mcf.param_names,'_','\_');
end end
amcf_name = options_mcf.amcf_name; amcf_name = options_mcf.amcf_name;
amcf_title = options_mcf.amcf_title; amcf_title = options_mcf.amcf_title;
@ -78,7 +80,7 @@ if ~isempty(indmcf) && ~DynareOptions.nograph
skipline() skipline()
xx=[]; xx=[];
if ~ isempty(xparam1), xx=xparam1(indmcf); end if ~ isempty(xparam1), xx=xparam1(indmcf); end
scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names(indmcf), ... scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names_tex(indmcf), ...
'.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, DynareOptions, ... '.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, DynareOptions, ...
beha_title, nobeha_title) beha_title, nobeha_title)
end end

View File

@ -49,7 +49,7 @@ if init
pdraw = zeros(npar,1); pdraw = zeros(npar,1);
lbcum = zeros(npar,1); lbcum = zeros(npar,1);
ubcum = ones(npar,1); ubcum = ones(npar,1);
[junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds [~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
% Set prior bounds % Set prior bounds
bounds = prior_bounds(bayestopt_, options_.prior_trunc); bounds = prior_bounds(bayestopt_, options_.prior_trunc);

View File

@ -143,7 +143,7 @@ for i = 1:p
end end
if i==1 if i==1
if nflag == 1 if nflag == 1
ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ... ylabel(vnames(j,:),'Rotation',45, ...
'HorizontalAlignment','right','VerticalAlignment','middle'); 'HorizontalAlignment','right','VerticalAlignment','middle');
else else
ylabel([num2str(j),' '],'Rotation',90) ylabel([num2str(j),' '],'Rotation',90)
@ -151,7 +151,7 @@ for i = 1:p
end end
if j==1 if j==1
if nflag == 1 if nflag == 1
title(vnames(i,:),'interpreter','none','Rotation',45, ... title(vnames(i,:),'Rotation',45, ...
'HorizontalAlignment','left','VerticalAlignment','bottom') 'HorizontalAlignment','left','VerticalAlignment','bottom')
else else
title(num2str(i)) title(num2str(i))

View File

@ -92,7 +92,7 @@ p2 = bayestopt_.p2(nshock+1:end);
p3 = bayestopt_.p3(nshock+1:end); p3 = bayestopt_.p3(nshock+1:end);
p4 = bayestopt_.p4(nshock+1:end); p4 = bayestopt_.p4(nshock+1:end);
[junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds [~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
% Set prior bounds % Set prior bounds
bounds = prior_bounds(bayestopt_, options_.prior_trunc); bounds = prior_bounds(bayestopt_, options_.prior_trunc);

View File

@ -123,24 +123,27 @@ if info(1)==0
ide_strength_J=NaN(1,nparam); ide_strength_J=NaN(1,nparam);
ide_strength_J_prior=NaN(1,nparam); ide_strength_J_prior=NaN(1,nparam);
if init if init
normaliz = NaN(1,nparam); ide_uncert_unnormaliz = NaN(1,nparam);
if prior_exist if prior_exist
offset_prior=0;
if ~isempty(estim_params_.var_exo) if ~isempty(estim_params_.var_exo)
normaliz1 = estim_params_.var_exo(:,7)'; % normalize with prior standard deviation normaliz_prior_std = bayestopt_.p2(1:estim_params_.nvx)'; % normalize with prior standard deviation
offset_prior=offset_prior+estim_params_.nvx+estim_params_.nvn;
else else
normaliz1=[]; normaliz_prior_std=[];
end end
if ~isempty(estim_params_.corrx) if ~isempty(estim_params_.corrx)
normaliz1 = [normaliz1 estim_params_.corrx(:,8)']; % normalize with prior standard deviation normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset_prior+1:offset_prior+estim_params_.ncx)']; % normalize with prior standard deviation
offset_prior=offset_prior+estim_params_.ncx+estim_params_.ncn;
end end
if ~isempty(estim_params_.param_vals) if ~isempty(estim_params_.param_vals)
normaliz1 = [normaliz1 estim_params_.param_vals(:,7)']; % normalize with prior standard deviation normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset_prior+1:offset_prior+estim_params_.np)']; % normalize with prior standard deviation
end end
% normaliz = max([normaliz; normaliz1]); % normaliz = max([normaliz; normaliz1]);
normaliz1(isinf(normaliz1)) = 1; % normaliz1(isinf(normaliz1)) = 1;
else else
normaliz1 = NaN(1,nparam); normaliz_prior_std = NaN(1,nparam);
end end
try try
options_.irf = 0; options_.irf = 0;
@ -176,7 +179,7 @@ if info(1)==0
end end
indok = find(max(ide_hess.indno,[],1)==0); indok = find(max(ide_hess.indno,[],1)==0);
cparam(indok,indok) = inv(AHess(indok,indok)); cparam(indok,indok) = inv(AHess(indok,indok));
normaliz(indok) = sqrt(diag(cparam(indok,indok)))'; ide_uncert_unnormaliz(indok) = sqrt(diag(cparam(indok,indok)))';
cmm = NaN(size(siJ,1),size(siJ,1)); cmm = NaN(size(siJ,1),size(siJ,1));
ind1=find(ide_hess.ind0); ind1=find(ide_hess.ind0);
cmm = siJ(:,ind1)*((AHess(ind1,ind1))\siJ(:,ind1)'); cmm = siJ(:,ind1)*((AHess(ind1,ind1))\siJ(:,ind1)');
@ -198,7 +201,7 @@ if info(1)==0
if isoctave || matlab_ver_less_than('8.3') if isoctave || matlab_ver_less_than('8.3')
[V,D]=eig(cc); [V,D]=eig(cc);
%fix for older Matlab versions that do not support computing left eigenvalues, see http://mathworks.com/help/releases/R2012b/matlab/ref/eig.html %fix for older Matlab versions that do not support computing left eigenvalues, see http://mathworks.com/help/releases/R2012b/matlab/ref/eig.html
[W,junk] = eig(cc.'); [W,~] = eig(cc.');
W = conj(W); W = conj(W);
else else
[V,D,W]=eig(cc); [V,D,W]=eig(cc);
@ -242,22 +245,23 @@ if info(1)==0
clre = siLRE(:,ind1-offset)*((MIM(ind1,ind1))\siLRE(:,ind1-offset)'); clre = siLRE(:,ind1-offset)*((MIM(ind1,ind1))\siLRE(:,ind1-offset)');
if ~isempty(indok) if ~isempty(indok)
rhoM(indok)=sqrt(1./diag(inv(tildaM(indok,indok)))); rhoM(indok)=sqrt(1./diag(inv(tildaM(indok,indok))));
normaliz(indok) = (sqrt(diag(inv(tildaM(indok,indok))))./deltaM(indok))'; %sqrt(diag(inv(MIM(indok,indok))))'; ide_uncert_unnormaliz(indok) = (sqrt(diag(inv(tildaM(indok,indok))))./deltaM(indok))'; %sqrt(diag(inv(MIM(indok,indok))))';
end end
% deltaM = deltaM.*abs(params') % deltaM = deltaM.*abs(params')
flag_score=0; flag_score=0;
end end
ide_strength_J(indok) = (1./(normaliz(indok)'./abs(params(indok)'))); ide_strength_J(indok) = (1./(ide_uncert_unnormaliz(indok)'./abs(params(indok)')));
ide_strength_J_prior(indok) = (1./(normaliz(indok)'./normaliz1(indok)')); ide_strength_J_prior(indok) = (1./(ide_uncert_unnormaliz(indok)'./normaliz_prior_std(indok)'));
ide_strength_J(params==0)=1./normaliz(params==0)'; %ide_strength_J(params==0)=1./ide_uncert_unnormaliz(params==0)';
deltaM_prior = deltaM.*abs(normaliz1'); sensitivity_zero_pos=find(isinf(deltaM));
deltaM_prior = deltaM.*abs(normaliz_prior_std');
deltaM = deltaM.*abs(params'); deltaM = deltaM.*abs(params');
deltaM(params==0)=deltaM_prior(params==0); %deltaM(params==0)=deltaM_prior(params==0);
quant = siJ./repmat(sqrt(diag(cmm)),1,nparam); quant = siJ./repmat(sqrt(diag(cmm)),1,nparam);
if size(quant,1)==1 if size(quant,1)==1
siJnorm = abs(quant).*normaliz1; siJnorm = abs(quant).*normaliz_prior_std;
else else
siJnorm = vnorm(quant).*normaliz1; siJnorm = vnorm(quant).*normaliz_prior_std;
end end
% siJnorm = vnorm(siJ(inok,:)).*normaliz; % siJnorm = vnorm(siJ(inok,:)).*normaliz;
quant=[]; quant=[];
@ -272,9 +276,9 @@ if info(1)==0
if ~isempty(iy) if ~isempty(iy)
quant = siH./repmat(sqrt(diag_chh(iy)),1,nparam); quant = siH./repmat(sqrt(diag_chh(iy)),1,nparam);
if size(quant,1)==1 if size(quant,1)==1
siHnorm = abs(quant).*normaliz1; siHnorm = abs(quant).*normaliz_prior_std;
else else
siHnorm = vnorm(quant).*normaliz1; siHnorm = vnorm(quant).*normaliz_prior_std;
end end
else else
siHnorm = []; siHnorm = [];
@ -292,9 +296,9 @@ if info(1)==0
if ~isempty(iy) if ~isempty(iy)
quant = siLRE./repmat(sqrt(diag_clre(iy)),1,np); quant = siLRE./repmat(sqrt(diag_clre(iy)),1,np);
if size(quant,1)==1 if size(quant,1)==1
siLREnorm = abs(quant).*normaliz1(offset+1:end); siLREnorm = abs(quant).*normaliz_prior_std(offset+1:end);
else else
siLREnorm = vnorm(quant).*normaliz1(offset+1:end); siLREnorm = vnorm(quant).*normaliz_prior_std(offset+1:end);
end end
else else
siLREnorm=[]; siLREnorm=[];
@ -304,6 +308,8 @@ if info(1)==0
ide_hess.ide_strength_J_prior=ide_strength_J_prior; ide_hess.ide_strength_J_prior=ide_strength_J_prior;
ide_hess.deltaM=deltaM; ide_hess.deltaM=deltaM;
ide_hess.deltaM_prior=deltaM_prior; ide_hess.deltaM_prior=deltaM_prior;
ide_hess.sensitivity_zero_pos=sensitivity_zero_pos;
ide_hess.identified_parameter_indices=indok;
ide_moments.siJnorm=siJnorm; ide_moments.siJnorm=siJnorm;
ide_model.siHnorm=siHnorm; ide_model.siHnorm=siHnorm;
ide_lre.siLREnorm=siLREnorm; ide_lre.siLREnorm=siLREnorm;

View File

@ -74,7 +74,7 @@ end
if ~isfield(oo_,'initval_decomposition') if ~isfield(oo_,'initval_decomposition')
options_.selected_variables_only = 0; %make sure all variables are stored options_.selected_variables_only = 0; %make sure all variables are stored
options_.plot_priors=0; options_.plot_priors=0;
[oo,M,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); [oo,M,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
% reduced form % reduced form
dr = oo.dr; dr = oo.dr;

View File

@ -66,7 +66,7 @@ if isfield(EstimatedParameters,'param_vals') && ~isempty(EstimatedParameters.par
%check whether steady state file changes estimated parameters %check whether steady state file changes estimated parameters
Model_par_varied=Model; %store Model structure Model_par_varied=Model; %store Model structure
Model_par_varied.params(EstimatedParameters.param_vals(:,1))=Model_par_varied.params(EstimatedParameters.param_vals(:,1))*1.01; %vary parameters Model_par_varied.params(EstimatedParameters.param_vals(:,1))=Model_par_varied.params(EstimatedParameters.param_vals(:,1))*1.01; %vary parameters
[junk, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0); [~, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0);
changed_par_indices=find((old_steady_params(EstimatedParameters.param_vals(:,1))-new_steady_params(EstimatedParameters.param_vals(:,1))) ... changed_par_indices=find((old_steady_params(EstimatedParameters.param_vals(:,1))-new_steady_params(EstimatedParameters.param_vals(:,1))) ...
| (Model_par_varied.params(EstimatedParameters.param_vals(:,1))-new_steady_params_2(EstimatedParameters.param_vals(:,1)))); | (Model_par_varied.params(EstimatedParameters.param_vals(:,1))-new_steady_params_2(EstimatedParameters.param_vals(:,1))));
@ -105,8 +105,8 @@ end
% display warning if some parameters are still NaN % display warning if some parameters are still NaN
test_for_deep_parameters_calibration(Model); test_for_deep_parameters_calibration(Model);
[lnprior, junk1,junk2,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4); [lnprior,~,~,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
if info if any(info)
fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1}) fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1})
error('The initial value of the prior is -Inf') error('The initial value of the prior is -Inf')
end end

View File

@ -114,9 +114,9 @@ while t <= last
tmp = (a+K*v); tmp = (a+K*v);
if analytic_derivation if analytic_derivation
if analytic_derivation==2 if analytic_derivation==2
[Da,junk,DLIKt,D2a,junk2, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]); [Da,~,DLIKt,D2a,~, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]);
else else
[Da,junk,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady); [Da,~,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady);
end end
DLIK = DLIK + DLIKt; DLIK = DLIK + DLIKt;
if analytic_derivation==2 || asy_hess if analytic_derivation==2 || asy_hess

View File

@ -153,7 +153,7 @@ while t<=last
end end
if analytic_derivation if analytic_derivation
if analytic_derivation==2 if analytic_derivation==2
[Da,junk,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T); [Da,~,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T);
else else
Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0); Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0);
end end

View File

@ -392,7 +392,7 @@ while (k < kmax) && (Psix > eps2)
Fx = Fxnew; Fx = Fxnew;
Phix = Phixnew; Phix = Phixnew;
Psix = Psixnew; Psix = Psixnew;
[junk,DFx] = feval(FUN,x,varargin{:}); [~,DFx] = feval(FUN,x,varargin{:});
DPhix = DPhi(x,Fx,DFx,lb,ub,lambda1,lambda2,n,Indexset); DPhix = DPhi(x,Fx,DFx,lb,ub,lambda1,lambda2,n,Indexset);
DPsix = DPhix'*Phix; DPsix = DPhix'*Phix;
normDPsix = norm(DPsix); normDPsix = norm(DPsix);

View File

@ -18,7 +18,7 @@ function o2WysrOISH = load_m_file_data_legacy(datafile, U7ORsJ0vy3) % --*-- Uni
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2); cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2);
[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,junk] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW); [pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,~] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW) if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
% We need to change directory, first we keep the current directory in memory... % We need to change directory, first we keep the current directory in memory...
@ -38,7 +38,7 @@ if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
end end
% Clear all the variables except the ones defined in the script. % Clear all the variables except the ones defined in the script.
clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW', 'junk'); clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW');
% Get the list of variables in the script. % Get the list of variables in the script.
mj6F4eU1BN = whos(); mj6F4eU1BN = whos();

View File

@ -0,0 +1,20 @@
function r = iscolumn(V)
% Copyright (C) 2018 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
sz = size(V);
r = (length(sz) == 2) && (sz(2) == 1);

View File

@ -0,0 +1,19 @@
function r = ismatrix(V)
% Copyright (C) 2018 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
r = (ndims(V) == 2);

View File

@ -16,5 +16,5 @@ function r = isrow(V)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
[m, n] = size(V); sz = size(V);
r = (m == 1); r = (length(sz) == 2) && (sz(1) == 1);

View File

@ -204,22 +204,22 @@ z = repmat(dr.ys,1,klen);
if ~options.block if ~options.block
if options.order == 1 if options.order == 1
if (options.bytecode) if (options.bytecode)
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
M.params, dr.ys, 1); M.params, dr.ys, 1);
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd]; jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
else else
[junk,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ... [~,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ...
M.params, dr.ys, it_); M.params, dr.ys, it_);
end end
elseif options.order >= 2 elseif options.order >= 2
if (options.bytecode) if (options.bytecode)
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
M.params, dr.ys, 1); M.params, dr.ys, 1);
jacobia_ = [loc_dr.g1 loc_dr.g1_x]; jacobia_ = [loc_dr.g1 loc_dr.g1_x];
else else
[junk,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),... [~,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),...
exo_simul, ... exo_simul, ...
M.params, dr.ys, it_); M.params, dr.ys, it_);
end end
if options.use_dll if options.use_dll
% In USE_DLL mode, the hessian is in the 3-column sparse representation % In USE_DLL mode, the hessian is in the 3-column sparse representation

View File

@ -6,19 +6,19 @@ coef_y = zeros(endo_nbr,3*endo_nbr);
coef_u = zeros(endo_nbr,M.exo_nbr); coef_u = zeros(endo_nbr,M.exo_nbr);
if M.maximum_lag > 0 if M.maximum_lag > 0
[junk,c1,c2] = find(ll(1,:)); [~,c1,c2] = find(ll(1,:));
coef_y(:,c1) = jacobian(:,c2); coef_y(:,c1) = jacobian(:,c2);
[junk,c1,c2] = find(ll(2,:)); [~,c1,c2] = find(ll(2,:));
coef_y(:,c1+endo_nbr) = jacobian(:,c2); coef_y(:,c1+endo_nbr) = jacobian(:,c2);
if M.maximum_lead > 0 if M.maximum_lead > 0
[junk,c1,c2] = find(ll(3,:)); [~,c1,c2] = find(ll(3,:));
coef_y(:,c1+2*endo_nbr) = jacobian(:,c2); coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
end end
else else
[junk,c1,c2] = find(ll(1,:)); [~,c1,c2] = find(ll(1,:));
coef_y(:,c1+endo_nbr) = jacobian(:,c2); coef_y(:,c1+endo_nbr) = jacobian(:,c2);
if M.maximum_lead > 0 if M.maximum_lead > 0
[junk,c1,c2] = find(ll(2,:)); [~,c1,c2] = find(ll(2,:));
coef_y(:,c1+2*endo_nbr) = jacobian(:,c2); coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
end end
end end

View File

@ -142,7 +142,7 @@ while ~done
elseif ischar(grad) elseif ischar(grad)
[g1, badg1] = grad(x1,varargin{:}); [g1, badg1] = grad(x1,varargin{:});
else else
[junk1,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:}); [~,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:});
badg1 = ~cost_flag; badg1 = ~cost_flag;
end end
wall1=badg1; wall1=badg1;
@ -169,7 +169,7 @@ while ~done
elseif ischar(grad) elseif ischar(grad)
[g2, badg2] = grad(x2,varargin{:}); [g2, badg2] = grad(x2,varargin{:});
else else
[junk2,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:}); [~,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:});
badg2 = ~cost_flag; badg2 = ~cost_flag;
end end
wall2=badg2; wall2=badg2;
@ -201,7 +201,7 @@ while ~done
elseif ischar(grad) elseif ischar(grad)
[g3, badg3] = grad(x3,varargin{:}); [g3, badg3] = grad(x3,varargin{:});
else else
[junk3,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:}); [~,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:});
badg3 = ~cost_flag; badg3 = ~cost_flag;
end end
wall3=badg3; wall3=badg3;
@ -261,7 +261,7 @@ while ~done
elseif ischar(grad) elseif ischar(grad)
[gh, badgh] = grad(xh,varargin{:}); [gh, badgh] = grad(xh,varargin{:});
else else
[junkh,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:}); [~,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:});
badgh = ~cost_flag; badgh = ~cost_flag;
end end
end end

View File

@ -46,12 +46,12 @@ for i=1:n
xiold = x(i); xiold = x(i);
h = step_length_correction(xiold,scale,i)*delta; h = step_length_correction(xiold,scale,i)*delta;
x(i) = xiold + h; x(i) = xiold + h;
[f1,junk1,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:}); [f1,~,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:});
if ~cost_flag1 if ~cost_flag1
fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the right!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h)) fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the right!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
end end
x(i) = xiold - h; x(i) = xiold - h;
[f2,junk2,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:}); [f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
if ~cost_flag2 if ~cost_flag2
fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the left!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h)) fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the left!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
end end

View File

@ -48,13 +48,13 @@ for i=1:n
xiold = x(i); xiold = x(i);
h = step_length_correction(xiold,scale,i)*delta; h = step_length_correction(xiold,scale,i)*delta;
x(i) = xiold+h; x(i) = xiold+h;
[f1,junk1,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:}); [f1,~,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:});
x(i) = xiold-h; x(i) = xiold-h;
[f2,junk1,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:}); [f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
x(i) = xiold+2*h; x(i) = xiold+2*h;
[f3,junk1,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:}); [f3,~,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:});
x(i) = xiold-2*h; x(i) = xiold-2*h;
[f4,junk1,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:}); [f4,~,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:});
if f0<f1 && f1<f3 && f0<f2 && f2<f4 if f0<f1 && f1<f3 && f0<f2 && f2<f4
g0 = 0; g0 = 0;
else else

View File

@ -190,7 +190,7 @@ if verbose
disp('Simplex initialization...') disp('Simplex initialization...')
end end
initial_point = x; initial_point = x;
[initial_score,junk1,nopenalty] = feval(objective_function,x,varargin{:}); [initial_score,~,nopenalty] = feval(objective_function,x,varargin{:});
if ~nopenalty if ~nopenalty
disp('Cannot initialize the simplex with the provided initial guess.') disp('Cannot initialize the simplex with the provided initial guess.')
skipline() skipline()
@ -528,7 +528,7 @@ for j = 1:n
end end
v(:,j+1) = y; v(:,j+1) = y;
x = y; x = y;
[fv(j+1),junk1,nopenalty_flag] = feval(objective_function,x,varargin{:}); [fv(j+1),~,nopenalty_flag] = feval(objective_function,x,varargin{:});
if check_delta if check_delta
while ~nopenalty_flag while ~nopenalty_flag
if y(j)~=0 if y(j)~=0
@ -544,7 +544,7 @@ for j = 1:n
end end
v(:,j+1) = y; v(:,j+1) = y;
x = y; x = y;
[fv(j+1),junk1,nopenalty_flag] = feval(objective_function,x,varargin{:}); [fv(j+1),~,nopenalty_flag] = feval(objective_function,x,varargin{:});
end end
end end
end end

View File

@ -91,7 +91,7 @@ if options_.ramsey_policy && options_.ACES_solver == 0
opt.jacobian_flag = 0; opt.jacobian_flag = 0;
oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_); oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_);
options_.solve_algo = old_solve_algo; options_.solve_algo = old_solve_algo;
[junk,junk,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_); [~,~,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
[jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_); [jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);
klen = M_.maximum_lag + M_.maximum_lead + 1; klen = M_.maximum_lag + M_.maximum_lead + 1;
dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar]; dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];
@ -123,14 +123,14 @@ else
lq_instruments.sim_ruleids=sim_ruleids; lq_instruments.sim_ruleids=sim_ruleids;
lq_instruments.tct_ruleids=tct_ruleids; lq_instruments.tct_ruleids=tct_ruleids;
%if isfield(lq_instruments,'xsopt_SS') %% changed by BY %if isfield(lq_instruments,'xsopt_SS') %% changed by BY
[junk, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY [~, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY
[qc, DYN_Q] = QPsolve(lq_instruments, s2, check); %% added by BY [qc, DYN_Q] = QPsolve(lq_instruments, s2, check); %% added by BY
z = repmat(lq_instruments.xsopt_SS,1,klen); z = repmat(lq_instruments.xsopt_SS,1,klen);
else else
z = repmat(dr.ys,1,klen); z = repmat(dr.ys,1,klen);
end end
z = z(iyr0) ; z = z(iyr0) ;
[junk,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ... [~,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, dr.ys, it_); oo_.exo_det_simul], M_.params, dr.ys, it_);
if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 ) if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 )

View File

@ -368,7 +368,7 @@ end
save_options_initval_file = options_.initval_file; save_options_initval_file = options_.initval_file;
options_.initval_file = '__'; options_.initval_file = '__';
[pos_constrained_pf, junk] = find(constrained_perfect_foresight); [pos_constrained_pf, ~] = find(constrained_perfect_foresight);
indx_endo_solve_pf = constrained_vars(pos_constrained_pf); indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
if isempty(indx_endo_solve_pf) if isempty(indx_endo_solve_pf)
pf = 0; pf = 0;
@ -572,7 +572,7 @@ else
for t = 1:constrained_periods for t = 1:constrained_periods
if direct_mode && ~isempty(is_constraint) if direct_mode && ~isempty(is_constraint)
[pos_constrained_pf, junk] = find(constrained_perfect_foresight .* is_constraint(t, :)'); [pos_constrained_pf, ~] = find(constrained_perfect_foresight .* is_constraint(t, :)');
indx_endo_solve_pf = constrained_vars(pos_constrained_pf); indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
if isempty(indx_endo_solve_pf) if isempty(indx_endo_solve_pf)
pf = 0; pf = 0;
@ -580,7 +580,7 @@ else
pf = length(indx_endo_solve_pf); pf = length(indx_endo_solve_pf);
end end
[pos_constrained_surprise, junk] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)'); [pos_constrained_surprise, ~] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)');
indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise); indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise);
if isempty(indx_endo_solve_surprise) if isempty(indx_endo_solve_surprise)
@ -591,7 +591,7 @@ else
end end
if direct_mode && ~isempty(is_shock) if direct_mode && ~isempty(is_shock)
[pos_shock_pf, junk] = find(shock_perfect_foresight .* is_shock(t, :)'); [pos_shock_pf, ~] = find(shock_perfect_foresight .* is_shock(t, :)');
indx_endo_solve_pf = shock_vars(pos_shock_pf); indx_endo_solve_pf = shock_vars(pos_shock_pf);
if isempty(indx_endo_solve_pf) if isempty(indx_endo_solve_pf)
b_pf = 0; b_pf = 0;
@ -599,7 +599,7 @@ else
b_pf = length(indx_endo_solve_pf); b_pf = length(indx_endo_solve_pf);
end end
[pos_shock_surprise, junk] = find((1-shock_perfect_foresight) .* is_shock(t, :)'); [pos_shock_surprise, ~] = find((1-shock_perfect_foresight) .* is_shock(t, :)');
indx_endo_solve_surprise = shock_vars(pos_shock_surprise); indx_endo_solve_surprise = shock_vars(pos_shock_surprise);
if isempty(indx_endo_solve_surprise) if isempty(indx_endo_solve_surprise)

View File

@ -179,9 +179,9 @@ if ~isreal(oo_.endo_simul(:)) %can only happen without bytecode
yT = real(oo_.endo_simul(:,options_.periods+2)); yT = real(oo_.endo_simul(:,options_.periods+2));
yy = real(oo_.endo_simul(:,2:options_.periods+1)); yy = real(oo_.endo_simul(:,2:options_.periods+1));
illi = M_.lead_lag_incidence'; illi = M_.lead_lag_incidence';
[i_cols,junk,i_cols_j] = find(illi(:)); [i_cols,~,i_cols_j] = find(illi(:));
illi = illi(:,2:3); illi = illi(:,2:3);
[i_cols_J1,junk,i_cols_1] = find(illi(:)); [i_cols_J1,~,i_cols_1] = find(illi(:));
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
oo_.exo_simul,M_.params,oo_.steady_state, ... oo_.exo_simul,M_.params,oo_.steady_state, ...

View File

@ -123,16 +123,16 @@ if nargout>1
yy = oo_.endo_simul(:,2:options_.periods+1); yy = oo_.endo_simul(:,2:options_.periods+1);
if ~exist('illi') if ~exist('illi')
illi = M_.lead_lag_incidence'; illi = M_.lead_lag_incidence';
[i_cols,junk,i_cols_j] = find(illi(:)); [i_cols,~,i_cols_j] = find(illi(:));
illi = illi(:,2:3); illi = illi(:,2:3);
[i_cols_J1,junk,i_cols_1] = find(illi(:)); [i_cols_J1,~,i_cols_1] = find(illi(:));
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
end end
if options_.block && ~options_.bytecode if options_.block && ~options_.bytecode
maxerror = oo_.deterministic_simulation.error; maxerror = oo_.deterministic_simulation.error;
else else
if options_.bytecode if options_.bytecode
[chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); [chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
else else
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
oo_.exo_simul,M_.params,oo_.steady_state, ... oo_.exo_simul,M_.params,oo_.steady_state, ...

View File

@ -71,8 +71,8 @@ y0 = endogenousvariables(:,M.maximum_lag);
yT = endogenousvariables(:,M.maximum_lag+periods+1); yT = endogenousvariables(:,M.maximum_lag+periods+1);
z = endogenousvariables(:,M.maximum_lag+(1:periods)); z = endogenousvariables(:,M.maximum_lag+(1:periods));
illi = M.lead_lag_incidence'; illi = M.lead_lag_incidence';
[i_cols, junk,i_cols_j] = find(illi(:)); [i_cols,~,i_cols_j] = find(illi(:));
illi = illi(:,2:3); illi = illi(:,2:3);
[i_cols_J1, junk,i_cols_1] = find(illi(:)); [i_cols_J1,~,i_cols_1] = find(illi(:));
i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)'); i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)');
dynamicmodel = str2func([M.fname,'.dynamic']); dynamicmodel = str2func([M.fname,'.dynamic']);

View File

@ -99,16 +99,16 @@ if nargout>1
yy = oo_.endo_simul(:,2:options_.periods+1); yy = oo_.endo_simul(:,2:options_.periods+1);
if ~exist('illi') if ~exist('illi')
illi = M_.lead_lag_incidence'; illi = M_.lead_lag_incidence';
[i_cols,junk,i_cols_j] = find(illi(:)); [i_cols,~,i_cols_j] = find(illi(:));
illi = illi(:,2:3); illi = illi(:,2:3);
[i_cols_J1,junk,i_cols_1] = find(illi(:)); [i_cols_J1,~,i_cols_1] = find(illi(:));
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
end end
if options_.block && ~options_.bytecode if options_.block && ~options_.bytecode
maxerror = oo_.deterministic_simulation.error; maxerror = oo_.deterministic_simulation.error;
else else
if options_.bytecode if options_.bytecode
[chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); [chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
else else
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
oo_.exo_simul,M_.params,oo_.steady_state, ... oo_.exo_simul,M_.params,oo_.steady_state, ...

View File

@ -69,6 +69,19 @@ if SampleSize == 1
else else
bar(log([idehess.ide_strength_J(:,is)' ])) bar(log([idehess.ide_strength_J(:,is)' ]))
end end
hold on
plot((1:length(idehess.ide_strength_J(:,is)))-0.15,log([idehess.ide_strength_J(:,is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
plot((1:length(idehess.ide_strength_J_prior(:,is)))+0.15,log([idehess.ide_strength_J_prior(:,is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
if any(isinf(log(idehess.ide_strength_J(idehess.identified_parameter_indices))))
inf_indices=find(isinf(log(idehess.ide_strength_J(idehess.identified_parameter_indices))));
inf_pos=ismember(is,inf_indices);
plot(find(inf_pos)-0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0])
end
if any(isinf(log(idehess.ide_strength_J_prior(idehess.identified_parameter_indices))))
inf_indices=find(isinf(log(idehess.ide_strength_J_prior(idehess.identified_parameter_indices))));
inf_pos=ismember(is,inf_indices);
plot(find(inf_pos)+0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0])
end
set(gca,'xlim',[0 nparam+1]) set(gca,'xlim',[0 nparam+1])
set(gca,'xticklabel','') set(gca,'xticklabel','')
dy = get(gca,'ylim'); dy = get(gca,'ylim');
@ -92,7 +105,21 @@ if SampleSize == 1
else else
bar(log([idehess.deltaM(is)])) bar(log([idehess.deltaM(is)]))
end end
hold on
plot((1:length(idehess.deltaM(is)))-0.15,log([idehess.deltaM(is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
plot((1:length(idehess.deltaM_prior(is)))+0.15,log([idehess.deltaM_prior(is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
inf_pos=find(isinf(log(idehess.deltaM)));
if ~isempty(inf_pos)
inf_indices=~ismember(inf_pos,idehess.sensitivity_zero_pos);
inf_pos=ismember(is,inf_pos(inf_indices));
plot(find(inf_pos)-0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0])
end
inf_pos=find(isinf(log(idehess.deltaM_prior)));
if ~isempty(inf_pos)
inf_indices=~ismember(inf_pos,idehess.sensitivity_zero_pos);
inf_pos=ismember(is,inf_pos(inf_indices));
plot(find(inf_pos)+0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0])
end
set(gca,'xlim',[0 nparam+1]) set(gca,'xlim',[0 nparam+1])
set(gca,'xticklabel','') set(gca,'xticklabel','')
dy = get(gca,'ylim'); dy = get(gca,'ylim');

View File

@ -204,7 +204,7 @@ for b=fpar:B
if run_smoother if run_smoother
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,junk1,junk2,P,junk4,junk5,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ... [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ...
DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_); DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
stock_trend_coeff(options_.varobs_id,irun(9))=trend_coeff; stock_trend_coeff(options_.varobs_id,irun(9))=trend_coeff;

View File

@ -144,7 +144,7 @@ if tt5
if any(x(id5)-p3(id5)<0) || any(x(id5)-p4(id5)>0) if any(x(id5)-p3(id5)<0) || any(x(id5)-p4(id5)>0)
logged_prior_density = -Inf ; logged_prior_density = -Inf ;
if nargout ==4 if nargout ==4
info=id5(any(x(id5)-p3(id5)<0) || any(x(id5)-p4(id5)>0)); info=id5((x(id5)-p3(id5)<0) || (x(id5)-p4(id5)>0));
end end
return return
end end

View File

@ -98,8 +98,7 @@ nobs = options_.nobs;
if forecast_ && any(forecast_params) if forecast_ && any(forecast_params)
M1=M_; M1=M_;
M1.params = forecast_params; M1.params = forecast_params;
[junk1,junk2,junk3,junk4,junk5,junk6,oo1] = dynare_resolve(M1,options_,oo_); [~,~,~,~,~,~,oo1] = dynare_resolve(M1,options_,oo_);
clear junk1 junk2 junk3 junk4 junk5 junk6
end end
if fast_realtime if fast_realtime
@ -109,7 +108,7 @@ if fast_realtime
newString=sprintf(running_text); newString=sprintf(running_text);
fprintf(['%s'],newString); fprintf(['%s'],newString);
options_.nobs=fast_realtime; options_.nobs=fast_realtime;
[oo0,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); [oo0,M_,~,~,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
gend0 = size(oo0.SmoothedShocks.(M_.exo_names{1}),1); gend0 = size(oo0.SmoothedShocks.(M_.exo_names{1}),1);
prctdone=0.5; prctdone=0.5;
if isoctave if isoctave
@ -120,7 +119,7 @@ if fast_realtime
fprintf([s0,'%s'],newString); fprintf([s0,'%s'],newString);
end end
options_.nobs=nobs; options_.nobs=nobs;
[oo2,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); [oo2,M_,~,~,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
gend2 = size(oo2.SmoothedShocks.(M_.exo_names{1}),1); gend2 = size(oo2.SmoothedShocks.(M_.exo_names{1}),1);
prctdone=1; prctdone=1;
if isoctave if isoctave
@ -142,7 +141,7 @@ for j=presample+1:nobs
% evalin('base',['options_.nobs=' int2str(j) ';']) % evalin('base',['options_.nobs=' int2str(j) ';'])
options_.nobs=j; options_.nobs=j;
if ~fast_realtime if ~fast_realtime
[oo,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); [oo,M_,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
gend = size(oo.SmoothedShocks.(M_.exo_names{1}),1); gend = size(oo.SmoothedShocks.(M_.exo_names{1}),1);
else else
gend = gend0+j-fast_realtime; gend = gend0+j-fast_realtime;

View File

@ -23,7 +23,7 @@ function [state_u,state_n] = set_dynare_random_generator_state(state_u,state_n)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7')); matlab_random_streams = ~isoctave;
if matlab_random_streams% Use new matlab interface. if matlab_random_streams% Use new matlab interface.
if matlab_ver_less_than('7.12') if matlab_ver_less_than('7.12')

View File

@ -24,7 +24,7 @@ if ~nargin
error('set_dynare_seed:: I need at least one input argument!') error('set_dynare_seed:: I need at least one input argument!')
end end
matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7') || options_.parallel_info.isHybridMatlabOctave); matlab_random_streams = ~(isoctave || options_.parallel_info.isHybridMatlabOctave);
if matlab_random_streams% Use new matlab interface. if matlab_random_streams% Use new matlab interface.
if nargin==1 if nargin==1

View File

@ -72,7 +72,7 @@ end
options_.selected_variables_only = 0; %make sure all variables are stored options_.selected_variables_only = 0; %make sure all variables are stored
options_.plot_priors=0; options_.plot_priors=0;
[oo_, M_, junk1, junk2, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_); [oo_, M_, ~, ~, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_);
% reduced form % reduced form
dr = oo_.dr; dr = oo_.dr;

View File

@ -97,7 +97,7 @@ if nargin>2
if ~isunix if ~isunix
error('The parallel version of SMM estimation is not implemented for non unix platforms!') error('The parallel version of SMM estimation is not implemented for non unix platforms!')
end end
[junk,hostname] = unix('hostname --fqdn'); [~,hostname] = unix('hostname --fqdn');
hostname = deblank(hostname); hostname = deblank(hostname);
master_is_running_a_job = 0; master_is_running_a_job = 0;
for i=1:length(parallel) for i=1:length(parallel)

View File

@ -111,22 +111,22 @@ it_ = M_.maximum_lag + 1;
z = repmat(dr.ys,1,klen); z = repmat(dr.ys,1,klen);
if local_order == 1 if local_order == 1
if (options_.bytecode) if (options_.bytecode)
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
M_.params, dr.ys, 1); M_.params, dr.ys, 1);
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd]; jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
else else
[junk,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ... [~,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
M_.params, dr.ys, it_); M_.params, dr.ys, it_);
end end
elseif local_order == 2 elseif local_order == 2
if (options_.bytecode) if (options_.bytecode)
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
M_.params, dr.ys, 1); M_.params, dr.ys, 1);
jacobia_ = [loc_dr.g1 loc_dr.g1_x]; jacobia_ = [loc_dr.g1 loc_dr.g1_x];
else else
[junk,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),... [~,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),...
exo_simul, ... exo_simul, ...
M_.params, dr.ys, it_); M_.params, dr.ys, it_);
end end
if options_.use_dll if options_.use_dll
% In USE_DLL mode, the hessian is in the 3-column sparse representation % In USE_DLL mode, the hessian is in the 3-column sparse representation
@ -217,15 +217,15 @@ nz = nnz(M_.lead_lag_incidence);
sdyn = M_.endo_nbr - nstatic; sdyn = M_.endo_nbr - nstatic;
[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ... [~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
order_var)); order_var));
b = zeros(M_.endo_nbr,M_.endo_nbr); b = zeros(M_.endo_nbr,M_.endo_nbr);
b(:,cols_b) = jacobia_(:,cols_j); b(:,cols_b) = jacobia_(:,cols_j);
if M_.maximum_endo_lead == 0 if M_.maximum_endo_lead == 0
% backward models: simplified code exist only at order == 1 % backward models: simplified code exist only at order == 1
if local_order == 1 if local_order == 1
[k1,junk,k2] = find(kstate(:,4)); [k1,~,k2] = find(kstate(:,4));
dr.ghx(:,k1) = -b\jacobia_(:,k2); dr.ghx(:,k1) = -b\jacobia_(:,k2);
if M_.exo_nbr if M_.exo_nbr
dr.ghu = -b\jacobia_(:,nz+1:end); dr.ghu = -b\jacobia_(:,nz+1:end);

View File

@ -204,7 +204,7 @@ if ~isempty(options_.nk) && options_.nk ~= 0
end end
else else
positions_in_declaration_order=oo_.dr.order_var(bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list)); positions_in_declaration_order=oo_.dr.order_var(bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list));
[junk,sorted_index_declaration_order]=sort(positions_in_declaration_order); [~,sorted_index_declaration_order]=sort(positions_in_declaration_order);
oo_.FilteredVariablesKStepAhead(:,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAhead; oo_.FilteredVariablesKStepAhead(:,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAhead;
if ~isempty(PK) && options_.filter_covariance %get K-step ahead variances if ~isempty(PK) && options_.filter_covariance %get K-step ahead variances
oo_.FilteredVariablesKStepAheadVariances(:,sorted_index_declaration_order,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAheadVariances; oo_.FilteredVariablesKStepAheadVariances(:,sorted_index_declaration_order,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAheadVariances;

View File

@ -31,7 +31,7 @@ function [hasLicense] = user_has_matlab_license(toolbox)
if matlab_ver_less_than('7.12') if matlab_ver_less_than('7.12')
hasLicense = license('test', toolbox); hasLicense = license('test', toolbox);
else else
[hasLicense, junk] = license('checkout',toolbox); [hasLicense, ~] = license('checkout',toolbox);
end end
if ~hasLicense if ~hasLicense
return return

View File

@ -21,7 +21,7 @@ a = dir('*.mod');
for i = 1:length(a) for i = 1:length(a)
[junk,basename,extension] = fileparts(a(i).name); [~,basename,extension] = fileparts(a(i).name);
if exist([basename '.m']) if exist([basename '.m'])
delete([basename '.m']); delete([basename '.m']);
end end

View File

@ -1,116 +0,0 @@
function dyn_mex(win_compiler,basename,force)
% Compile Dynare model dlls when model option use_dll is used
% if C file is fresher than mex file
%
% INPUTS
% o win_compiler str compiler used under Windows (unused under Linux or OSX):
% 'msvc' (MS Visual C)
% 'cygwin'
% o basename str filenames base
% o force bool recompile if 1
%
% OUTPUTS
% none
%
% Copyright (C) 2015-2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
Dc = dir([basename '/mode/src/dynamic.c']);
Dmex = dir(['+' basename '/model/dynamic.' mexext]);
% compile only if date of C file is greater than date of mex file
% and force is not True
if ~isempty(Dmex)
if (Dmex.datenum > Dc.datenum) && ~force
disp('Mex files are newer than the source: not recompiled')
return
end
end
if ~isoctave
% Some mex commands are enclosed in an eval(), because otherwise it will make Octave fail
if ispc
if strcmp(win_compiler,'msvc')
% MATLAB/Windows + Microsoft Visual C++
% Add /TP flag as fix for #1227
eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" COMPFLAGS="/TP" ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" COMPFLAGS="/TP" ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
elseif strcmp(win_compiler,'mingw')
eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
elseif strcmp(win_compiler,'cygwin') %legacy support for Cygwin with mexopts.bat
% MATLAB/Windows + Cygwin g++
eval(['mex -O PRELINK_CMDS1="echo EXPORTS > mex.def & echo ' ...
'mexFunction >> mex.def & echo Dynamic >> mex.def" ' ...
basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O PRELINK_CMDS1="echo EXPORTS > mex.def & echo ' ...
'mexFunction >> mex.def & echo Dynamic >> mex.def" ' ...
basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
else
error(['When using the USE_DLL option, you must give either ' ...
'''cygwin'', ''mingw'' or ''msvc'' option to the ''dynare'' command'])
end
elseif isunix && ~ismac
% MATLAB/Linux
if matlab_ver_less_than('8.3')
eval(['mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' ' ...
basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' ' ...
basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
elseif matlab_ver_less_than('9.1')
eval(['mex -O LINKEXPORT='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LINKEXPORT='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
else
eval(['mex -O LINKEXPORTVER='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LINKEXPORTVER='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
end
elseif ismac
% MATLAB/MacOS
if matlab_ver_less_than('8.1')
eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ...
'error -arch $ARCHS -Wl,-syslibroot,$SDKROOT ' ...
'-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ...
basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ...
'error -arch $ARCHS -Wl,-syslibroot,$SDKROOT ' ...
'-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ...
basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
elseif matlab_ver_less_than('8.3')
eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ...
'error -arch $ARCHS -Wl,-syslibroot,$MW_SDKROOT ' ...
'-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ...
basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ...
'error -arch $ARCHS -Wl,-syslibroot,$MW_SDKROOT ' ...
'-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ...
basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
elseif matlab_ver_less_than('9.1')
eval(['mex -O LINKEXPORT='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LINKEXPORT='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
else
eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic'])
eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static'])
end
end
else
% Octave
eval(['mex ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -o +' basename '/dynamic'])
eval(['mex ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -o +' basename '/static'])
end

View File

@ -48,7 +48,7 @@ if ~all(check)
end end
nvar = length(i_var); nvar = length(i_var);
[i_var_unique, index_uniques, junk] = unique(i_var, 'first'); [i_var_unique, index_uniques, ~] = unique(i_var, 'first');
index_uniques = sort(index_uniques); index_uniques = sort(index_uniques);
i_var_unique = i_var(index_uniques); i_var_unique = i_var(index_uniques);

View File

@ -1,12 +1,11 @@
ACLOCAL_AMFLAGS = -I ../../../m4 ACLOCAL_AMFLAGS = -I ../../../m4
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if DO_SOMETHING if DO_SOMETHING
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv block_kalman_filter sobol local_state_space_iterations SUBDIRS = mjdgges kronecker bytecode block_kalman_filter sobol local_state_space_iterations
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if HAVE_MATIO if HAVE_MATIO
SUBDIRS += k_order_perturbation dynare_simul_ SUBDIRS += libdynare++ gensylv k_order_perturbation dynare_simul_
endif endif
if HAVE_GSL if HAVE_GSL

View File

@ -34,7 +34,7 @@ if test "x$ax_enable_matlab" = "xyes"; then
if test "x$ax_matlab_version_ok" = "xyes"; then if test "x$ax_matlab_version_ok" = "xyes"; then
AX_MEXOPTS AX_MEXOPTS
AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to version 7.5 (R2007b) at least.])]) AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.9], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to version 7.9 (R2009b) at least.])])
fi fi
CFLAGS="$MATLAB_CFLAGS" CFLAGS="$MATLAB_CFLAGS"
@ -66,8 +66,6 @@ AM_PROG_AR
case ${host_os} in case ${host_os} in
*mingw32*) *mingw32*)
# Ensure that -lpthread is statically linked under MinGW
PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic"
# Kludge for bug in MinGW, that defines __STDC_UTF_16__ but not char16_t # 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) # This breaks the matrix.h of older MATLABs (e.g. R2009a)
# Also see <uchar.h> # Also see <uchar.h>
@ -94,6 +92,18 @@ AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"])
AX_SLICOT([matlab]) AX_SLICOT([matlab])
AM_CONDITIONAL([HAVE_SLICOT], [test "x$has_slicot" = "xyes"]) AM_CONDITIONAL([HAVE_SLICOT], [test "x$has_slicot" = "xyes"])
# On Windows, we want static linking of the external libraries
case ${host_os} in
*mingw32*)
# We hardcode -lpthread here, otherwise it is not detected by the
# AX_PTHREAD macro and therefore not statically linked
PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic"
GSL_LIBS="-Wl,-Bstatic $GSL_LIBS -Wl,-Bdynamic"
LIBADD_MATIO="-Wl,-Bstatic $LIBADD_MATIO -Wl,-Bdynamic"
LIBADD_SLICOT="-Wl,-Bstatic $LIBADD_SLICOT -Wl,-Bdynamic"
;;
esac
AM_CONDITIONAL([DO_SOMETHING], [test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"]) AM_CONDITIONAL([DO_SOMETHING], [test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"])
if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"; then if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"; then
@ -107,9 +117,9 @@ else
fi fi
if test "x$ax_enable_matlab" = "xyes" -a "x$has_matio" = "xyes"; then if test "x$ax_enable_matlab" = "xyes" -a "x$has_matio" = "xyes"; then
BUILD_KORDER_DYNSIMUL_MEX_MATLAB="yes" BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB="yes"
else else
BUILD_KORDER_DYNSIMUL_MEX_MATLAB="no (missing MatIO library)" BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB="no (missing MatIO library)"
fi fi
if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes" -a "x$has_slicot" = "xyes"; then if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes" -a "x$has_slicot" = "xyes"; then
@ -148,7 +158,7 @@ Dynare is now configured for building the following components...
Binaries (with "make"): Binaries (with "make"):
MEX files for MATLAB (except those listed below): $BUILD_MEX_MATLAB MEX files for MATLAB (except those listed below): $BUILD_MEX_MATLAB
K-order and dynare_simul MEX files for MATLAB: $BUILD_KORDER_DYNSIMUL_MEX_MATLAB Gensylv, k-order and dynare_simul MEX files for MATLAB: $BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB
MS-SBVAR MEX files for MATLAB: $BUILD_MS_SBVAR_MEX_MATLAB MS-SBVAR MEX files for MATLAB: $BUILD_MS_SBVAR_MEX_MATLAB
Kalman Steady State MEX file for MATLAB: $BUILD_KALMAN_STEADY_STATE_MATLAB Kalman Steady State MEX file for MATLAB: $BUILD_KALMAN_STEADY_STATE_MATLAB
M2HTML documentation: $BUILD_M2HTML M2HTML documentation: $BUILD_M2HTML

View File

@ -1,11 +1,11 @@
ACLOCAL_AMFLAGS = -I ../../../m4 ACLOCAL_AMFLAGS = -I ../../../m4
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if DO_SOMETHING if DO_SOMETHING
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv block_kalman_filter sobol local_state_space_iterations SUBDIRS = mjdgges kronecker bytecode block_kalman_filter sobol local_state_space_iterations
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if HAVE_MATIO if HAVE_MATIO
SUBDIRS += k_order_perturbation dynare_simul_ SUBDIRS += libdynare++ gensylv k_order_perturbation dynare_simul_
endif endif
if HAVE_GSL if HAVE_GSL

View File

@ -56,7 +56,7 @@ AC_SUBST([LIBADD_DLOPEN])
AX_GSL AX_GSL
AM_CONDITIONAL([HAVE_GSL], [test "x$has_gsl" = "xyes"]) AM_CONDITIONAL([HAVE_GSL], [test "x$has_gsl" = "xyes"])
# Check for libmatio, needed by k-order, dynare_simul, ms-sbvar (only under Octave, as an alternative to MATLAB's libmat) # Check for libmatio, needed by MEX files using Dynare++ code, and by ms-sbvar (the latter only under Octave, as an alternative to MATLAB's libmat)
AX_MATIO AX_MATIO
AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"]) AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"])
@ -88,9 +88,9 @@ else
fi fi
if test "x$MKOCTFILE" != "x" -a "x$has_matio" = "xyes"; then if test "x$MKOCTFILE" != "x" -a "x$has_matio" = "xyes"; then
BUILD_KORDER_DYNSIMUL_MEX_OCTAVE="yes" BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE="yes"
else else
BUILD_KORDER_DYNSIMUL_MEX_OCTAVE="no (missing MatIO library)" BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE="no (missing MatIO library)"
fi fi
if test "x$MKOCTFILE" != "x" -a "x$has_slicot" = "xyes"; then if test "x$MKOCTFILE" != "x" -a "x$has_slicot" = "xyes"; then
@ -119,9 +119,9 @@ Dynare is now configured for building the following components...
Binaries (with "make"): Binaries (with "make"):
MEX files for Octave (except those listed below): $BUILD_MEX_OCTAVE MEX files for Octave (except those listed below): $BUILD_MEX_OCTAVE
Gensylv, k-order and dynare_simul MEX for Octave: $BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE
MS-SBVAR MEX files for Octave: $BUILD_MS_SBVAR_MEX_OCTAVE MS-SBVAR MEX files for Octave: $BUILD_MS_SBVAR_MEX_OCTAVE
Kalman Steady State MEX file for Octave: $BUILD_KALMAN_STEADY_STATE_OCTAVE Kalman Steady State MEX file for Octave: $BUILD_KALMAN_STEADY_STATE_OCTAVE
K-order and dynare_simul MEX for Octave: $BUILD_KORDER_DYNSIMUL_MEX_OCTAVE
]) ])

View File

@ -33,40 +33,40 @@ DynamicModelAC::copyDoubleIntoTwoDMatData(double *dm, TwoDMatrix *tdm, int rows,
tdm->get(i, j) = dm[dmIdx++]; tdm->get(i, j) = dm[dmIdx++];
} }
double * void
DynamicModelAC::unpackSparseMatrix(mxArray *sparseMat) DynamicModelAC::unpackSparseMatrixAndCopyIntoTwoDMatData(mxArray *sparseMat, TwoDMatrix *tdm)
{ {
int totalCols = mxGetN(sparseMat); int totalCols = mxGetN(sparseMat);
mwIndex *rowIdxVector = mxGetIr(sparseMat); mwIndex *rowIdxVector = mxGetIr(sparseMat);
mwSize sizeRowIdxVector = mxGetNzmax(sparseMat); mwSize sizeRowIdxVector = mxGetNzmax(sparseMat);
mwIndex *colIdxVector = mxGetJc(sparseMat); mwIndex *colIdxVector = mxGetJc(sparseMat);
assert(tdm->ncols() == 3);
assert(tdm->nrows() == sizeRowIdxVector);
double *ptr = mxGetPr(sparseMat); double *ptr = mxGetPr(sparseMat);
double *newMat = (double *) malloc(sizeRowIdxVector*3*sizeof(double));
int rind = 0; int rind = 0;
int retvalind0 = 0; int output_row = 0;
int retvalind1 = sizeRowIdxVector;
int retvalind2 = sizeRowIdxVector*2;
for (int i = 0; i < totalCols; i++) for (int i = 0; i < totalCols; i++)
for (int j = 0; j < (int) (colIdxVector[i+1]-colIdxVector[i]); j++, rind++) for (int j = 0; j < (int) (colIdxVector[i+1]-colIdxVector[i]); j++, rind++)
{ {
newMat[retvalind0++] = rowIdxVector[rind] + 1; tdm->get(output_row, 0) = rowIdxVector[rind] + 1;
newMat[retvalind1++] = i + 1; tdm->get(output_row, 1) = i + 1;
newMat[retvalind2++] = ptr[rind]; tdm->get(output_row, 2) = ptr[rind];
output_row++;
} }
/* If there are less elements than Nzmax (that might happen if some /* If there are less elements than Nzmax (that might happen if some
derivative is symbolically not zero but numerically zero at the evaluation derivative is symbolically not zero but numerically zero at the evaluation
point), then fill in the matrix with empty entries, that will be point), then fill in the matrix with empty entries, that will be
recognized as such by KordpDynare::populateDerivativesContainer() */ recognized as such by KordpDynare::populateDerivativesContainer() */
while (retvalind0 < (int) sizeRowIdxVector) while (output_row < (int) sizeRowIdxVector)
{ {
newMat[retvalind0++] = 0; tdm->get(output_row, 0) = 0;
newMat[retvalind1++] = 0; tdm->get(output_row, 1) = 0;
newMat[retvalind2++] = 0; tdm->get(output_row, 2) = 0;
output_row++;
} }
return newMat;
} }

View File

@ -25,9 +25,10 @@
class DynamicModelAC class DynamicModelAC
{ {
public: public:
static double *unpackSparseMatrix(mxArray *sparseMatrix); virtual ~DynamicModelAC() = default;
static void unpackSparseMatrixAndCopyIntoTwoDMatData(mxArray *sparseMat, TwoDMatrix *tdm);
static void copyDoubleIntoTwoDMatData(double *dm, TwoDMatrix *tdm, int rows, int cols); static void copyDoubleIntoTwoDMatData(double *dm, TwoDMatrix *tdm, int rows, int cols);
virtual void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady, virtual void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady,
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException) = 0; Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false) = 0;
}; };
#endif #endif

View File

@ -21,7 +21,7 @@
#include <sstream> #include <sstream>
DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) DynamicModelDLL::DynamicModelDLL(const string &modName) noexcept(false)
{ {
string fName; string fName;
#if !defined(__CYGWIN32__) && !defined(_WIN32) #if !defined(__CYGWIN32__) && !defined(_WIN32)
@ -33,7 +33,7 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
{ {
#if defined(__CYGWIN32__) || defined(_WIN32) #if defined(__CYGWIN32__) || defined(_WIN32)
dynamicHinstance = LoadLibrary(fName.c_str()); dynamicHinstance = LoadLibrary(fName.c_str());
if (dynamicHinstance == NULL) if (dynamicHinstance == nullptr)
throw 1; throw 1;
ntt = (int *) GetProcAddress(dynamicHinstance, "ntt"); ntt = (int *) GetProcAddress(dynamicHinstance, "ntt");
dynamic_resid_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_resid_tt"); dynamic_resid_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_resid_tt");
@ -44,18 +44,18 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
dynamic_g2 = (dynamic_g2_fct) GetProcAddress(dynamicHinstance, "dynamic_g2"); dynamic_g2 = (dynamic_g2_fct) GetProcAddress(dynamicHinstance, "dynamic_g2");
dynamic_g3_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_g3_tt"); dynamic_g3_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_g3_tt");
dynamic_g3 = (dynamic_g3_fct) GetProcAddress(dynamicHinstance, "dynamic_g3"); dynamic_g3 = (dynamic_g3_fct) GetProcAddress(dynamicHinstance, "dynamic_g3");
if (ntt == NULL if (ntt == nullptr
|| dynamic_resid_tt == NULL || dynamic_resid == NULL || dynamic_resid_tt == nullptr || dynamic_resid == nullptr
|| dynamic_g1_tt == NULL || dynamic_g1 == NULL || dynamic_g1_tt == nullptr || dynamic_g1 == nullptr
|| dynamic_g2_tt == NULL || dynamic_g2 == NULL || dynamic_g2_tt == nullptr || dynamic_g2 == nullptr
|| dynamic_g3_tt == NULL || dynamic_g3 == NULL) || dynamic_g3_tt == nullptr || dynamic_g3 == nullptr)
{ {
FreeLibrary(dynamicHinstance); // Free the library FreeLibrary(dynamicHinstance); // Free the library
throw 2; throw 2;
} }
#else // Linux or Mac #else // Linux or Mac
dynamicHinstance = dlopen(fName.c_str(), RTLD_NOW); dynamicHinstance = dlopen(fName.c_str(), RTLD_NOW);
if (dynamicHinstance == NULL) if (dynamicHinstance == nullptr)
{ {
cerr << dlerror() << endl; cerr << dlerror() << endl;
throw 1; throw 1;
@ -69,11 +69,11 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
dynamic_g2 = (dynamic_g2_fct) dlsym(dynamicHinstance, "dynamic_g2"); dynamic_g2 = (dynamic_g2_fct) dlsym(dynamicHinstance, "dynamic_g2");
dynamic_g3_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_g3_tt"); dynamic_g3_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_g3_tt");
dynamic_g3 = (dynamic_g3_fct) dlsym(dynamicHinstance, "dynamic_g3"); dynamic_g3 = (dynamic_g3_fct) dlsym(dynamicHinstance, "dynamic_g3");
if (ntt == NULL if (ntt == nullptr
|| dynamic_resid_tt == NULL || dynamic_resid == NULL || dynamic_resid_tt == nullptr || dynamic_resid == nullptr
|| dynamic_g1_tt == NULL || dynamic_g1 == NULL || dynamic_g1_tt == nullptr || dynamic_g1 == nullptr
|| dynamic_g2_tt == NULL || dynamic_g2 == NULL || dynamic_g2_tt == nullptr || dynamic_g2 == nullptr
|| dynamic_g3_tt == NULL || dynamic_g3 == NULL) || dynamic_g3_tt == nullptr || dynamic_g3 == nullptr)
{ {
dlclose(dynamicHinstance); // Free the library dlclose(dynamicHinstance); // Free the library
cerr << dlerror() << endl; cerr << dlerror() << endl;
@ -95,16 +95,19 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
} }
catch (...) catch (...)
{ {
throw DynareException(__FILE__, __LINE__, string("Can't find the relevant dynamic symbols in ") + fName); throw DynareException(__FILE__, __LINE__, "Can't find the relevant dynamic symbols in " + fName);
} }
} }
DynamicModelDLL::~DynamicModelDLL() DynamicModelDLL::~DynamicModelDLL()
{ {
#if defined(__CYGWIN32__) || defined(_WIN32) #if defined(__CYGWIN32__) || defined(_WIN32)
bool result = FreeLibrary(dynamicHinstance); auto result = FreeLibrary(dynamicHinstance);
if (result == 0) if (result == 0)
throw DynareException(__FILE__, __LINE__, string("Can't free the *_dynamic DLL")); {
cerr << "Can't free the *_dynamic DLL" << endl;
exit(EXIT_FAILURE);
}
#else #else
dlclose(dynamicHinstance); dlclose(dynamicHinstance);
#endif #endif
@ -112,7 +115,7 @@ DynamicModelDLL::~DynamicModelDLL()
void void
DynamicModelDLL::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady, DynamicModelDLL::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady,
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException) Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false)
{ {
double *T = (double *) malloc(sizeof(double) * (*ntt)); double *T = (double *) malloc(sizeof(double) * (*ntt));
dynamic_resid_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T); dynamic_resid_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T);

View File

@ -34,11 +34,11 @@
#include "dynamic_abstract_class.hh" #include "dynamic_abstract_class.hh"
#include "dynare_exception.h" #include "dynare_exception.h"
typedef void (*dynamic_tt_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T); using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);
typedef void (*dynamic_resid_fct) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *residual); using dynamic_resid_fct = void (*) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *residual);
typedef void (*dynamic_g1_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *g1); using dynamic_g1_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *g1);
typedef void (*dynamic_g2_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v2); using dynamic_g2_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v2);
typedef void (*dynamic_g3_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v3); using dynamic_g3_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v3);
/** /**
* creates pointer to Dynamic function inside <model>_dynamic.dll * creates pointer to Dynamic function inside <model>_dynamic.dll
@ -61,11 +61,10 @@ private:
public: public:
// construct and load Dynamic model DLL // construct and load Dynamic model DLL
DynamicModelDLL(const string &fname) throw (DynareException); explicit DynamicModelDLL(const string &fname) noexcept(false);
virtual virtual ~DynamicModelDLL();
~DynamicModelDLL();
void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady, void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady,
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException); Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false);
}; };
#endif #endif

View File

@ -19,18 +19,14 @@
#include "dynamic_m.hh" #include "dynamic_m.hh"
DynamicModelMFile::DynamicModelMFile(const string &modName) throw (DynareException) : DynamicModelMFile::DynamicModelMFile(const string &modName) noexcept(false) :
DynamicMFilename(modName + ".dynamic") DynamicMFilename{modName + ".dynamic"}
{
}
DynamicModelMFile::~DynamicModelMFile()
{ {
} }
void void
DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady, DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady,
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException) Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false)
{ {
mxArray *prhs[nrhs_dynamic], *plhs[nlhs_dynamic]; mxArray *prhs[nrhs_dynamic], *plhs[nlhs_dynamic];
@ -51,10 +47,10 @@ DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParam
residual = Vector(mxGetPr(plhs[0]), residual.skip(), (int) mxGetM(plhs[0])); residual = Vector(mxGetPr(plhs[0]), residual.skip(), (int) mxGetM(plhs[0]));
copyDoubleIntoTwoDMatData(mxGetPr(plhs[1]), g1, (int) mxGetM(plhs[1]), (int) mxGetN(plhs[1])); copyDoubleIntoTwoDMatData(mxGetPr(plhs[1]), g1, (int) mxGetM(plhs[1]), (int) mxGetN(plhs[1]));
if (g2 != NULL) if (g2 != nullptr)
copyDoubleIntoTwoDMatData(unpackSparseMatrix(plhs[2]), g2, (int) mxGetNzmax(plhs[2]), 3); unpackSparseMatrixAndCopyIntoTwoDMatData(plhs[2], g2);
if (g3 != NULL) if (g3 != nullptr)
copyDoubleIntoTwoDMatData(unpackSparseMatrix(plhs[3]), g3, (int) mxGetNzmax(plhs[3]), 3); unpackSparseMatrixAndCopyIntoTwoDMatData(plhs[3], g3);
for (int i = 0; i < nrhs_dynamic; i++) for (int i = 0; i < nrhs_dynamic; i++)
mxDestroyArray(prhs[i]); mxDestroyArray(prhs[i]);

View File

@ -36,10 +36,9 @@ private:
const static int nlhs_dynamic = 4; const static int nlhs_dynamic = 4;
const static int nrhs_dynamic = 5; const static int nrhs_dynamic = 5;
public: public:
DynamicModelMFile(const string &modName) throw (DynareException); explicit DynamicModelMFile(const string &modName) noexcept(false);
virtual virtual ~DynamicModelMFile() = default;
~DynamicModelMFile();
void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady, void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady,
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException); Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false);
}; };
#endif #endif

View File

@ -40,14 +40,14 @@ KordpDynare::KordpDynare(const vector<string> &endo, int num_endo,
Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat, Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector &nnzd, int npred, int nforw, int nboth, const int jcols, const Vector &nnzd,
const int nsteps, int norder, const int nsteps, int norder,
Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium) throw (TLException) : const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium) noexcept(false) :
nStat(nstat), nBoth(nboth), nPred(npred), nForw(nforw), nExog(nexog), nPar(npar), nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar},
nYs(npred + nboth), nYss(nboth + nforw), nY(num_endo), nJcols(jcols), NNZD(nnzd), nSteps(nsteps), nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps},
nOrder(norder), journal(jr), ySteady(ysteady), params(inParams), vCov(vcov), nOrder{norder}, journal{jr}, ySteady{ysteady}, params{inParams}, vCov{vcov},
md(1), dnl(*this, endo), denl(*this, exo), dsnl(*this, dnl, denl), ss_tol(sstol), varOrder(var_order), md{1}, dnl{*this, endo}, denl{*this, exo}, dsnl{*this, dnl, denl}, ss_tol{sstol}, varOrder{var_order},
ll_Incidence(llincidence), qz_criterium(criterium), g1p(NULL), ll_Incidence{llincidence}, qz_criterium{criterium}, g1p{nullptr},
g2p(NULL), g3p(NULL), dynamicModelFile(dynamicModelFile_arg) g2p{nullptr}, g3p{nullptr}, dynamicModelFile{move(dynamicModelFile_arg)}
{ {
ReorderDynareJacobianIndices(); ReorderDynareJacobianIndices();
@ -61,15 +61,15 @@ KordpDynare::KordpDynare(const vector<string> &endo, int num_endo,
Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat, Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector &nnzd, int npred, int nforw, int nboth, const int jcols, const Vector &nnzd,
const int nsteps, int norder, const int nsteps, int norder,
Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium, const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium,
TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) throw (TLException) : TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false) :
nStat(nstat), nBoth(nboth), nPred(npred), nForw(nforw), nExog(nexog), nPar(npar), nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar},
nYs(npred + nboth), nYss(nboth + nforw), nY(num_endo), nJcols(jcols), NNZD(nnzd), nSteps(nsteps), nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps},
nOrder(norder), journal(jr), ySteady(ysteady), params(inParams), vCov(vcov), nOrder{norder}, journal{jr}, ySteady{ysteady}, params{inParams}, vCov{vcov},
md(1), dnl(*this, endo), denl(*this, exo), dsnl(*this, dnl, denl), ss_tol(sstol), varOrder(var_order), md{1}, dnl{*this, endo}, denl{*this, exo}, dsnl{*this, dnl, denl}, ss_tol{sstol}, varOrder{var_order},
ll_Incidence(llincidence), qz_criterium(criterium), ll_Incidence{llincidence}, qz_criterium{criterium},
g1p(g1_arg), g2p(g2_arg), g3p(g3_arg), dynamicModelFile(dynamicModelFile_arg) g1p{g1_arg}, g2p{g2_arg}, g3p{g3_arg}, dynamicModelFile{move(dynamicModelFile_arg)}
{ {
ReorderDynareJacobianIndices(); ReorderDynareJacobianIndices();
@ -91,7 +91,7 @@ KordpDynare::solveDeterministicSteady()
} }
void void
KordpDynare::evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) throw (DynareException) KordpDynare::evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) noexcept(false)
{ {
// This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals // This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals
out.zeros(); out.zeros();
@ -99,7 +99,7 @@ KordpDynare::evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) thr
void void
KordpDynare::evaluateSystem(Vector &out, const Vector &yym, const Vector &yy, KordpDynare::evaluateSystem(Vector &out, const Vector &yym, const Vector &yy,
const Vector &yyp, const Vector &xx) throw (DynareException) const Vector &yyp, const Vector &xx) noexcept(false)
{ {
// This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals // This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals
out.zeros(); out.zeros();
@ -112,7 +112,7 @@ KordpDynare::evaluateSystem(Vector &out, const Vector &yym, const Vector &yy,
void void
KordpDynare::calcDerivativesAtSteady() KordpDynare::calcDerivativesAtSteady()
{ {
if (g1p == NULL) if (g1p == nullptr)
{ {
g1p = new TwoDMatrix(nY, nJcols); g1p = new TwoDMatrix(nY, nJcols);
g1p->zeros(); g1p->zeros();
@ -166,7 +166,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve
// model derivatives FSSparseTensor instance // model derivatives FSSparseTensor instance
FSSparseTensor *mdTi = (new FSSparseTensor(ord, nJcols, nY)); FSSparseTensor *mdTi = (new FSSparseTensor(ord, nJcols, nY));
IntSequence s(ord, 0); IntSequence s{ord, 0};
if (ord == 1) if (ord == 1)
{ {
@ -261,7 +261,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve
* passing to <model>_dynamic DLL * passing to <model>_dynamic DLL
*************************************************************/ *************************************************************/
void void
KordpDynare::LLxSteady(const Vector &yS, Vector &llxSteady) throw (DynareException, TLException) KordpDynare::LLxSteady(const Vector &yS, Vector &llxSteady) noexcept(false)
{ {
if ((nJcols-nExog) == yS.length()) if ((nJcols-nExog) == yS.length())
throw DynareException(__FILE__, __LINE__, "ySteady already of right size"); throw DynareException(__FILE__, __LINE__, "ySteady already of right size");
@ -308,7 +308,7 @@ KordpDynare::LLxSteady(const Vector &yS, Vector &llxSteady) throw (DynareExcepti
************************************/ ************************************/
void void
KordpDynare::ReorderDynareJacobianIndices() throw (TLException) KordpDynare::ReorderDynareJacobianIndices() noexcept(false)
{ {
// create temporary square 2D matrix size nEndo x nEndo (sparse) // create temporary square 2D matrix size nEndo x nEndo (sparse)
// for the lag, current and lead blocks of the jacobian // for the lag, current and lead blocks of the jacobian
@ -351,7 +351,7 @@ DynareStateNameList::DynareStateNameList(const KordpDynare &dynare, const Dynare
const DynareNameList &denl) const DynareNameList &denl)
{ {
for (int i = 0; i < dynare.nys(); i++) for (int i = 0; i < dynare.nys(); i++)
names.push_back(string(dnl.getName(i+dynare.nstat()))); names.push_back(string{dnl.getName(i+dynare.nstat())});
for (int i = 0; i < dynare.nexog(); i++) for (int i = 0; i < dynare.nexog(); i++)
names.push_back(string(denl.getName(i))); names.push_back(string{denl.getName(i)});
} }

View File

@ -20,6 +20,7 @@
#ifndef K_ORD_DYNARE3_H #ifndef K_ORD_DYNARE3_H
#define K_ORD_DYNARE3_H #define K_ORD_DYNARE3_H
#include <vector> #include <vector>
#include <memory>
#include "t_container.h" #include "t_container.h"
#include "sparse_tensor.h" #include "sparse_tensor.h"
#include "decision_rule.h" #include "decision_rule.h"
@ -123,20 +124,19 @@ public:
Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred, Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred,
int nforw, int nboth, const int nJcols, const Vector &NNZD, int nforw, int nboth, const int nJcols, const Vector &NNZD,
const int nSteps, const int ord, const int nSteps, const int ord,
Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &varOrder, const TwoDMatrix &ll_Incidence, const vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
double qz_criterium) throw (TLException); double qz_criterium) noexcept(false);
KordpDynare(const vector<string> &endo, int num_endo, KordpDynare(const vector<string> &endo, int num_endo,
const vector<string> &exo, int num_exo, int num_par, const vector<string> &exo, int num_exo, int num_par,
Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred, Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred,
int nforw, int nboth, const int nJcols, const Vector &NNZD, int nforw, int nboth, const int nJcols, const Vector &NNZD,
const int nSteps, const int ord, const int nSteps, const int ord,
Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &varOrder, const TwoDMatrix &ll_Incidence, const vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) throw (TLException); double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false);
virtual virtual ~KordpDynare();
~KordpDynare();
int int
nstat() const nstat() const
{ {
@ -230,21 +230,21 @@ public:
} }
void solveDeterministicSteady(); void solveDeterministicSteady();
void evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) throw (DynareException); void evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) noexcept(false);
void evaluateSystem(Vector &out, const Vector &yym, const Vector &yy, void evaluateSystem(Vector &out, const Vector &yym, const Vector &yy,
const Vector &yyp, const Vector &xx) throw (DynareException); const Vector &yyp, const Vector &xx) noexcept(false);
void calcDerivativesAtSteady(); void calcDerivativesAtSteady();
DynamicModelAC *dynamicModelFile; unique_ptr<DynamicModelAC> dynamicModelFile;
DynamicModel * DynamicModel *
clone() const clone() const
{ {
std::cerr << "KordpDynare::clone() not implemented" << std::endl; std::cerr << "KordpDynare::clone() not implemented" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
void LLxSteady(const Vector &yS, Vector &llxSteady) throw (DynareException, TLException); // Given the steady state in yS, returns in llxSteady the steady state extended with leads and lags void LLxSteady(const Vector &yS, Vector &llxSteady) noexcept(false); // Given the steady state in yS, returns in llxSteady the steady state extended with leads and lags
private: private:
void ReorderDynareJacobianIndices() throw (TLException); void ReorderDynareJacobianIndices() noexcept(false);
void populateDerivativesContainer(const TwoDMatrix &g, int ord, const vector<int> &vOrder); void populateDerivativesContainer(const TwoDMatrix &g, int ord, const vector<int> &vOrder);
}; };

View File

@ -198,9 +198,9 @@ extern "C" {
if ((nEndo != nendo) || (nExog != nexo)) if ((nEndo != nendo) || (nExog != nexo))
DYN_MEX_FUNC_ERR_MSG_TXT("Incorrect number of input parameters."); DYN_MEX_FUNC_ERR_MSG_TXT("Incorrect number of input parameters.");
TwoDMatrix *g1m = NULL; TwoDMatrix *g1m = nullptr;
TwoDMatrix *g2m = NULL; TwoDMatrix *g2m = nullptr;
TwoDMatrix *g3m = NULL; TwoDMatrix *g3m = nullptr;
// derivatives passed as arguments */ // derivatives passed as arguments */
if (nrhs > 3) if (nrhs > 3)
{ {
@ -236,11 +236,11 @@ extern "C" {
jName += ".jnl"; jName += ".jnl";
Journal journal(jName.c_str()); Journal journal(jName.c_str());
DynamicModelAC *dynamicModelFile; unique_ptr<DynamicModelAC> dynamicModelFile;
if (use_dll == 1) if (use_dll == 1)
dynamicModelFile = new DynamicModelDLL(fName); dynamicModelFile = make_unique<DynamicModelDLL>(fName);
else else
dynamicModelFile = new DynamicModelMFile(fName); dynamicModelFile = make_unique<DynamicModelMFile>(fName);
// intiate tensor library // intiate tensor library
tls.init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog); tls.init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog);
@ -248,7 +248,7 @@ extern "C" {
// make KordpDynare object // make KordpDynare object
KordpDynare dynare(endoNames, nEndo, exoNames, nExog, nPar, KordpDynare dynare(endoNames, nEndo, exoNames, nExog, nPar,
ySteady, vCov, modParams, nStat, nPred, nForw, nBoth, ySteady, vCov, modParams, nStat, nPred, nForw, nBoth,
jcols, NNZD, nSteps, kOrder, journal, dynamicModelFile, jcols, NNZD, nSteps, kOrder, journal, move(dynamicModelFile),
sstol, var_order_vp, llincidence, qz_criterium, sstol, var_order_vp, llincidence, qz_criterium,
g1m, g2m, g3m); g1m, g2m, g3m);

@ -1 +1 @@
Subproject commit bef7c2a1938f1201cffbddc8d597b2a486fd36c6 Subproject commit 571b5d081657271b7f5e02f93778bddf9020787b

Some files were not shown because too many files have changed in this diff Show More