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
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • 6.x
  • asm
  • aux_func
  • clang+openmp
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dragonfly
  • dynare_minreal
  • eigen
  • error_msg_undeclared_model_vars
  • estim_params
  • exo_steady_state
  • gpm-optimal-policy
  • julia
  • madysson
  • master
  • mex-GetPowerDeriv
  • penalty
  • separateM_
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 6-beta1
  • 6-beta2
  • 6.0
  • 6.1
  • 6.2
  • 6.3
  • 6.4
91 results

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
  • ebenetce/dynare
  • chskcau/dynare-doc-fixes
28 results
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • aux_func
  • clang+openmp
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dynamic-striated
  • eigen
  • error_msg_undeclared_model_vars
  • estim_params
  • exceptions
  • exo_steady_state
  • filter_initial_state
  • gpm-optimal-policy
  • julia
  • local_state_space_iteration_k
  • master
  • mex-GetPowerDeriv
  • occbin
  • penalty
  • rmExtraExo
  • separateM_
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
63 results
Show changes
Showing
with 686 additions and 2528 deletions
// --+ options: json=compute, stochastic +--
var y x z v;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
pac_target_info(pacman);
target v;
auxname_target_nonstationary vns;
component y;
auxname pv_y_;
kind ll;
component x;
growth diff(x(-1));
auxname pv_dx_;
kind dd;
end;
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
[name='eq:x']
diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
[name='eq:v']
v = x + d_y*y ; // Composite target, no residuals here only variables defined in the auxiliary VAR model.
[name='zpac']
diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
end;
shocks;
var ex = .10;
var ey = .15;
var ez = .05;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
/*
**
** Simulate artificial dataset
**
*/
// Set initial conditions to zero.
initialconditions = dseries(zeros(10, M_.endo_nbr+M_.exo_nbr), 2000Q1, vertcat(M_.endo_names,M_.exo_names));
// Simulate the model for 5000 periods
TrueData = simul_backward_model(initialconditions, 5000);
/*
**
** Estimate PAC equation (using the artificial data)
**
*/
// Provide initial conditions for the estimated parameters
clear eparams
eparams.e_c_m = .9;
eparams.c_z_1 = .5;
eparams.c_z_2 = .2;
edata = TrueData; // Set the dataset used for estimation
edata.ez = dseries(NaN, 2000Q1); // Remove residuals for the PAC equation from the database.
pac.estimate.nls('zpac', eparams, edata, 2005Q1:2005Q1+4000, 'fmincon'); // Should produce a table with the estimates (close to the calibration given in lines 21-23)
......@@ -15,7 +15,7 @@
*/
/*
* Copyright (C) 2001-2010 Dynare Team
* Copyright © 2001-2010 Dynare Team
*
* This file is part of Dynare.
*
......@@ -30,7 +30,7 @@
* 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/>.
* along with Dynare. If not, see <https://www.gnu.org/licenses/>.
*/
......
/*
* This file presents a baseline RBC model with government spending shocks where the persistence of the
* government spending shock is estimated via impulse response function (IRF) matching.
*
* Notes:
* - The empirical IRFs were estimated using the Blanchard/Perotti (2002) approach, see
* https://github.com/JohannesPfeifer/DSGE_mod/blob/master/RBC_IRF_matching/get_empirical_IRFs.m
* - They are given in the csv file rbc_irf_matching_data.csv, the first two columns contain
* the empirical IRFs of G and Y, while the third and fourth column contain the corresponding
* variances of the IRFs from a bootstrap approach.
* Importantly: this mod file does not show how to get the empirical IRFs from a SVAR model,
* but takes these as "data".
* - Of course the RBC model is not capable of generating the consumption increase
* after a government spending shock. For that reason, this mod-file only targets the IRFs for G and Y.
* - The weighting matrix uses a diagonal matrix with the inverse of the pointwise IRF variances on the main diagonal.
* - The empirical IRFs and model IRFs use an impulse size of 1 percent. Thus, there is no uncertainty about the
* initial impact. The IRF matching therefore only targets the G-response starting in the second period.
* - Note that for the current model, the number of IRFs exceeds the number of VAR parameters. Therefore,
* the distribution of the estimator will be non-standard, see Guerron-Quintana/Inoue/Kilian (2016),
* http://dx.doi.org/10.1016/j.jeconom.2016.09.009
* - The mod-file also shows how to estimate an AR(2)-process by working with the roots of the autoregressive
* process instead of the coefficients. This allows for easily restricting the process to the stability region and
* would allow specifying e.g. a beta prior for both roots as was done in Born/Peter/Pfeifer (2013), Fiscal news
* and macroeconomic volatility, https://doi.org/10.1016/j.jedc.2013.06.011
*
* Please note that the following copyright notice only applies to this Dynare
* implementation of the model.
*/
/*
* Copyright (C) 2016-17 Johannes Pfeifer,
* Copyright (C) 2024 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 <https://www.gnu.org/licenses/>.
*/
%----------------------------------------------------------------
% define variables
%----------------------------------------------------------------
@#define IRF_periods=80
var y ${y}$ (long_name='output')
c ${c}$ (long_name='consumption')
k ${k}$ (long_name='capital')
l ${l}$ (long_name='hours')
z ${z}$ (long_name='TFP')
ghat ${\hat g}$ (long_name='government spending')
r ${r}$ (long_name='annualized interest rate')
w ${w}$ (long_name='real wage')
invest ${i}$ (long_name='investment')
log_y ${\log(y)}$ (long_name='log output')
log_k ${\log(k)}$ (long_name='log capital stock')
log_c ${\log(c)}$ (long_name='log consumption')
log_l ${\log(l)}$ (long_name='log labor')
log_w ${\log(w)}$ (long_name='log real wage')
log_invest ${\log(i)}$ (long_name='log investment')
;
varexo eps_z ${\varepsilon_z}$ (long_name='TFP shock')
eps_g ${\varepsilon_g}$ (long_name='government spending shock')
;
%----------------------------------------------------------------
% define parameters
%----------------------------------------------------------------
parameters
beta ${\beta}$ (long_name='discount factor')
psi ${\psi}$ (long_name='labor disutility parameter')
sigma ${\sigma}$ (long_name='risk aversion')
delta ${\delta}$ (long_name='depreciation rate')
alpha ${\alpha}$ (long_name='capital share')
rhoz ${\rho_z}$ (long_name='persistence TFP shock')
root_g_1 ${\rho_g}$ (long_name='first root of AR(2) G process')
root_g_2 ${\rho_g}$ (long_name='second root of AR(2) G process')
gammax ${\gamma_x}$ (long_name='composite growth rate')
gshare ${\frac{G}{Y}}$ (long_name='government spending share')
n ${n}$ (long_name='population growth')
x ${x}$ (long_name='technology growth (per capita output growth)')
i_y ${\frac{I}{Y}}$ (long_name='investment-output ratio')
k_y ${\frac{K}{Y}}$ (long_name='capital-output ratio')
g_ss ${\bar G}$ (long_name='government spending in steady state')
l_ss ${\bar L}$ (long_name='labor in steady state')
;
%----------------------------------------------------------------
% model equations
%----------------------------------------------------------------
model;
# rho_g_1= (root_g_1+root_g_2);
# rho_g_2= - root_g_1*root_g_2;
[name='Euler equation']
c^(-sigma)=beta/gammax*c(+1)^(-sigma)*
(alpha*exp(z(+1))*(k/l(+1))^(alpha-1)+(1-delta));
[name='Labor FOC']
psi*c^sigma*1/(1-l)=w;
[name='Law of motion capital']
gammax*k=(1-delta)*k(-1)+invest;
[name='resource constraint']
y=invest+c+g_ss*exp(ghat);
[name='production function']
y=exp(z)*k(-1)^alpha*l^(1-alpha);
[name='real wage/firm FOC labor']
w=(1-alpha)*y/l;
[name='annualized real interst rate/firm FOC capital']
r=4*alpha*y/k(-1);
[name='exogenous TFP process']
z=rhoz*z(-1)+eps_z;
[name='government spending process']
ghat=rho_g_1*ghat(-1)+rho_g_2*ghat(-2)+eps_g;
[name='Definition log output']
log_y = log(y);
[name='Definition log capital']
log_k = log(k);
[name='Definition log consumption']
log_c = log(c);
[name='Definition log hours']
log_l = log(l);
[name='Definition log wage']
log_w = log(w);
[name='Definition log investment']
log_invest = log(invest);
end;
%----------------------------------------------------------------
% set steady state values
%---------------------------------------------------------------
steady_state_model;
gammax = (1+n)*(1+x);
delta = i_y/k_y-x-n-n*x;
beta = (1+x)*(1+n)/(alpha/k_y+(1-delta));
l = l_ss;
k = ((1/beta*(1+n)*(1+x)-(1-delta))/alpha)^(1/(alpha-1))*l;
invest = (x+n+delta+n*x)*k;
y = k^alpha*l^(1-alpha);
g = gshare*y;
g_ss = g;
c = (1-gshare)*k^(alpha)*l^(1-alpha)-invest;
psi = (1-alpha)*(k/l)^alpha*(1-l)/c^sigma;
w = (1-alpha)*y/l;
r = 4*alpha*y/k;
log_y = log(y);
log_k = log(k);
log_c = log(c);
log_l = log(l);
log_w = log(w);
log_invest = log(invest);
z = 0;
ghat =0;
end;
%----------------------------------------------------------------
% calibration
%----------------------------------------------------------------
sigma = 1;
alpha = 0.33;
i_y = 0.25;
k_y = 10.4;
x = 0.0055;
n = 0.0027;
rhoz = 0.97;
root_g_1 = 0.9602;
root_g_2 = 0;
gshare = 0.2038;
l_ss = 1/3;
shocks;
var eps_g = 1;
end;
steady;
check;
varobs ghat log_y y; // you need to specify observables
%----------------------------------------------------------------
% IRF matching example 1:
% - different ways to MANUALLY enter values and weights
% - Maximum likelihood estimation
%----------------------------------------------------------------
estimated_params;
root_g_1 , 0.90 , 0, 1;
root_g_2 , 0.10 , 0, 1;
end;
xx = [1.007,1.117,1.092];
ww = [51,52];
matched_irfs;
var log_y ; varexo eps_g ; periods 1, 2 ; values 0.20, 0.17 ; weights 360, 140 ;
var ghat ; varexo eps_g ; periods 2 3:5 ; values 1.01, (xx) ; weights 50, 20 ;
var y ; varexo eps_g ; periods 10:11 ; values (log(1.05)) ; weights (ww) ;
end;
method_of_moments(mom_method = irf_matching, mode_compute = 5, additional_optimizer_steps=[4]);
%----------------------------------------------------------------
% IRF matching example 2
% - use all IRFs given in MATLAB objects
% - use Bayesian Slice sampler
%----------------------------------------------------------------
estimated_params(overwrite);
root_g_1 , 0.50 , 0, 1, beta_pdf , 0.50 , 0.20;
root_g_2 , 0.10 , 0, 1, beta_pdf , 0.50 , 0.20;
end;
% get data
irfs_data = importdata('rbc_irf_matching_data.csv');
irfs_ghat_eps_g = irfs_data.data(2:80,1); % start in t=2 due to identification restrictions in SVAR
irfs_log_y_eps_g = irfs_data.data(1:80,2);
weights_ghat_eps_g = 1./irfs_data.data(2:80,3);
weights_log_y_eps_g = 1./irfs_data.data(1:80,4);
matched_irfs(overwrite);
var ghat ; varexo eps_g; periods 2:80; values (irfs_ghat_eps_g); weights (weights_ghat_eps_g);
var log_y; varexo eps_g; periods 1:80; values (irfs_log_y_eps_g); weights (weights_log_y_eps_g);
end;
method_of_moments(mom_method = irf_matching
,order = 1
,mh_nblocks = 2, mh_replic = 50
,posterior_sampling_method = 'slice'
,plot_priors = 1
);
%----------------------------------------------------------------
% IRF matching example 3:
% - use anonymous function to access IRFs more flexibly
% - showcase how to use irf_matching_file
% - find posterior mode
%----------------------------------------------------------------
% get data
irfs_data = importdata('rbc_irf_matching_data.csv');
% use anonymous function (or MATLAB function) to have more flexibility, but inputs can only be numerical
% we also take 100 just for illustration that you can do any required transformation in an irf_matching_file
irfs_vals = @(j) 100.*(irfs_data.data(2:80,j));
irfs_weights = @(j) 1./(irfs_data.data(2:80,j));
matched_irfs(overwrite);
var ghat ; varexo eps_g; periods 2:80; values (irfs_vals(1)); weights (irfs_weights(3));
var log_y; varexo eps_g; periods 2:80; values (irfs_vals(2)); weights (irfs_weights(4));
end;
% we use the irf_matching_file to transform variable y to log(y) so the model
% variable aligns with the variable from the given empirical SVAR
method_of_moments(mom_method = irf_matching
,irf_matching_file = rbc_irf_matching_transformations
,mh_replic = 0,plot_priors = 0
);
\ No newline at end of file
G,Y,var_G,var_Y
1,0.208070478344545,1.12054105855257e-33,0.0027602236508546
1.01463693816715,0.166450236530301,0.00583152879723266,0.00679133276154495
1.00764238152471,0.230433660500946,0.0111184998994349,0.00952654639548326
1.11696510115769,0.215252336067127,0.0164663222282161,0.0113464752654877
1.09223998892147,0.222958847463141,0.0216966728235886,0.013533420700953
1.03736643322521,0.243972174559692,0.0257004687001329,0.0151053406229588
1.01711112212948,0.261016995864984,0.0303544421773506,0.0162405771811019
0.967577038730636,0.269060130173636,0.0339076793971577,0.0171352445593892
0.912649802559854,0.278584624341349,0.03620212016322,0.0179592573395723
0.867058516612021,0.283001682449059,0.038151205713992,0.0187783728830758
0.820597806619289,0.283598412003388,0.0396511019185971,0.0194594651103199
0.77563492323912,0.281760898055785,0.0403347277351183,0.0198713886600475
0.735846344956036,0.277110769410598,0.0407036832985301,0.0198800923047385
0.698850036380633,0.269931336693529,0.0407917065478011,0.0194569744071588
0.664596916513962,0.261143278620547,0.0405012612908696,0.0186271529903141
0.633528960929983,0.251064751428521,0.0400022455114944,0.0174559567202935
0.604912703413876,0.240132445806634,0.0393594337883548,0.0160603819816583
0.578360605178466,0.228823340604282,0.0385445703756185,0.0145721875285327
0.55371549942988,0.217458827167635,0.0376075435183867,0.0130962012473614
0.530621264922238,0.206298301306342,0.0365729915386994,0.0117094186557471
0.508813730835084,0.195562831928213,0.0354403165776896,0.010461528435305
0.488125279535286,0.185390333897221,0.0342268285355491,0.00937102041748079
0.468386758403429,0.175863201796663,0.0329491563166573,0.00843340667968603
0.449471041462416,0.167022878990409,0.0316223984500399,0.00763260719022832
0.431296406103216,0.158870322365946,0.0302644814355948,0.00694575471751527
0.413799596231625,0.151377829877172,0.0288934660918837,0.00634988691182681
0.396937751823371,0.144499570770831,0.0275270293690654,0.00582564616104379
0.380685985677042,0.13817717429653,0.0261806418593218,0.00535836547483349
0.365028340579903,0.132346351995696,0.0248665732796567,0.00493799567463183
0.349954881191496,0.126942318129237,0.0235951459469029,0.0045584177486503
0.335459383987806,0.121903145354258,0.022373467574597,0.00421578980579863
0.321536118675061,0.117172332783573,0.021205727363848,0.00390754150917342
0.308178316488601,0.112700463782387,0.0200943664605458,0.00363147379277453
0.295377351869768,0.108445858384018,0.019040123479836,0.00338513596160304
0.283122066100135,0.104374632848495,0.0180423053448312,0.00316565728079348
0.271398650164465,0.100460305211796,0.0170995738403303,0.0029698495549103
0.260190863606074,0.0966830386847356,0.0162100638803249,0.00279435029276752
0.249480370591311,0.0930286987898092,0.0153715252985084,0.00263589300567087
0.239247213436084,0.0894878338463341,0.0145815957210218,0.002491545439791
0.229470346306504,0.0860546497623421,0.0138378615720872,0.00235884935269597
0.220128148976686,0.0827260491927552,0.0131378639605267,0.00223588384965084
0.211198902955524,0.0795007779016462,0.0124791808709379,0.00212125323555392
0.20266120682353,0.0763786992809964,0.0118594333328108,0.0020139945677632
0.194494311443246,0.0733602078340912,0.0112762767066973,0.00191345670528973
0.186678374172779,0.0704457804639186,0.0107274179119509,0.0018191767154505
0.179194635081175,0.0676356552603192,0.0102106211287206,0.00173077210770515
0.172025520775263,0.064929622999291,0.00972370794405955,0.0016478667536602
0.165154686254735,0.0623269135604257,0.00926457432688479,0.00157005669764952
0.158567006362608,0.0598261581740075,0.00883120737460965,0.00149690646906453
0.152248528236286,0.0574254089705774,0.00842170119327602,0.00142796690804853
0.146186396016794,0.0551221987689224,0.00803427530290723,0.0013628024472437
0.140368757967879,0.0529136261066764,0.00766728912012237,0.00130101642649392
0.134784664597338,0.0507964530245216,0.00731924890008266,0.00124226770384004
0.129423964825334,0.0487672057100314,0.00698880917814805,0.00118627695274624
0.124277205618631,0.046822270602385,0.00667476765058639,0.00113282353216918
0.119335538941298,0.0449579808540134,0.0063760543634253,0.0010817364372413
0.11459063850232,0.0431706900378893,0.00609171803409054,0.00103288330782315
0.110034627608638,0.0414568316344016,0.00582091131964085,0.000986160390158817
0.105660018476945,0.0398129641266707,0.00556287623442419,0.000941484872060258
0.101459662633845,0.0382358024894679,0.00531693108962639,0.000898789756847698
0.0974267115198392,0.0367222375053657,0.00508245926485931,0.000858020371449084
0.0935545860830807,0.0352693447261226,0.00485889955647229,0.000819131356725285
0.0898369539782651,0.0338743850644921,0.00464573784815541,0.00078208329876107
0.0862677129419094,0.0325347989994978,0.00444249975285543,0.000746838714885712
0.0828409789666302,0.0312481962526895,0.00424874389794858,0.000713357679487274
0.0795510780159448,0.0300123425850257,0.00406405581698042,0.000681593780987298
0.076392540182423,0.0288251451088667,0.00388804253930626,0.000651491166504331
0.0733600953745436,0.0276846372357925,0.00372032800246882,0.000622983230006533
0.070448669804769,0.0265889641106603,0.00356054943074244,0.000595993138422716
0.0676533827305797,0.0255363691313685,0.0034083547518209,0.00057043599416774
0.064969543062731,0.024525181932661,0.00326340099829315,0.00054622212266834
0.0623926455954874,0.0235538080267355,0.00312535355830137,0.000523260827093126
0.0599183667294525,0.0226207201454146,0.00299388608378455,0.000501463968548093
0.0575425596484649,0.0217244512173301,0.00286868083997892,0.000480748874949654
0.055261248979131,0.0208635888360229,0.00274942930127684,0.000461040295246497
0.0530706250072852,0.0200367710268393,0.00263583284298659,0.000442271333040507
0.0509670375530574,0.0192426830970757,0.00252760342283966,0.000424383467067322
0.0489469896186406,0.0184800553498327,0.00242446418777184,0.000407325873359123
0.0470071309236527,0.0177476614525368,0.0023261499716701,0.000391054302991331
0.0451442514353558,0.0170443172715253,0.00223240766511842,0.000375529754828271
function [modelIrf, error_indicator] = rbc_irf_matching_transformations(modelIrf, M_, options_mom_, ys_)
% -------------------------------------------------------------------------
% This file manipulates model IRFs to be consistent with empirical IRFS
% -------------------------------------------------------------------------
% INPUTS
% - modelIrf: [options_mom_.irf by M_.endo_nbr by M_.exo_nbr]
% array of IRFs for all model variables and all shocks
% - M_: [structure] Dynare model structure
% - options_mom_: [structure] Dynare options structure
% - ys_: [double] steady state values of all endogenous variables
% -------------------------------------------------------------------------
% OUTPUTS
% - modelIrf: [options_mom_.irf by M_.endo_nbr by M_.exo_nbr]
% modified array of IRFs for all model variables and all shocks
% - error_indicator: [boolean] indicator of success (0) or failure (1)
% -------------------------------------------------------------------------
% This function is called by
% - mom.run
% -------------------------------------------------------------------------
% Copyright © 2024 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 <https://www.gnu.org/licenses/>.
% initialize error indicator
error_indicator = 0;
% get indices of variables
idx_ghat = find(ismember(M_.endo_names,'ghat'));
idx_log_y = find(ismember(M_.endo_names,'log_y'));
idx_eps_g = find(ismember(M_.exo_names,'eps_g'));
% manipulate the model IRFs to match the empirical IRFs (e.g. cumsum, common scaling, trends, ratios, etc.)
modelIrf(:,idx_ghat,idx_eps_g) = 100.*modelIrf(:,idx_ghat,idx_eps_g);
modelIrf(:,idx_log_y,idx_eps_g) = 100.*modelIrf(:,idx_log_y,idx_eps_g);
end
\ No newline at end of file
module Dynare
##
# Copyright © 2015-2016 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/>.
##
export @compile, @dynare
function compile(modfile)
# Add cd to path if not already there
if isempty(findin([pwd()], LOAD_PATH))
unshift!(LOAD_PATH, pwd())
end
# Process modfile
println(string("Using ", Sys.WORD_SIZE, "-bit preprocessor"))
preprocessor = string(dirname(@__FILE__()), "/preprocessor", Sys.WORD_SIZE, "/dynare_m")
run(`$preprocessor $modfile language=julia output=dynamic`)
end
macro dynare(modfiles...)
ex = Expr(:toplevel)
if length(modfiles)>1
for modfile in modfiles
eval(:(compile($modfile)))
basename = split(modfile, ".mod"; keep=false)
push!(ex.args, Expr(:import, Symbol(basename[1])))
end
else
eval(:(compile($modfiles)))
basename = split(modfiles[1], ".mod"; keep=false)
push!(ex.args, Expr(:importall, Symbol(basename[1])))
end
return ex
end
macro compile(modfiles...)
for modfile in modfiles
eval(:(compile($modfile)))
end
end
end
module DynareModel
##
# Copyright © 2015-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/>.
##
export Model, Endo, Exo, ExoDet, Param, dynare_model
abstract type Atom end
immutable Endo <: Atom
name::String
tex_name::String
long_name::String
end
immutable Exo <: Atom
name::String
tex_name::String
long_name::String
end
immutable ExoDet <: Atom
name::String
tex_name::String
long_name::String
end
immutable Param <: Atom
name::String
tex_name::String
long_name::String
end
immutable AuxVars
endo_index::Int
var_type::Int
orig_index::Int
orig_lead_lag::Int
eq_nbr::Int
orig_expr::String
end
immutable PredVars
index::Int
end
immutable ObsVars
index::Int
end
immutable DetShocks
exo_det::Int
exo_id::Int
multiplicative::Bool
periods::Vector{Int}
value::Float64
end
immutable EquationTag
eq_nbr::Int
name::String
value::String
end
type Model
fname::String
dname::String
dynare_version::String
endo::Vector{Endo}
exo::Vector{Exo}
exo_det::Vector{ExoDet}
param::Vector{Param}
aux_vars::Vector{AuxVars}
pred_vars::Vector{Int}
obs_vars::Vector{Int}
state_var::Vector{Int}
orig_endo_nbr::Int
orig_eq_nbr::Int
eq_nbr::Int
ramsey_eq_nbr::Int
det_shocks::Vector{DetShocks}
nstatic::Int
nfwrd::Int
npred::Int
nboth::Int
nsfwrd::Int
nspred::Int
ndynamic::Int
maximum_lag::Int
maximum_lead::Int
maximum_endo_lag::Int
maximum_endo_lead::Int
maximum_exo_lag::Int
maximum_exo_lead::Int
orig_maximum_lag::Int
orig_maximum_lead::Int
orig_maximum_endo_lag::Int
orig_maximum_endo_lead::Int
orig_maximum_exo_lag::Int
orig_maximum_exo_lead::Int
orig_maximum_exo_det_lag::Int
orig_maximum_exo_det_lead::Int
lead_lag_incidence::Matrix{Int}
nnzderivatives::Vector{Int}
analytical_steady_state::Bool
user_written_analytical_steady_state::Bool
static_and_dynamic_models_differ::Bool
equation_tags::Vector{String}
exo_names_orig_ord::Vector{Int}
sigma_e::Matrix{Float64}
correlation_matrix::Matrix{Float64}
h::Matrix{Float64}
correlation_matrix_me::Matrix{Float64}
sigma_e_is_diagonal::Bool
params::Vector{Float64}
static::Function
static_params_derivs::Function
dynamic::Function
dynamic_params_derivs::Function
steady_state::Function
end
function dynare_model()
return Model("", # fname
"", # dname
"", # dynare_version
Vector{Endo}(), # endo
Vector{Exo}(), # exo
Vector{ExoDet}(), # exo_det
Vector{Param}(), # param
Vector{AuxVars}(), # aux_vars
Vector{Int}(), # pred_vars
Vector{Int}(), # obs_vars
Vector{Int}(), # state_var
0, # orig_endo_nbr
0, # orig_eq_nbr
0, # eq_nbr
0, # ramsey_eq_nbr
Vector{DetShocks}(), # det_shocks
0, # nstatic
0, # nfwrd
0, # npred
0, # nboth
0, # nsfwrd
0, # nspred
0, # ndynamic
0, # maximum_lag
0, # maximum_lead
0, # maximum_endo_lag
0, # maximum_endo_lead
0, # maximum_exo_lag
0, # maximum_exo_lead
0, # orig_maximum_lag
0, # orig_maximum_lead
0, # orig_maximum_endo_lag
0, # orig_maximum_endo_lead
0, # orig_maximum_exo_lag
0, # orig_maximum_exo_lead
0, # orig_maximum_exo_det_lag
0, # orig_maximum_exo_det_lead
Matrix{Int}(0,0), # lead_lag_incidence
zeros(Int64,3), # nnzderivatives
false, # analytical_steady_state
false, # user_written_analytical_steady_state
false, # static_and_dynamic_models_differ
Vector{String}(), # equation_tags
Vector{Int}(), # exo_names_orig_ord
Matrix{Float64}(0,0), # sigma_e (Cov matrix of the structural innovations)
Matrix{Float64}(0,0), # correlation_matrix (Corr matrix of the structural innovations)
Matrix{Float64}(0,0), # h (Cov matrix of the measurement errors)
Matrix{Float64}(0,0), # correlation_matrix_me (Cov matrix of the measurement errors)
true, # sigma_e_is_diagonal
Vector{Float64}(), # params
function()end, # static
function()end, # static_params_derivs
function()end, # dynamic
function()end, # dynamic_params_derivs
function()end # steady_state
)
end
end
module DynareOptions
##
# Copyright © 2015 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/>.
##
export Options, dynare_options
type PFMSolver
maxit::Int
periods::Int
tolx::Float64
tolf::Float64
end
function pfmsolver_set_defaults()
return PFMSolver(500, # maxit (Maximum number of iterations in Newton algorithm)
400, # periods (Number of periods to return to the steady state)
1e-6, # tolx (Tolerance criterion on the paths for the endogenous variables)
1e-6 # tolf (Tolerance criterion on the stacked non linear equations)
)
end
type Options
dynare_version::String
linear::Bool
pfmsolver::PFMSolver
end
function dynare_options()
return Options("", # dynare_version
false, # linear
pfmsolver_set_defaults() # pfmsolver
)
end
end
module DynareOutput
##
# Copyright © 2015-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/>.
##
export Ouput, dynare_output
type Output
dynare_version::String
steady_state::Vector{Float64}
exo_steady_state::Vector{Float64}
end
function dynare_output()
return Output("", # dynare_version
Vector{Float64}(), # steady_state
Vector{Float64}() # exo_steady_state
)
end
end
module PerfectForesightModelSolver
##
# Copyright © 2016 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/>.
##
import DynareModel.Model
import DynareOutput.Output
import DynareOptions.Options
export simulate_perfect_foresight_model!
function simulate_perfect_foresight_model!(endogenousvariables::Matrix{Float64}, exogenousvariables::Matrix{Float64}, steadystate::Vector{Float64}, model::Model, options::Options)
lead_lag_incidence = model.lead_lag_incidence
nyp = countnz(lead_lag_incidence[1,:])
ny0 = countnz(lead_lag_incidence[2,:])
nyf = countnz(lead_lag_incidence[3,:])
ny = length(model.endo)
nd = nyp+ny0+nyf
periods = options.pfmsolver.periods
params = model.params
tmp = lead_lag_incidence[2:3,:]'
i_cols_A1 = find(tmp)
i_cols_1 = tmp[i_cols_A1]
tmp = lead_lag_incidence[1:2,:]'
i_cols_AT = find(tmp)
i_cols_T = tmp[i_cols_AT]
tmp = lead_lag_incidence[2,:]'
i_cols_A0 = find(tmp)
i_cols_0 = tmp[i_cols_A0]
i_cols_j = collect(1:nd)
i_upd = ny+collect(1:periods*ny)
Y = vec(endogenousvariables)
z = Y[find(lead_lag_incidence')]
jacobian = zeros(Float64, ny, length(z)+length(model.exo))
residuals = zeros(Float64, ny)
println("\nMODEL SIMULATION:\n")
rd = zeros(Float64, periods*ny)
iA = zeros(Int64, periods*model.nnzderivatives[1])
jA = zeros(Int64, periods*model.nnzderivatives[1])
vA = zeros(Float64, periods*model.nnzderivatives[1])
convergence = false
iteration = 0
while !convergence
iteration += 1
i_rows = collect(1:ny)
i_cols_A = find(lead_lag_incidence')
i_cols = i_cols_A
m = 0
for it = 2:(periods+1)
model.dynamic(Y[i_cols], exogenousvariables, params, steadystate, it, residuals, jacobian)
if it==(periods+1) & it==2
(r, c, v) = findnz(jacobian[:,i_cols_0])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A0[c]
vA[k] = v
elseif it==(periods+1)
(r, c, v) = findnz(jacobian[:,i_cols_T])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A[i_cols_T[c]]
vA[k] = v
elseif it==2
(r, c, v) = findnz(jacobian[:,i_cols_1])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A1[c]
vA[k] = v
else
(r, c, v) = findnz(jacobian[:,i_cols_j])
k = collect(1:length(v))+m
iA[k] = i_rows[r]
jA[k] = i_cols_A[c]
vA[k] = v
end
m += length(v)
rd[i_rows] = residuals
i_rows += ny
i_cols += ny
if it>2
i_cols_A += ny
end
end
err = maximum(abs.(rd))
println("Iter. ", iteration, "\t err. ", round(err, 12))
if err<options.pfmsolver.tolf
iteration -= 1
convergence = true
end
A = sparse(iA[1:m], jA[1:m], vA[1:m])
dy = -A\rd
Y[i_upd] += dy
if maximum(abs.(dy))<options.pfmsolver.tolx
convergence = true
end
end
if convergence
println("\nPFM solver converged in ", iteration, " iterations!\n")
endogenousvariables = reshape(Y, ny, periods+2)
end
end
end
module SteadyState
##
# Copyright © 2016 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/>.
##
using NLsolve
import DynareModel.Model
import DynareOutput.Output
export steady, steady!
export steady_state, steady_state!
function steady(model::Model, oo::Output)
if model.analytical_steady_state || model.user_written_analytical_steady_state
steadystate = zeros(length(model.endo))
model.steady_state(steadystate, oo.exo_steady_state, model.params)
return steadystate
else
error("You have to provide a closed form solution for the steady state, or declare a guess\nfor the steady state as a third input argument.")
end
end
function steady!(model::Model, oo::Output)
if model.analytical_steady_state || model.user_written_analytical_steady_state
model.steady_state(oo.steady_state, oo.exo_steady_state, model.params)
return
else
error("You have to provide a closed form solution for the steady state, or declare a guess\nfor the steady state as a third input argument.")
end
end
function steady(model::Model, oo::Output, yinit::Vector{Float64})
f!(fval::Vector{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval)
j!(fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fjac)
fj!(fval::Vector{Float64}, fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval, fjac)
r = nlsolve(f!, j!, fj!, yinit, show_trace=false)
if converged(r)
return r.zero
else
return fill(NaN, length(yinit))
end
end
function steady!(model::Model, oo::Output, yinit::Vector{Float64})
f!(fval::Vector{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval)
j!(fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fjac)
fj!(fval::Vector{Float64}, fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval, fjac)
r = nlsolve(f!, j!, fj!, yinit, show_trace=false)
if converged(r)
oo.steady_state = r.zero
else
oo.steady_state = fill(NaN, length(yinit))
end
end
function steady_state(model::Model, oo::Output)
ys = steady(model, oo)
display_steady_state(model, oo, ys)
end
function steady_state!(model::Model, oo::Output)
steady!(model, oo)
display_steady_state(model, oo, oo.steady_state)
end
function display_steady_state(model::Model, oo::Output, ys::Vector{Float64})
println("\n\nSTEADY STATE:\n")
for i = 1:length(model.endo)
println(string(model.endo[i].name, " = ", ys[i]))
end
end
function issteadystate(model::Model, oo::Output, ys::Vector{Float64})
residuals = zeros(Float64, length(ys))
compute_static_model_residuals!(model, oo, ys, residuals)
return maximum(abs(residuals))<1e-6
end
function compute_static_model_residuals!(model::Model, oo::Output, ys::Vector{Float64}, residuals::Vector{Float64})
model.static(ys, oo.exo_steady_state, model.params, residuals)
end
end
module Utils
##
# Copyright © 2015 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/>.
##
export get_power_deriv
function get_power_deriv(x::Float64, p::Real, k::Int)
if abs(x)<1e-12 && p>0 && k>p && typeof(p)==Int
dxp = .0
else
dxp = x^(p-k)
for i = 0:k-1
dxp *= p
p -= 1
end
end
return dxp
end
end
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Dynare
Upstream-Contact: Dynare Team, whose members in 2019 are:
Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
Houtan Bastani <houtan@dynare.org>
Michel Juillard <michel.juillard@mjui.fr>
Frédéric Karamé <frederic.karame@univ-lemans.fr>
Junior Maih <junior.maih@gmail.com>
Ferhat Mihoubi <fmihoubi@univ-evry.fr>
Willi Mutschler <willi@mutschler.eu>
Johannes Pfeifer <jpfeifer@gmx.de>
Marco Ratto <marco.ratto@ec.europa.eu>
Sébastien Villemot <sebastien@dynare.org>
Upstream-Contact: Dynare Team, whose members in 2025 are:
- Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
- Michel Juillard <michel.juillard@mjui.fr>
- Frédéric Karamé <frederic.karame@univ-lemans.fr>
- Junior Maih <junior.maih@gmail.com>
- Willi Mutschler <willi@mutschler.eu>
- Johannes Pfeifer <jpfeifer@gmx.de>
- Marco Ratto <marco.ratto@ec.europa.eu>
- Normann Rion <normann@dynare.org>
- Sébastien Villemot <sebastien@dynare.org>
Former Dynare Team members include:
- Houtan Bastani
- Abdeljabar Benzougar
- Alejandro Buesa
- Fabrice Collard
- Assia Ezzeroug
- Dóra Kocsis
- Stéphane Lhuissier
- Ferhat Mihoubi
- George Perendia
Source: https://www.dynare.org
Files: *
Copyright: 1996-2019 Dynare Team
Copyright: 1996-2025 Dynare Team
License: GPL-3+
Files: matlab/AIM/SP*
Files: matlab/+occbin/IVF_core.m
matlab/+occbin/match_function.m
Copyright: none
License: public-domain-inversion-filter
Original authors: Pablo Cuba-Borda, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong
Original file downloaded from:
http://www.lguerrieri.com/jae-replication.zip
Adapted for Dynare by Dynare Team.
.
This code is in the public domain and may be used freely.
However the authors would appreciate acknowledgement of the source by
citation of any of the following papers:
.
Pablo Cuba-Borda, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong (2019): "Likelihood evaluation of models
with occasionally binding constraints", Journal of Applied Econometrics, 34(7), 1073-1085
Files: matlab/+occbin/make_chart.m
matlab/+occbin/map_regime.m
matlab/+occbin/mkdata.m
matlab/+occbin/mkdatap_anticipated_2constraints_dyn.m
matlab/+occbin/mkdatap_anticipated_dyn.m
matlab/+occbin/solve_one_constraint.m
matlab/+occbin/solve_two_constraints.m
Copyright: none
License: public-domain-occbin
Original authors: Luca Guerrieri and Matteo Iacoviello
Original file downloaded from:
https://www.matteoiacoviello.com/research_files/occbin_20140630.zip
Adapted for Dynare by Dynare Team.
.
This code is in the public domain and may be used freely.
However the authors would appreciate acknowledgement of the source by
citation of any of the following papers:
.
Luca Guerrieri and Matteo Iacoviello (2015): "OccBin: A toolkit for solving
dynamic models with occasionally binding constraints easily"
Journal of Monetary Economics 70, 22-38
Files: matlab/AIM/*
Copyright: none
License: public-domain-aim
This code is in the public domain and may be used freely.
......@@ -39,113 +86,125 @@ License: public-domain-aim
Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
pages 472-489
Files: matlab/optimization/bfgsi1.m matlab/csolve.m matlab/optimization/csminit1.m matlab/optimization/numgrad2.m
Files: matlab/optimization/bfgsi1.m matlab/optimization/csolve.m matlab/optimization/csminit1.m matlab/optimization/numgrad2.m
matlab/optimization/numgrad3.m matlab/optimization/numgrad3_.m matlab/optimization/numgrad5.m
matlab/optimization/numgrad5_.m matlab/optimization/csminwel1.m matlab/bvar_density.m
matlab/bvar_toolbox.m matlab/partial_information/PI_gensys.m matlab/partial_information/qzswitch.m
matlab/partial_information/qzdiv.m
matlab/optimization/numgrad5_.m matlab/optimization/csminwel1.m matlab/+bvar/density.m
matlab/+bvar/toolbox.m matlab/partial_information/PI_gensys.m matlab/partial_information/PI_qzswitch.m
matlab/partial_information/PI_qzdiv.m
Copyright: 1993-2009 Christopher Sims
2006-2016 Dynare Team
2006-2024 Dynare Team
License: GPL-3+
Files: matlab/optimization/cmaes.m
Copyright: 2001-2012 Nikolaus Hansen
2012 Dynare Team
2012-2023 Dynare Team
License: GPL-3+
Files: matlab/optimization/solvopt.m
Copyright: 1997-2008 Alexei Kuntsevich and Franz Kappel
2008-2015 Giovanni Lombardo
2015 Dynare Team
2015-2017 Dynare Team
License: GPL-3+
Files: matlab/optimization/simulated_annealing.m
Copyright: 1995 E.G.Tsionas
1995-2002 Thomas Werner
2002-2015 Giovanni Lombardo
2015 Dynare Team
2015-2017 Dynare Team
License: GPL-3+
Files: matlab/endogenous_prior.m
Files: matlab/estimation/endogenous_prior.m
Copyright: 2011 Lawrence J. Christiano, Mathias Trabandt and Karl Walentin
2013 Dynare Team
2013-2017 Dynare Team
License: GPL-3+
Files: matlab/trust_region.m
Copyright: 2008-2012 VZLU Prague, a.s.
2014-2016 Dynare Team
License: GPL-3+
Files: matlab/estimation/smc/logsumexp.m
Copyright: 2020 Nicholas J. Higham
License: BSD-2-clause
Files: matlab/one_sided_hp_filter.m
Copyright: 2010-2015 Alexander Meyer-Gohde
2015 Dynare Team
2015-2017 Dynare Team
License: GPL-3+
Files: matlab/collapse_figures_in_tabgroup.m
Copyright: 2023 Eduard Benet Cerda
2024 Dynare Team
License: GPL-3+
Files: matlab/convergence_diagnostics/raftery_lewis.m
Copyright: 2016 Benjamin Born and Johannes Pfeifer
2016 Dynare Team
2016-2017 Dynare Team
License: GPL-3+
Files: matlab/commutation.m matlab/duplication.m
Files: matlab/+pruned_SS/commutation.m matlab/+pruned_SS/duplication.m
Copyright: 1997 Tom Minka <minka@microsoft.com>
2019 Dynare Team
2019-2020 Dynare Team
License: GPL-3+
Files: matlab/+pruned_SS/allVL1.m
Copyright: 2007-2010 Bruno Luong <brunoluong@yahoo.com>
2020 Dynare Team
License: GPL-3+
Comment: The original author gave authorization to change
the license from BSD-2-clause to GPL-3+ and redistribute
it under GPL-3+ with Dynare.
Files: matlab/+pruned_SS/uperm.m
Copyright: 2014 Bruno Luong <brunoluong@yahoo.com>
2020 Dynare Team
License: GPL-3+
Comment: The original author gave authorization to change
the license from BSD-2-clause to GPL-3+ and redistribute
it under GPL-3+ with Dynare.
Files: matlab/gsa/Morris_Measure_Groups.m
matlab/gsa/Sampling_Function_2.m
Files: matlab/+pruned_SS/prodmom.m matlab/+pruned_SS/bivmom.m
Copyright: 2008-2015 Raymond Kan <kan@chass.utoronto.ca>
2019-2023 Dynare Team
License: GPL-3+
Comment: The author gave authorization to redistribute
these functions under GPL-3+ with Dynare and would
appreciate acknowledgement of the source by citation
of the following paper:
Kan, R.: "From moments of sum to moments of product."
Journal of Multivariate Analysis, 2008, vol. 99, issue 3,
pages 542-554.
Files: matlab/+gsa/Morris_Measure_Groups.m
matlab/+gsa/Sampling_Function_2.m
Copyright: 2005 European Commission
2012 Dynare Team
2012-2023 Dynare Team
License: GPL-3+
Comment: Written by Jessica Cariboni and Francesca Campolongo
Joint Research Centre, The European Commission,
Files: matlab/gsa/cumplot.m
matlab/gsa/filt_mc_.m
matlab/gsa/gsa_plotmatrix.m
matlab/gsa/gsa_skewness.m
matlab/gsa/gsa_speed.m
matlab/gsa/log_trans_.m
matlab/gsa/map_calibration.m
matlab/gsa/map_ident_.m
matlab/gsa/mcf_analysis.m
matlab/gsa/myboxplot.m
matlab/gsa/myprctilecol.m
matlab/gsa/prior_draw_gsa.m
matlab/gsa/read_data.m
matlab/gsa/redform_map.m
matlab/gsa/redform_screen.m
matlab/gsa/scatter_mcf.m
matlab/gsa/smirnov.m
matlab/gsa/stab_map_.m
matlab/gsa/stab_map_1.m
matlab/gsa/stab_map_2.m
matlab/gsa/stand_.m
matlab/gsa/tcrit.m
matlab/gsa/teff.m
matlab/gsa/trank.m
Files: matlab/+gsa/cumplot.m
matlab/+gsa/monte_carlo_filtering.m
matlab/+gsa/skewness.m
matlab/+gsa/log_transform.m
matlab/+gsa/map_calibration.m
matlab/+gsa/map_identification.m
matlab/+gsa/monte_carlo_filtering_analysis.m
matlab/+gsa/boxplot.m
matlab/+gsa/prior_draw.m
matlab/+gsa/reduced_form_mapping.m
matlab/+gsa/reduced_form_screening.m
matlab/+gsa/scatter_mcf.m
matlab/+gsa/smirnov_test.m
matlab/+gsa/stability_mapping.m
matlab/+gsa/stability_mapping_univariate.m
matlab/+gsa/stability_mapping_bivariate.m
matlab/+gsa/standardize_columns.m
matlab/+gsa/tcrit.m
matlab/+gsa/teff.m
Copyright: 2011-2018 European Commission
2011-2018 Dynare Team
2011-2023 Dynare Team
License: GPL-3+
Files: matlab/gsa/pick.m
Copyright: none
License: public-domain-jrc
This software has been developed at the Joint Research Centre of European Commission
by officers in the course of their official duties. This software is not subject to copyright
protection and is in the public domain. It is an experimental system. The Joint Research Centre
of European Commission assumes no responsibility whatsoever for its use by other parties
and makes no guarantees, expressed or implied, about its quality, reliability, or any other
characteristic. We would appreciate acknowledgement if the software is used.
Comment: This file is part of GLUEWIN.
The program has been developed by M. Ratto, European Commission, Joint Research Centre,
Institute for the Protection and Security of The Citizen, Technological and Economic Risk Management,
Applied Statistics, as a deliverable of the IMPACT project
(EC Fifth Framework Programme, SCA Project, IST-1999-11313, DG-INFSO).
Files: matlab/optimization/simpsa.m matlab/optimization/simpsaget.m matlab/optimization/simpsaset.m
Copyright: 2005 Henning Schmidt, FCC, henning@fcc.chalmers.se
2006 Brecht Donckels, BIOMATH, brecht.donckels@ugent.be
2013-2016 Dynare Team
2013-2017 Dynare Team
License: GPL-3+
Files: matlab/missing/stats/normpdf.m matlab/missing/stats/gamcdf.m
......@@ -155,134 +214,98 @@ Files: matlab/missing/stats/normpdf.m matlab/missing/stats/gamcdf.m
matlab/missing/stats/betapdf.m matlab/missing/stats/normcdf.m
matlab/missing/stats/stdnormal_cdf.m matlab/missing/stats/norminv.m
matlab/missing/stats/stdnormal_pdf.m matlab/missing/stats/betainv.m
matlab/missing/stats-matlab/common_size.m
Copyright: 1995-2007 Kurt Hornik
2008-2011 Dynare Team
2008-2017 Dynare Team
License: GPL-3+
Files: matlab/missing/stats-matlab/quantile.m
Files: matlab/missing/stats/quantile.m
Copyright: 2014-2016 Christopher Hummersone
2016 Dynare Team
2016-2023 Dynare Team
License: GPL-3+
Files: matlab/missing/stats-matlab/corr.m
Files: matlab/missing/stats/corr.m
Copyright: 1993-1996 Kurt Hornik
1996-2015 John W. Eaton
2013-2015 Julien Bect
2016 Dynare Team
License: GPL-3+
Files: matlab/missing/strjoin/strjoin.m
Copyright: 2013-2019 Ben Abbott
2007 Muthiah Annamalai
2019 Dynare Team
License: GPL-3+
Files: matlab/missing/corrcoef/corrcoef.m matlab/missing/corrcoef/sumskipnan.m
matlab/missing/corrcoef/flag_implicit_skip_nan.m matlab/missing/corrcoef/tcdf.m
Copyright: 2000-2005,2008,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
2014 Dynare Team
2016-2023 Dynare Team
License: GPL-3+
Files: matlab/lmmcp/catstruct.m
Copyright: 2005 Jos van der Geest <jos@jasen.nl>
2013 Christophe Gouel
2016 Dynare Team
2016-2021 Dynare Team
License: BSD-2-clause
Files: matlab/lmmcp/lmmcp.m
Copyright: 2005 Christian Kanzow and Stefania Petra
2013 Christophe Gouel
2014 Dynare Team
2014-2017 Dynare Team
License: permissive-lmmcp
Unlimited permission is granted to everyone to use, copy, modify or
distribute this software.
Files: matlab/utilities/graphics/distinguishable_colors.m
Copyright: 2010-2011 Timothy E. Holy
2017 Dynare Team
License: BSD-2-clause
Files: matlab/utilities/graphics/colorspace.m
Copyright: 2005-2010 Pascal Getreuer
2017-2023 Dynare Team
License: BSD-2-clause
Files: doc/*.rst doc/*.tex doc/*.svg doc/*.pdf doc/*.bib
Copyright: 1996-2019 Dynare Team
License: GFDL-NIV-1.3+
Files: doc/macroprocessor/*
Copyright: 2008-2015 Dynare Team
Files: examples/fs2000_data.m tests/estimation/pct/fs2000_data.m
Copyright: 2000-2022 Frank Schorfheide
2023 Dynare Team
License: CC-BY-SA-4.0
Files: doc/preprocessor/*
Copyright: 2007-2019 Dynare Team
License: CC-BY-SA-4.0
Files: examples/usmodel_data.mat tests/estimation/pct/SW_2007_fmincon_parallel.m
Copyright: 2007-2013 Frank Smets and Raf Wouters
2013-24 Johannes Pfeifer
2025 Dynare Team
License: GPL-3+
Files: doc/*.rst doc/*.tex doc/*.svg doc/*.pdf doc/*.bib
Copyright: 1996-2025 Dynare Team
License: GFDL-NIV-1.3+
Files: doc/dr.tex doc/bvar_a_la_sims.tex
Files: doc/dr.tex doc/dr.bib
Copyright: 2007-2011 Sébastien Villemot
License: GFDL-NIV-1.3+
Files: dynare++/*
Files: doc/bvar-a-la-sims.tex
Copyright: 2007-2017 Sébastien Villemot
2016-2017 Johannes Pfeifer
License: GFDL-NIV-1.3+
Files: doc/sylvester.tex doc/tl.tex
Copyright: 2004-2011 Ondra Kamenik
2019 Dynare Team
License: GPL-3+
Files: m4/ax_blas.m4 m4/ax_lapack.m4
Copyright: 2008 Steven G. Johnson <stevenj@alum.mit.edu>
License: GPL-3+ with Autoconf exception
Files: m4/ax_boost_base.m4
Copyright: 2008 Thomas Porschberg <thomas@randspringer.de>
2009 Peter Adolphs
License: FSFAP
Files: m4/ax_compare_version.m4
Copyright: 2008 Tim Toolan <toolan@ele.uri.edu>
License: FSFAP
Files: m4/ax_cxx_compile_stdcxx.m4
m4/ax_cxx_compile_stdcxx_14.m4
Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
2012 Zack Weinberg <zackw@panix.com>
2013 Roy Stogner <roystgnr@ices.utexas.edu>
2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
2015 Paul Norman <penorman@mac.com>
2015 Moritz Klammler <moritz@klammler.eu>
2016 Krzesimir Nowak <qdlacz@gmail.com>
License: FSFAP
Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4
Copyright: 2008 Boretti Mathieu <boretti@eig.unige.ch>
2009 Dynare Team
License: LGPL-2.1+
Files: m4/ax_matlab_arch.m4 m4/ax_matlab.m4 m4/ax_mexext.m4
Copyright: 2002-2003 Ralph Schleicher
2009 Dynare Team
License: GPL-2+ with Autoconf exception
Files: scripts/dynare.el
Copyright: 2010 Yannick Kalantzis
2019 Dynare Team
2019-2025 Dynare Team
License: GPL-3+
Files: mex/sources/dynare_simul_/dynare_simul_.cc
mex/sources/gensylv/gensylv.cc
Copyright: 2005-2011 Ondra Kamenik
2019 Dynare Team
Files: mex/sources/gensylv/gensylv.cc
mex/sources/libkorder/kord/* mex/sources/libkorder/sylv/*
mex/sources/libkorder/tl/* mex/sources/libkorder/utils/*
Copyright: 2004-2011 Ondra Kamenik
2019-2025 Dynare Team
License: GPL-3+
Files: mex/sources/sobol/sobol.hh mex/sources/sobol/initialize_v_array.hh
mex/sources/sobol/initialize_v_array.inc
Copyright: 2009 John Burkardt
2010-2011 Dynare Team
Files: mex/sources/sobol/sobol.f08
Copyright: 2004-2009 John Burkardt
2023 Dynare Team
License: LGPL-3+
Files: contrib/jsonlab
Copyright: 2011-2017 Qianqian Fang <q.fang at neu.edu>
License: BSD or GPL-3+
Files: preprocessor/doc/macroprocessor/*
Copyright: 2008-2024 Dynare Team
License: CC-BY-SA-4.0
Files: preprocessor/doc/preprocessor/*
Copyright: 2007-2023 Dynare Team
License: CC-BY-SA-4.0
Files: contrib/ms-sbvar/utilities_dw/*
Copyright: 1996-2011 Daniel Waggoner
......@@ -367,32 +390,9 @@ Files: contrib/ms-sbvar/TZcode/MatlabFiles/qplot2.m
Copyright: 1997-2012 Clark A. Burdick
License: GPL-3+
Files: contrib/dmm/*
Copyright: 2010-2014 European Commission
2006-2012 Dynare Team
License: GPL-3+
Files: contrib/dmm/randlib/*
Copyright: none
License: public-domain-dmm
We place the Randlib code that we have written in the public domain.
.
NO WARRANTY
.
WE PROVIDE ABSOLUTELY NO WARRANTY OF ANY KIND EITHER EXPRESSED OR
IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD
THIS PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
SERVICING, REPAIR OR CORRECTION.
.
IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR ANY OF ITS COMPONENT
INSTITUTIONS INCLUDING M. D. ANDERSON HOSPITAL BE LIABLE TO YOU FOR
DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA OR
ITS ANALYSIS BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD
PARTIES) THE PROGRAM.
Files: matlab/+waitbar/multi.m
Copyright: 2007-2025 The MathWorks, Inc.
License: BSD-2-clause
License: BSD-2-clause
Redistribution and use in source and binary forms, with or without
......@@ -423,27 +423,7 @@ License: GFDL-NIV-1.3+
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
.
A copy of the license can be found at <http://www.gnu.org/licenses/fdl.txt>
License: GPL-2+ with Autoconf exception
This program 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 2,
or (at your option) any later version.
.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
.
As a special exception to the GNU General Public License, if
you distribute this file as part of a program that contains a
configuration script generated by GNU Autoconf, you may include
it under the same distribution terms that you use for the rest
of that program.
A copy of the license can be found at <https://www.gnu.org/licenses/fdl.txt>
License: GPL-3+
Dynare is free software: you can redistribute it and/or modify
......@@ -457,48 +437,7 @@ License: GPL-3+
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/>.
License: GPL-3+ with Autoconf exception
This program 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.
.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
.
As a special exception, the respective Autoconf Macro's copyright owner
gives unlimited permission to copy, distribute and modify the configure
scripts that are the output of Autoconf when processing the Macro. You
need not follow the terms of the GNU General Public License when using
or distributing such scripts, even though portions of the text of the
Macro appear in them. The GNU General Public License (GPL) does govern
all other use of the material that constitutes the Autoconf Macro.
.
This special exception to the GPL applies to versions of the Autoconf
Macro released by the Autoconf Archive. When you make and distribute a
modified version of the Autoconf Macro, you may extend this special
exception to the GPL to apply to your modified version as well.
License: LGPL-2.1+
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
.
This library 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 Lesser
General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
along with Dynare. If not, see <https://www.gnu.org/licenses/>.
License: LGPL-3+
This program is free software: you can redistribute it and/or modify
......@@ -512,7 +451,7 @@ License: LGPL-3+
GNU Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
License: CC-BY-SA-4.0
Attribution-ShareAlike 4.0 International
......@@ -940,9 +879,3 @@ License: CC-BY-SA-4.0
licenses.
.
Creative Commons may be contacted at creativecommons.org.
License: FSFAP
Copying and distribution of this file, with or without modification, are
permitted in any medium without royalty provided the copyright notice
and this notice are preserved. This file is offered as-is, without any
warranty.
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_blas.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro looks for a library that implements the BLAS linear-algebra
# interface (see http://www.netlib.org/blas/). On success, it sets the
# BLAS_LIBS output variable to hold the requisite library linkages.
#
# To link with BLAS, you should link with:
#
# $BLAS_LIBS $LIBS $FLIBS
#
# in that order. FLIBS is the output variable of the
# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is
# sometimes necessary in order to link with F77 libraries. Users will also
# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
# reason.
#
# Many libraries are searched for, from ATLAS to CXML to ESSL. The user
# may also use --with-blas=<lib> in order to use some specific BLAS
# library <lib>. In order to link successfully, however, be aware that you
# will probably need to use the same Fortran compiler (which can be set
# via the F77 env. var.) as was used to compile the BLAS library.
#
# ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
# not found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_BLAS.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
#
# This program 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.
#
# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 15
AU_ALIAS([ACX_BLAS], [AX_BLAS])
AC_DEFUN([AX_BLAS], [
AC_PREREQ(2.50)
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
AC_REQUIRE([AC_CANONICAL_HOST])
ax_blas_ok=no
AC_ARG_WITH(blas,
[AS_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])])
case $with_blas in
yes | "") ;;
no) ax_blas_ok=disable ;;
-* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;;
*) BLAS_LIBS="-l$with_blas" ;;
esac
# Get fortran linker names of BLAS functions to check for.
AC_F77_FUNC(sgemm)
AC_F77_FUNC(dgemm)
ax_blas_save_LIBS="$LIBS"
LIBS="$LIBS $FLIBS"
# First, check BLAS_LIBS environment variable
if test $ax_blas_ok = no; then
if test "x$BLAS_LIBS" != x; then
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes], [BLAS_LIBS=""])
AC_MSG_RESULT($ax_blas_ok)
LIBS="$save_LIBS"
fi
fi
# BLAS linked to by default? (happens on some supercomputers)
if test $ax_blas_ok = no; then
save_LIBS="$LIBS"; LIBS="$LIBS"
AC_MSG_CHECKING([if $sgemm is being linked in already])
AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes])
AC_MSG_RESULT($ax_blas_ok)
LIBS="$save_LIBS"
fi
# BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(openblas, $sgemm, [ax_blas_ok=yes
BLAS_LIBS="-lopenblas"])
fi
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(atlas, ATL_xerbla,
[AC_CHECK_LIB(f77blas, $sgemm,
[AC_CHECK_LIB(cblas, cblas_dgemm,
[ax_blas_ok=yes
BLAS_LIBS="-lcblas -lf77blas -latlas"],
[], [-lf77blas -latlas])],
[], [-latlas])])
fi
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(blas, $sgemm,
[AC_CHECK_LIB(dgemm, $dgemm,
[AC_CHECK_LIB(sgemm, $sgemm,
[ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
[], [-lblas])],
[], [-lblas])])
fi
# BLAS in Intel MKL library?
if test $ax_blas_ok = no; then
# MKL for gfortran
if test x"$ac_cv_fc_compiler_gnu" = xyes; then
# 64 bit
if test $host_cpu = x86_64; then
AC_CHECK_LIB(mkl_gf_lp64, $sgemm,
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],,
[-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread])
# 32 bit
elif test $host_cpu = i686; then
AC_CHECK_LIB(mkl_gf, $sgemm,
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],,
[-lmkl_gf -lmkl_sequential -lmkl_core -lpthread])
fi
# MKL for other compilers (Intel, PGI, ...?)
else
# 64-bit
if test $host_cpu = x86_64; then
AC_CHECK_LIB(mkl_intel_lp64, $sgemm,
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],,
[-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread])
# 32-bit
elif test $host_cpu = i686; then
AC_CHECK_LIB(mkl_intel, $sgemm,
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],,
[-lmkl_intel -lmkl_sequential -lmkl_core -lpthread])
fi
fi
fi
# Old versions of MKL
if test $ax_blas_ok = no; then
AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread])
fi
# BLAS in Apple vecLib library?
if test $ax_blas_ok = no; then
save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS"
AC_MSG_CHECKING([for $sgemm in -framework vecLib])
AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"])
AC_MSG_RESULT($ax_blas_ok)
LIBS="$save_LIBS"
fi
# BLAS in Alpha CXML library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"])
fi
# BLAS in Alpha DXML library? (now called CXML, see above)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"])
fi
# BLAS in Sun Performance library?
if test $ax_blas_ok = no; then
if test "x$GCC" != xyes; then # only works with Sun CC
AC_CHECK_LIB(sunmath, acosp,
[AC_CHECK_LIB(sunperf, $sgemm,
[BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
ax_blas_ok=yes],[],[-lsunmath])])
fi
fi
# BLAS in SCSL library? (SGI/Cray Scientific Library)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"])
fi
# BLAS in SGIMATH library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(complib.sgimath, $sgemm,
[ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
fi
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(blas, $sgemm,
[AC_CHECK_LIB(essl, $sgemm,
[ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
[], [-lblas $FLIBS])])
fi
# Generic BLAS library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"])
fi
AC_SUBST(BLAS_LIBS)
LIBS="$ax_blas_save_LIBS"
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_blas_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])
:
else
ax_blas_ok=no
$2
fi
])dnl AX_BLAS
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
#
# DESCRIPTION
#
# This macro compares two version strings. Due to the various number of
# minor-version numbers that can exist, and the fact that string
# comparisons are not compatible with numeric comparisons, this is not
# necessarily trivial to do in a autoconf script. This macro makes doing
# these comparisons easy.
#
# The six basic comparisons are available, as well as checking equality
# limited to a certain number of minor-version levels.
#
# The operator OP determines what type of comparison to do, and can be one
# of:
#
# eq - equal (test A == B)
# ne - not equal (test A != B)
# le - less than or equal (test A <= B)
# ge - greater than or equal (test A >= B)
# lt - less than (test A < B)
# gt - greater than (test A > B)
#
# Additionally, the eq and ne operator can have a number after it to limit
# the test to that number of minor versions.
#
# eq0 - equal up to the length of the shorter version
# ne0 - not equal up to the length of the shorter version
# eqN - equal up to N sub-version levels
# neN - not equal up to N sub-version levels
#
# When the condition is true, shell commands ACTION-IF-TRUE are run,
# otherwise shell commands ACTION-IF-FALSE are run. The environment
# variable 'ax_compare_version' is always set to either 'true' or 'false'
# as well.
#
# Examples:
#
# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
#
# would both be true.
#
# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
#
# would both be false.
#
# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
#
# would be true because it is only comparing two minor versions.
#
# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
#
# would be true because it is only comparing the lesser number of minor
# versions of the two values.
#
# Note: The characters that separate the version numbers do not matter. An
# empty string is the same as version 0. OP is evaluated by autoconf, not
# configure, so must be a string, not a variable.
#
# The author would like to acknowledge Guido Draheim whose advice about
# the m4_case and m4_ifvaln functions make this macro only include the
# portions necessary to perform the specific comparison specified by the
# OP argument in the final configure script.
#
# LICENSE
#
# Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 13
dnl #########################################################################
AC_DEFUN([AX_COMPARE_VERSION], [
AC_REQUIRE([AC_PROG_AWK])
# Used to indicate true or false condition
ax_compare_version=false
# Convert the two version strings to be compared into a format that
# allows a simple string comparison. The end result is that a version
# string of the form 1.12.5-r617 will be converted to the form
# 0001001200050617. In other words, each number is zero padded to four
# digits, and non digits are removed.
AS_VAR_PUSHDEF([A],[ax_compare_version_A])
A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/[[^0-9]]//g'`
AS_VAR_PUSHDEF([B],[ax_compare_version_B])
B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
-e 's/[[^0-9]]//g'`
dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
dnl # then the first line is used to determine if the condition is true.
dnl # The sed right after the echo is to remove any indented white space.
m4_case(m4_tolower($2),
[lt],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
],
[gt],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
],
[le],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
],
[ge],[
ax_compare_version=`echo "x$A
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
],[
dnl Split the operator from the subversion count if present.
m4_bmatch(m4_substr($2,2),
[0],[
# A count of zero means use the length of the shorter version.
# Determine the number of characters in A and B.
ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
# Set A to no more than B's length and B to no more than A's length.
A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
],
[[0-9]+],[
# A count greater than zero means use only that many subversions
A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
],
[.+],[
AC_WARNING(
[invalid OP numeric parameter: $2])
],[])
# Pad zeros at end of numbers to make same length.
ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
B="$B`echo $A | sed 's/./0/g'`"
A="$ax_compare_version_tmp_A"
# Check for equality or inequality as necessary.
m4_case(m4_tolower(m4_substr($2,0,2)),
[eq],[
test "x$A" = "x$B" && ax_compare_version=true
],
[ne],[
test "x$A" != "x$B" && ax_compare_version=true
],[
AC_WARNING([invalid OP parameter: $2])
])
])
AS_VAR_POPDEF([A])dnl
AS_VAR_POPDEF([B])dnl
dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
if test "$ax_compare_version" = "true" ; then
m4_ifvaln([$4],[$4],[:])dnl
m4_ifvaln([$5],[else $5])dnl
fi
]) dnl AX_COMPARE_VERSION
dnl Adds flags needed to compile programs using C++11 threads
dnl Copyright © 2019 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
dnl Dynare is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl Dynare is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
AC_DEFUN([AX_CXX11_THREAD],
[
AC_REQUIRE([AC_CANONICAL_BUILD])
case ${host_os} in
*mingw32*)
THREAD_CXXFLAGS="-mthreads $THREAD_CXXFLAGS"
;;
*)
THREAD_CXXFLAGS="-pthread $THREAD_CXXFLAGS"
;;
esac
AC_SUBST(THREAD_CXXFLAGS)
])
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
# or '14' (for the C++14 standard).
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
# required and that the macro should error out if no mode with that
# support is found. If specified 'optional', then configuration proceeds
# regardless, after defining HAVE_CXX${VERSION} if and only if a
# supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 7
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
AX_REQUIRE_DEFINED([AC_MSG_WARN])
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
[$2], [noext], [],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
ax_cv_cxx_compile_cxx$1,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[ax_cv_cxx_compile_cxx$1=yes],
[ax_cv_cxx_compile_cxx$1=no])])
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
ac_success=yes
fi
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
switch="-std=gnu++${alternative}"
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
fi])
m4_if([$2], [ext], [], [dnl
if test x$ac_success = xno; then
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
if test x$ac_success = xyes; then
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
fi
if test x$ac_success = xno; then
HAVE_CXX$1=0
AC_MSG_NOTICE([No compiler with C++$1 support was found])
else
HAVE_CXX$1=1
AC_DEFINE(HAVE_CXX$1,1,
[define if the compiler supports basic C++$1 syntax])
fi
AC_SUBST(HAVE_CXX$1)
m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])])
])
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual void f() {}
};
struct Derived : public Base
{
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_separators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])
dnl Tests for new features in C++17
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus <= 201402L
#error "This is not a C++17 compiler"
#else
#if defined(__clang__)
#define REALLY_CLANG
#else
#if defined(__GNUC__)
#define REALLY_GCC
#endif
#endif
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
#if !defined(REALLY_CLANG)
namespace test_constexpr_lambdas
{
// TODO: test it with clang++ from git
constexpr int foo = [](){return 42;}();
}
#endif // !defined(REALLY_CLANG)
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
#if !defined(REALLY_CLANG)
namespace test_template_argument_deduction_for_class_templates
{
// TODO: test it with clang++ from git
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
#endif // !defined(REALLY_CLANG)
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
#if !defined(REALLY_CLANG)
namespace test_structured_bindings
{
// TODO: test it with clang++ from git
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
#endif // !defined(REALLY_CLANG)
#if !defined(REALLY_CLANG)
namespace test_exception_spec_type_system
{
// TODO: test it with clang++ from git
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
#endif // !defined(REALLY_CLANG)
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus <= 201402L
]])
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++14
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++14. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 5
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])])
dnl Detect GSL.
dnl We don't use the official M4 macro since it relies on the script gsl-config,
dnl which does not work when cross-compiling.
dnl
dnl Copyright © 2010-2012 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
dnl Dynare is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl Dynare is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
AC_DEFUN([AX_GSL],
[
AC_ARG_WITH(gsl, AC_HELP_STRING([--with-gsl=DIR], [prefix to GSL installation]),
gsl_prefix="$withval", gsl_prefix="")
has_gsl=yes
if test -n "$gsl_prefix"; then
GSL_CPPFLAGS="-I$withval/include"
GSL_LDFLAGS="-L$withval/lib"
else
GSL_CPPFLAGS=""
GSL_LDFLAGS=""
fi
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
ac_save_LIBS="$LIBS"
LIBS=""
CPPFLAGS="$CPPFLAGS $GSL_CPPFLAGS"
LDFLAGS="$LDFLAGS $GSL_LDFLAGS"
AC_LANG_PUSH(C)
AC_CHECK_HEADER([gsl/gsl_cdf.h], [], [has_gsl=no])
AC_LANG_POP(C)
AC_CHECK_LIB([m], [cos])
AC_CHECK_LIB([gslcblas], [cblas_dgemm], [LIBS="-lgslcblas $LIBS"], [has_gsl=no])
AC_CHECK_LIB([gsl], [gsl_cdf_ugaussian_P], [LIBS="-lgsl $LIBS"], [has_gsl=no])
if test "$has_gsl" = yes; then
GSL_LIBS="$LIBS"
else
GSL_LIBS=""
fi
CPPFLAGS="$ac_save_CPPFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
AC_SUBST(GSL_CPPFLAGS)
AC_SUBST(GSL_LDFLAGS)
AC_SUBST(GSL_LIBS)
])
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_lapack.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LAPACK([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro looks for a library that implements the LAPACK linear-algebra
# interface (see http://www.netlib.org/lapack/). On success, it sets the
# LAPACK_LIBS output variable to hold the requisite library linkages.
#
# To link with LAPACK, you should link with:
#
# $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS
#
# in that order. BLAS_LIBS is the output variable of the AX_BLAS macro,
# called automatically. FLIBS is the output variable of the
# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is
# sometimes necessary in order to link with F77 libraries. Users will also
# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
# reason.
#
# The user may also use --with-lapack=<lib> in order to use some specific
# LAPACK library <lib>. In order to link successfully, however, be aware
# that you will probably need to use the same Fortran compiler (which can
# be set via the F77 env. var.) as was used to compile the LAPACK and BLAS
# libraries.
#
# ACTION-IF-FOUND is a list of shell commands to run if a LAPACK library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_LAPACK.
#
# LICENSE
#
# Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
#
# This program 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.
#
# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 8
AU_ALIAS([ACX_LAPACK], [AX_LAPACK])
AC_DEFUN([AX_LAPACK], [
AC_REQUIRE([AX_BLAS])
ax_lapack_ok=no
AC_ARG_WITH(lapack,
[AS_HELP_STRING([--with-lapack=<lib>], [use LAPACK library <lib>])])
case $with_lapack in
yes | "") ;;
no) ax_lapack_ok=disable ;;
-* | */* | *.a | *.so | *.so.* | *.o) LAPACK_LIBS="$with_lapack" ;;
*) LAPACK_LIBS="-l$with_lapack" ;;
esac
# Get fortran linker name of LAPACK function to check for.
AC_F77_FUNC(cheev)
# We cannot use LAPACK if BLAS is not found
if test "x$ax_blas_ok" != xyes; then
ax_lapack_ok=noblas
LAPACK_LIBS=""
fi
# First, check LAPACK_LIBS environment variable
if test "x$LAPACK_LIBS" != x; then
save_LIBS="$LIBS"; LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
AC_MSG_CHECKING([for $cheev in $LAPACK_LIBS])
AC_TRY_LINK_FUNC($cheev, [ax_lapack_ok=yes], [LAPACK_LIBS=""])
AC_MSG_RESULT($ax_lapack_ok)
LIBS="$save_LIBS"
if test $ax_lapack_ok = no; then
LAPACK_LIBS=""
fi
fi
# LAPACK linked to by default? (is sometimes included in BLAS lib)
if test $ax_lapack_ok = no; then
save_LIBS="$LIBS"; LIBS="$LIBS $BLAS_LIBS $FLIBS"
AC_CHECK_FUNC($cheev, [ax_lapack_ok=yes])
LIBS="$save_LIBS"
fi
# Generic LAPACK library?
for lapack in lapack lapack_rs6k; do
if test $ax_lapack_ok = no; then
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
AC_CHECK_LIB($lapack, $cheev,
[ax_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS])
LIBS="$save_LIBS"
fi
done
AC_SUBST(LAPACK_LIBS)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_lapack_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_LAPACK,1,[Define if you have LAPACK library.]),[$1])
:
else
ax_lapack_ok=no
$2
fi
])dnl AX_LAPACK