Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
  • chskcau/dynare-doc-fixes
27 results
Select Git revision
Show changes
Commits on Source (142)
Showing
with 516 additions and 14 deletions
......@@ -195,6 +195,18 @@ mex/build/matlab/run_m2html.m
/contrib/ms-sbvar/sbvar_init_file
/tests/ms-sbvar/*.tmp
# DMM
*.nml
/mex/build/matlab/dmm/*.mod
/mex/build/octave/dmm/*.mod
*.PRI
*.DIS
*.FST
*.INN
*.ML
*.PAR
*.UNB
# Reporting
*synctex.gz
tests/reporting/tmpRepDir
dmm @ a58ee984
Subproject commit ea7846fd71d32851877cf60008ac5046b51a7a51
Subproject commit a58ee9845df900fd532fec8bc91839f720fa8193
......@@ -26,14 +26,16 @@ AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is
AC_MSG_CHECKING([for options to compile MEX for MATLAB])
MATLAB_CPPFLAGS="-I$MATLAB/extern/include"
MATLAB_INCLUDE_DIR="-I$MATLAB/extern/include"
MATLAB_CPPFLAGS="$MATLAB_INCLUDE_DIR"
case ${MATLAB_ARCH} in
glnx86 | glnxa64)
MATLAB_DEFS="$MATLAB_DEFS -D_GNU_SOURCE -DNDEBUG"
MATLAB_CFLAGS="-fexceptions -fPIC -pthread -g -O2"
MATLAB_CXXFLAGS="-fPIC -pthread -g -O2"
MATLAB_FFLAGS="-fPIC -g -O2 -fexceptions"
MATLAB_FFLAGS="$MATLAB_INCLUDE_DIR -fPIC -g -O2 -fexceptions"
MATLAB_FCFLAGS="$MATLAB_FFLAGS"
MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/${MATLAB_ARCH} -L$MATLAB/bin/${MATLAB_ARCH}"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map"
MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack -lmwblas"
......@@ -50,7 +52,8 @@ case ${MATLAB_ARCH} in
win32 | win64)
MATLAB_CFLAGS="-fexceptions -g -O2"
MATLAB_CXXFLAGS="-g -O2"
MATLAB_FFLAGS="-fexceptions -g -O2 -fno-underscoring"
MATLAB_FFLAGS="$MATLAB_INCLUDE_DIR -fexceptions -g -O2 -fno-underscoring"
MATLAB_FCFLAGS="$MATLAB_FFLAGS"
MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
# Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions)
MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -shared -L$MATLAB/bin/${MATLAB_ARCH}"
......@@ -68,9 +71,10 @@ case ${MATLAB_ARCH} in
MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
MATLAB_CFLAGS="-fno-common -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions"
MATLAB_CXXFLAGS="-fno-common -fexceptions -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
MATLAB_FFLAGS="-fexceptions -fbackslash -arch $ARCHS"
MATLAB_FFLAGS="$MATLAB_INCLUDE_DIR -fexceptions -fbackslash -arch $ARCHS"
MATLAB_FCFLAGS="$MATLAB_FFLAGS"
MATLAB_LDFLAGS_NOMAP="-L$MATLAB/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,$(pwd)/$srcdir/mexFunction-MacOSX.map"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map"
MATLAB_LIBS="-lmx -lmex -lmat -lstdc++ -lmwlapack -lmwblas"
ax_mexopts_ok="yes"
;;
......
......@@ -53,6 +53,7 @@ addpath([dynareroot '/partial_information/'])
addpath([dynareroot '/ms-sbvar/'])
addpath([dynareroot '/ms-sbvar/identification/'])
addpath([dynareroot '../contrib/ms-sbvar/TZcode/MatlabFiles/'])
addpath([dynareroot '../contrib/dmm/matlab/'])
addpath([dynareroot '/parallel/'])
addpath([dynareroot '/particle/'])
addpath([dynareroot '/gsa/'])
......@@ -252,6 +253,16 @@ else
end
if verbose
disp([ message 'Markov Switching SBVAR.' ])
end
% Test if DMM DLL is present
if exist('dmm', 'file') == 3
message = '[mex] ';
else
message = '[no] ';
end
if verbose
disp([ message 'Dynamic Mixture Models.' ])
skipline()
end
......
......@@ -321,7 +321,8 @@ options_.timeless = 0;
estimation_info.empty_prior = struct(...
'domain', [], 'interval', [], 'mean', [], ...
'median', [], 'mode', [], 'shape', [], ...
'shift', [], 'stdev', [], 'truncate', [], 'variance', []);
'shift', [], 'stdev', [], 'truncate', [], ...
'variance', [], 'params', []);
estimation_info.empty_options = struct(...
'bounds',[], 'init', [], 'jscale', []);
estimation_info.subsamples.range = struct('date1', [], 'date2', []);
......@@ -345,6 +346,7 @@ estimation_info.measurement_error_corr.prior = estimation_info.empty_prior;
estimation_info.measurement_error_corr.subsample_prior = estimation_info.empty_prior;
estimation_info.measurement_error_corr.options = estimation_info.empty_options;
estimation_info.measurement_error_corr.subsample_options = estimation_info.empty_options;
estimation_info.transition_probability.prior = estimation_info.empty_prior;
estimation_info.subsamples_index = {};
estimation_info.subsamples.range_index = {};
estimation_info.parameter_prior_index = {};
......@@ -362,6 +364,10 @@ estimation_info.measurement_error_corr.range_index = {};
estimation_info.structural_innovation_corr_prior_index = {};
estimation_info.structural_innovation_corr_options_index = {};
estimation_info.structural_innovation_corr.range_index = {};
estimation_info.transition_probability_index = {};
options_.initial_period = dates(1,1);
options_.dataset.firstobs = options_.initial_period;
options_.dataset.lastobs = NaN;
options_.initial_period = NaN; %dates(1,1);
options_.dataset.file = [];
options_.dataset.series = [];
......@@ -637,6 +643,20 @@ options_.gpu = 0;
options_.convergence.geweke.taper_steps=[4 8 15];
options_.convergence.geweke.geweke_interval=[0.2 0.5];
% DMM
options_.dmm.seed = 0;
options_.dmm.thinning_factor = 1;
options_.dmm.block_length = 1;
options_.dmm.calc_marg_lik = 'N';
options_.dmm.check_mats = 'N';
options_.dmm.simulate_data = 'N';
options_.dmm.num_forecasts = 0;
options_.mcmc.drop = 100;
options_.mcmc.replic = 1000;
options_.calibration = [];
options_.multinomial = [];
% Options for lmmcp solver
options_.lmmcp = [];
......
function multinomial = set_multinomial_default()
%function multinomial = set_multinomial_default()
% creates the default multinomial substructure for options_
%
% INPUTS
% none
%
% OUTPUTS
% multinomial (struct)
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
multinomial.process = 1;
multinomial.values = [];
multinomial.parameters=[];
multinomial.parameters = '';
multinomial.probability=[];
end
\ No newline at end of file
function writeDmmNmlFile(M_, options_, estimation_info)
% function writeDmmNmlFile(M_, options_, estimation_info)
% Writes the NML file used by the DMM code
%
% INPUTS
% M_ [structure]
% options_ [structure]
% estimation_info [structure]
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
fid = fopen([M_.fname '.nml'], 'w');
if fid == -1
error(['writeDmmNmlFile could not open ' M_.fname '.nml for writing.']);
end
fprintf(fid, '%s.nml file generated by Dynare\n', M_.fname);
fprintf(fid, 'from %s.mod on %d-%d-%d at %d:%d:%d\n', M_.fname, fix(clock));
%% Prior
fprintf(fid, '\n&prior\n');
nt = size(estimation_info.parameter,2);
fprintf(fid, 'nt=%d\n', nt);
for i=1:nt
switch estimation_info.parameter(i).prior(1).shape
case 1
shape = 'BE';
case 3
shape = 'NT';
case 4
shape = 'IG';
otherwise
error(['Only inv_gamma, normal, and beta are supported for the ' ...
'prior distributions of dmm.']);
end
fprintf(fid, 'pdftheta(%d) = "%s" hyptheta(1, %d) = %d %d %d %d\n', i, ...
shape, i, estimation_info.parameter(i).prior(1).mean, ...
estimation_info.parameter(i).prior(1).stdev, ...
estimation_info.parameter(i).prior(1).interval);
end
fprintf(fid, '&end\n');
%% MCMC
fprintf(fid, '\n&mcmc\n');
fprintf(fid, 'seed=%d thin=%d burnin=%d simulrec=%d hbl=%d MargLik="%s"', ...
options_.dmm.seed, options_.dmm.thinning_factor, options_.mcmc.drop, ...
options_.mcmc.replic, options_.dmm.block_length, ...
options_.dmm.calc_marg_lik);
fprintf(fid, '\n&end\n');
%% S* (Latent Variables)
% Check that two latent vars don't impact the same matrix
combine = {};
mats = {'C', 'H', 'G', 'A', 'F', 'R'};
for i=1:length(mats)
if sum(strcmp({options_.dmm.S.mat}, mats{i})) > 1
idxs = strcmp({options_.dmm.S.mat}, mats{i});
canLatentVarsBeCombiend(options_, idxs);
combine = [combine; {mats{i}, idxs}];
end
end
wroteLatVarFor = {};
for i=1:size(options_.dmm.S, 2)
if ~any(strcmp(wroteLatVarFor(:), options_.dmm.S(i).mat))
numStates = 1;
if any(strcmp(combine(:,1), options_.dmm.S(i).mat))
for j=1:size(options_.dmm.S, 2)
if any(strcmp(combine(:,1), options_.dmm.S(i).mat))
numStates = numStates*options_.dmm.S(i).ns;
end
end
else
numStates = options_.dmm.S(i).ns;
end
multidx = find(strcmp({options_.multinomial(:).process}, options_.dmm.S(i).process));
tpidx = find(strcmp(estimation_info.transition_probability_index, options_.multinomial(multidx).probability));
params = estimation_info.transition_probability(tpidx).prior.params;
fprintf(fid, '\n&S%d\n', i);
fprintf(fid, 'dynS%d="%s" nS%d=%d hypS%d(1,1)=%s matS%d="%s"',i,'I',i, ...
numStates, i, num2str(params), i, options_.dmm.S(i).mat);
fprintf(fid, '\n&end\n');
wroteLatVarFor = [wroteLatVarFor options_.dmm.S(i).mat];
end
end
%% SSM
fprintf(fid, '\n&ssm\n');
fprintf(fid, 'nu=%d nv=%d nx=%d d=%d %d dllname="%s" check="%s"', M_.exo_nbr, ...
length(wroteLatVarFor), options_.dmm.nx, ...
options_.dmm.max_order_of_integration, options_.dmm.num_nonstationary, ...
[cd filesep M_.fname '_dmm.m'], options_.dmm.check_mats);
fprintf(fid, '\n&end\n');
%% Dataset
fprintf(fid, '\n&dataset\n');
data = options_.dmm.dataset;
Tobs = size(data, 1);
if M_.exo_det_nbr == 0
assert(size(data,2) == options_.varobs_nbr, ['Error: when the number of exogenous ' ...
'variables is equal to zero, you must have the same ' ...
'number of columns of data as varobs.']);
else
assert(size(data, 2) == options_.varobs_nbr + M_.exo_det_nbr, ['Error: when the number ' ...
'of exogenous variables is greater than zero, you ' ...
'must have the same number of columns as varobs+varexodet']);
Tobs = Tobs - options_.dmm.num_forecasts;
end
fprintf(fid, 'T=%d ny=%d nz=%d nf=%d datasim="%s" obs=\n', ...
Tobs, options_.varobs_nbr, M_.exo_det_nbr, options_.dmm.num_forecasts, options_.dmm.simulate_data);
for i=1:size(data,1)
fprintf(fid, '%f ', data.data(i,:));
fprintf(fid, '\n');
end
fprintf(fid, '&end\n');
%% Close file
fclose(fid);
end
function canLatentVarsBeCombiend(options_, idxs)
% if two latent vars impact the same matrix, see if they have the same
% prior and hence can be combined
if ~all(strcmp(options_.multinomial(idxs).probability))
error(['writeDmmNmlFile: Two latent variables impact DMM matrix ' ...
options_.dmm.S(idxs(1)).mat ...
' and have different transition probabilities']);
end
end
noinst_PROGRAMS = dmm
DMMDIR = $(top_srcdir)/../../../contrib/dmm
DYNMEXSRCDIR = $(top_srcdir)/../../sources
DMMMEXSRCDIR = $(DYNMEXSRCDIR)/dmm
AM_FFLAGS += -cpp $(DEFS) -fcray-pointer -ffixed-form -ffixed-line-length-none -std=legacy
AM_FCFLAGS += -cpp $(DEFS) -fdefault-integer-8 -fPIC
LDADD = $(FLIBS) $(FCLIBS)
nodist_dmm_SOURCES = \
$(DMMMEXSRCDIR)/mexinterface.f90 \
$(DMMDIR)/iso_c_utilities.f90 \
$(DMMDIR)/dlfcn.f90 \
$(DMMDIR)/logical2integer.for \
$(DMMDIR)/gammln.for \
$(DMMDIR)/invfbis.for \
$(DMMDIR)/recest.for \
$(DMMDIR)/invnormcdf.for \
$(DMMDIR)/mvncdf.for \
$(DMMDIR)/kf.for \
$(DMMDIR)/mvnpdf.for \
$(DMMDIR)/schollu.for \
$(DMMDIR)/harmonic.for \
$(DMMDIR)/kf2.for \
$(DMMDIR)/neweywestcov.for \
$(DMMDIR)/chi2inv.for \
$(DMMDIR)/harmonic2.for \
$(DMMDIR)/kim.for \
$(DMMDIR)/neweywestcov2.for \
$(DMMDIR)/simprior.for \
$(DMMDIR)/hf.for \
$(DMMDIR)/ks.for \
$(DMMDIR)/ols.for \
$(DMMDIR)/cumnorm.for \
$(DMMDIR)/ikf.for \
$(DMMDIR)/ks2.for \
$(DMMDIR)/openfiles.for \
$(DMMDIR)/designz.for \
$(DMMDIR)/ikf2.for \
$(DMMDIR)/lemma4.for \
$(DMMDIR)/slice.for \
$(DMMDIR)/drawpsi.for \
$(DMMDIR)/initrand.for \
$(DMMDIR)/logmvnpdf.for \
$(DMMDIR)/slice2.for \
$(DMMDIR)/drawtheta.for \
$(DMMDIR)/lyapunov.for \
$(DMMDIR)/syminv.for \
$(DMMDIR)/drawtheta2.for \
$(DMMDIR)/pprod.for \
$(DMMDIR)/tnormi.for \
$(DMMDIR)/ergodic.for \
$(DMMDIR)/input.for \
$(DMMDIR)/markovp.for \
$(DMMDIR)/prior.for \
$(DMMDIR)/var.for \
$(DMMDIR)/findinput.for \
$(DMMDIR)/int2seq.for \
$(DMMDIR)/mengwong.for \
$(DMMDIR)/priordir.for \
$(DMMDIR)/forecast.for \
$(DMMDIR)/int2seq2.for \
$(DMMDIR)/mengwong2.for \
$(DMMDIR)/invf.for \
$(DMMDIR)/amh.for \
$(DMMDIR)/gck.for \
$(DMMDIR)/amh2.for \
$(DMMDIR)/gck2.for \
$(DMMDIR)/checkdesign.for \
$(DMMDIR)/innov.for \
$(DMMDIR)/innov2.for \
$(DMMDIR)/main.for \
$(DMMDIR)/missing.for \
$(DMMDIR)/opg.for \
$(DMMDIR)/opgh.for \
$(DMMDIR)/opgkim.for \
$(DMMDIR)/ptheta.for \
$(DMMDIR)/ptheta2.for \
$(DMMDIR)/simdata.for \
$(DMMDIR)/simstate.for \
$(DMMDIR)/simstate2.for \
$(DMMDIR)/recpr.for \
$(DMMDIR)/setfilem.for \
$(DMMDIR)/geterrstr.for \
$(DMMDIR)/randlib/advnst.f \
$(DMMDIR)/randlib/genmn.f \
$(DMMDIR)/randlib/genunf.f \
$(DMMDIR)/randlib/ignlgi.f \
$(DMMDIR)/randlib/inrgcm.f \
$(DMMDIR)/randlib/phrtsd.f \
$(DMMDIR)/randlib/sdot.f \
$(DMMDIR)/randlib/setgmn.f \
$(DMMDIR)/randlib/sgamma.f \
$(DMMDIR)/randlib/genbet.f \
$(DMMDIR)/randlib/gennor.f \
$(DMMDIR)/randlib/getcgn.f \
$(DMMDIR)/randlib/ignuin.f \
$(DMMDIR)/randlib/lennob.f \
$(DMMDIR)/randlib/qrgnin.f \
$(DMMDIR)/randlib/setall.f \
$(DMMDIR)/randlib/setsd.f \
$(DMMDIR)/randlib/snorm.f \
$(DMMDIR)/randlib/gengam.f \
$(DMMDIR)/randlib/genprm.f \
$(DMMDIR)/randlib/getsd.f \
$(DMMDIR)/randlib/initgn.f \
$(DMMDIR)/randlib/mltmod.f \
$(DMMDIR)/randlib/ranf.f \
$(DMMDIR)/randlib/setant.f \
$(DMMDIR)/randlib/sexpo.f \
$(DMMDIR)/randlib/spofa.f \
$(DMMMEXSRCDIR)/design.f90 \
$(DMMMEXSRCDIR)/mexprint.f90 \
$(DMMMEXSRCDIR)/designInternal.cc \
$(DMMMEXSRCDIR)/dmm.cc
CLEANFILES = *.mod
......@@ -3,7 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../m4
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if DO_SOMETHING
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv block_kalman_filter sobol local_state_space_iterations
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv block_kalman_filter sobol local_state_space_iterations dmm
if HAVE_MATIO
SUBDIRS += k_order_perturbation dynare_simul_
......@@ -34,4 +34,4 @@ install-exec-local:
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/mex/matlab
endif
EXTRA_DIST = mex.def mexFunction-MacOSX.map
EXTRA_DIST = mex.def
......@@ -39,6 +39,7 @@ if test "x$ax_enable_matlab" = "xyes"; then
CFLAGS="$MATLAB_CFLAGS"
CXXFLAGS="$MATLAB_CXXFLAGS"
FFLAGS="$MATLAB_FFLAGS"
FCFLAGS="$MATLAB_FCFLAGS"
fi
case ${host_os} in
......@@ -54,9 +55,15 @@ esac
CFLAGS="$CFLAGS -Wall -Wno-parentheses"
FFLAGS="$FFLAGS -Wall"
FCFLAGS="$FCFLAGS -Wall"
CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses"
AC_PROG_F77([gfortran g77 f77])
AC_F77_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
AC_PROG_FC([gfortran])
AC_FC_LIBRARY_LDFLAGS
AC_FC_WRAPPERS
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
......@@ -167,9 +174,10 @@ AC_CONFIG_FILES([Makefile
dynare_simul_/Makefile
estimation/Makefile
kalman_steady_state/Makefile
dmm/Makefile
ms_sbvar/Makefile
block_kalman_filter/Makefile
sobol/Makefile
local_state_space_iterations/Makefile])
sobol/Makefile
local_state_space_iterations/Makefile])
AC_OUTPUT
include ../mex.am
include ../../dmm.am
......@@ -2,6 +2,10 @@ EXEEXT = $(MEXEXT)
AM_CPPFLAGS = $(MATLAB_CPPFLAGS)
AM_CPPFLAGS += -I$(top_srcdir)/../../sources
AM_FFLAGS = $(MATLAB_FFLAGS)
AM_FFLAGS += -I$(top_srcdir)/../../sources
AM_FCFLAGS = $(MATLAB_FFLAGS)
AM_FCFLAGS += -I$(top_srcdir)/../../sources
DEFS += $(MATLAB_DEFS)
DEFS += -DMATLAB_MEX_FILE
......
_mexFunction
......@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I ../../../m4
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if DO_SOMETHING
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv qzcomplex ordschur block_kalman_filter sobol local_state_space_iterations
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv qzcomplex ordschur block_kalman_filter sobol local_state_space_iterations dmm
if COMPILE_LINSOLVE
SUBDIRS += linsolve
......
......@@ -25,10 +25,14 @@ AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign])
AC_CHECK_PROG([MKOCTFILE], [mkoctfile], [mkoctfile])
if test "x$MKOCTFILE" != "x"; then
INCDIR=`$MKOCTFILE -p INCFLAGS`
CC=`$MKOCTFILE -p CC`
CXX=`$MKOCTFILE -p CXX`
CFLAGS=`$MKOCTFILE -p CFLAGS`
FFLAGS=`$MKOCTFILE -p FFLAGS`
FFLAGS="$FFLAGS $INCDIR"
FCFLAGS=`$MKOCTFILE -p FCFLAGS`
FCFLAGS="$FCFLAGS $INCDIR"
CXXFLAGS=`$MKOCTFILE -p CXXFLAGS`
LDFLAGS="`$MKOCTFILE -p LFLAGS` `$MKOCTFILE -p LDFLAGS`"
OCTAVE_VERSION=`$MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //'`
......@@ -40,9 +44,15 @@ AM_CONDITIONAL([COMPILE_LINSOLVE], [test "$OCTAVE38" != "yes"])
CFLAGS="$CFLAGS -Wall -Wno-parentheses"
FFLAGS="$FFLAGS -Wall"
FCFLAGS="$FCFLAGS -Wall"
CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses"
AC_PROG_F77([gfortran g77 f77])
AC_F77_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
AC_PROG_FC([gfortran])
AC_FC_LIBRARY_LDFLAGS
AC_FC_WRAPPERS
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
......@@ -154,6 +164,7 @@ AC_CONFIG_FILES([Makefile
qzcomplex/Makefile
ordschur/Makefile
kalman_steady_state/Makefile
dmm/Makefile
ms_sbvar/Makefile
block_kalman_filter/Makefile
sobol/Makefile
......
EXEEXT = .mex
include ../mex.am
include ../../dmm.am
......@@ -7,6 +7,7 @@ DEFS += -DMEXEXT=\".mex\"
AM_CFLAGS = $(shell $(MKOCTFILE) -p CPICFLAG)
AM_FFLAGS = $(shell $(MKOCTFILE) -p FPICFLAG)
AM_FCFLAGS = $(shell $(MKOCTFILE) -p FPICFLAG)
AM_CXXFLAGS = $(shell $(MKOCTFILE) -p CXXPICFLAG)
AM_LDFLAGS = $(shell $(MKOCTFILE) -p DL_LDFLAGS)
......
......@@ -16,7 +16,8 @@ EXTRA_DIST = \
block_kalman_filter \
sobol \
local_state_space_iterations \
linsolve
linsolve \
dmm
clean-local:
rm -rf `find mex/sources -name *.o`
......
!
! Copyright (C) 2014 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/>.
!
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
#if defined(MATLAB_MEX_FILE)
#include "fintrf.h"
#endif
#ifndef MWPOINTER
#define MWPOINTER integer(4)
#endif
#ifndef mwPointer
#define mwPointer MWPOINTER
#endif
SUBROUTINE DESIGN(ny,nz,nx,nu,ns,nt,theta,c,H,G,a,F,R)
USE MEXINTERFACE
IMPLICIT NONE
! INPUT
INTEGER(C_INT), INTENT(IN) :: ny,nz,nx,nu,nt
INTEGER, DIMENSION(6), INTENT(IN) :: ns
DOUBLE PRECISION, DIMENSION(nt), INTENT(IN) :: theta
! OUTPUT
DOUBLE PRECISION, DIMENSION(ny,max(1,nz),ns(1)), INTENT(OUT) :: c
DOUBLE PRECISION, DIMENSION(ny,nx,ns(2)), INTENT(OUT) :: H
DOUBLE PRECISION, DIMENSION(ny,nu,ns(3)), INTENT(OUT) :: G
DOUBLE PRECISION, DIMENSION(nx,ns(4)), INTENT(OUT) :: a
DOUBLE PRECISION, DIMENSION(nx,nx,ns(5)), INTENT(OUT) :: F
DOUBLE PRECISION, DIMENSION(nx,nu,ns(6)), INTENT(OUT) :: R
! COMMON
CHARACTER*200 mfile
COMMON /M/ mfile
! LOCAL
INTEGER I
INTEGER(C_INT), DIMENSION(6) :: nsC
DO I=1,6
nsC(I) = INT2(ns(I))
END DO
CALL designInternal(ny,nz,nx,nu,nsC,nt,theta,TRIM(mfile)//C_NULL_CHAR,c,H,G,a,F,R)
END SUBROUTINE DESIGN
#endif
#include <dynmex.h>
#include <algorithm>
#include <string.h>
using namespace std;
extern "C"
void designInternal(int ny, int nz, int nx, int nu, int ns[6], int nt,
double *theta, char *mfile,
double *c, double *H, double *G, double *a, double *F, double *R)
{
mxArray *lhs[6], *rhs[6];
nz = max(1, nz);
const mwSize dimsC[] = {(mwSize)ny, (mwSize)nz, (mwSize)ns[0]};
const mwSize dimsH[] = {(mwSize)ny, (mwSize)nx, (mwSize)ns[1]};
const mwSize dimsG[] = {(mwSize)ny, (mwSize)nu, (mwSize)ns[2]};
const mwSize dimsA[] = {(mwSize)nx, (mwSize)ns[3]};
const mwSize dimsF[] = {(mwSize)nx, (mwSize)nx, (mwSize)ns[4]};
const mwSize dimsR[] = {(mwSize)nx, (mwSize)nu, (mwSize)ns[5]};
lhs[0] = mxCreateNumericArray(3, dimsC, mxDOUBLE_CLASS, mxREAL);
lhs[1] = mxCreateNumericArray(3, dimsH, mxDOUBLE_CLASS, mxREAL);
lhs[2] = mxCreateNumericArray(3, dimsG, mxDOUBLE_CLASS, mxREAL);
lhs[3] = mxCreateNumericArray(2, dimsA, mxDOUBLE_CLASS, mxREAL);
lhs[4] = mxCreateNumericArray(3, dimsF, mxDOUBLE_CLASS, mxREAL);
lhs[5] = mxCreateNumericArray(3, dimsR, mxDOUBLE_CLASS, mxREAL);
rhs[0] = mxCreateDoubleScalar(ny);
rhs[1] = mxCreateDoubleScalar(nz);
rhs[2] = mxCreateDoubleScalar(nx);
rhs[3] = mxCreateDoubleScalar(nu);
rhs[4] = mxCreateDoubleMatrix(1, 6, mxREAL);
rhs[5] = mxCreateDoubleMatrix(1, nt, mxREAL);
double *passns = mxGetPr(rhs[4]);
for (int i = 0; i < 6; i++)
passns[i] = (double) ns[i];
memcpy(mxGetPr(rhs[5]), theta, sizeof(double) * nt);
mexCallMATLAB(6, lhs, 6, rhs, mfile);
memcpy(c, mxGetPr(lhs[0]), sizeof(double) * mxGetNumberOfElements(lhs[0]));
memcpy(H, mxGetPr(lhs[1]), sizeof(double) * mxGetNumberOfElements(lhs[1]));
memcpy(G, mxGetPr(lhs[2]), sizeof(double) * mxGetNumberOfElements(lhs[2]));
memcpy(a, mxGetPr(lhs[3]), sizeof(double) * mxGetNumberOfElements(lhs[3]));
memcpy(F, mxGetPr(lhs[4]), sizeof(double) * mxGetNumberOfElements(lhs[4]));
memcpy(R, mxGetPr(lhs[5]), sizeof(double) * mxGetNumberOfElements(lhs[5]));
for (int i=0; i<6; i++)
{
mxDestroyArray(lhs[i]);
mxDestroyArray(rhs[i]);
}
}