MATLAB R2009b compatibility fixes
— use XLS instead of XLSX in testsuite datafiles — use optimset instead of optimoptions — use quadv/quadl/quadgk instead of integral — fix race condition in load_m_file_data_legacy.m tests — use fallback implementation for intersect(…, 'stable')time-shift
parent
13c645e940
commit
98bdf76581
|
@ -205,7 +205,7 @@ end
|
|||
%$ density = @(x) exp(lpdfgweibull(x,shape,scale));
|
||||
%$
|
||||
%$ try
|
||||
%$ if isoctave
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s = quadl(density, .0000000001, 100000, 1e-10);
|
||||
%$ else
|
||||
%$ s = integral(density, 0, 100000);
|
||||
|
@ -228,7 +228,7 @@ end
|
|||
%$ density = @(x) exp(lpdfgweibull(x,shape,scale));
|
||||
%$
|
||||
%$ try
|
||||
%$ if isoctave
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s = quadl(density, .0000000001, 100000, 1e-10);
|
||||
%$ else
|
||||
%$ s = integral(density, 0, 100000);
|
||||
|
@ -251,7 +251,7 @@ end
|
|||
%$ density = @(x) exp(lpdfgweibull(x,shape,scale));
|
||||
%$
|
||||
%$ try
|
||||
%$ if isoctave
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s = quadl(density, .0000000001, 100000, 1e-10);
|
||||
%$ else
|
||||
%$ s = integral(density, 0, 100000);
|
||||
|
@ -262,7 +262,7 @@ end
|
|||
%$ end
|
||||
%$
|
||||
%$ if t(1)
|
||||
%$ if isoctave()
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ t(2) = abs(s-1)<5e-5;
|
||||
%$ else
|
||||
%$ t(2) = abs(s-1)<1e-6;
|
||||
|
@ -280,6 +280,8 @@ end
|
|||
%$ try
|
||||
%$ if isoctave
|
||||
%$ s = quadgk(xdens, .0000000001, 100000, 1e-10);
|
||||
%$ elseif matlab_ver_less_than('7.14')
|
||||
%$ s = quadgk(xdens, .0000000001, 100000, 'AbsTol', 1e-10);
|
||||
%$ else
|
||||
%$ s = integral(xdens, 0, 100000);
|
||||
%$ end
|
||||
|
@ -301,7 +303,7 @@ end
|
|||
%$ xdens = @(x) x.*exp(lpdfgweibull(x,shape,scale));
|
||||
%$
|
||||
%$ try
|
||||
%$ if isoctave
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s = quadl(xdens, .0000000001, 100000, 1e-10);
|
||||
%$ else
|
||||
%$ s = integral(xdens, 0, 100000);
|
||||
|
@ -324,7 +326,7 @@ end
|
|||
%$ xdens = @(x) x.*exp(lpdfgweibull(x,shape,scale));
|
||||
%$
|
||||
%$ try
|
||||
%$ if isoctave
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s = quadl(xdens, .0000000001, 100000, 1e-10);
|
||||
%$ else
|
||||
%$ s = integral(xdens, 0, 100000);
|
||||
|
@ -350,7 +352,7 @@ end
|
|||
%$ try
|
||||
%$ s = NaN(n, 1);
|
||||
%$ for i=1:n
|
||||
%$ if isoctave()
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s(i) = quadl(density, .0000000001, .1*i, 1e-10);
|
||||
%$ else
|
||||
%$ s(i) = integral(density, 0, .1*i);
|
||||
|
@ -381,7 +383,7 @@ end
|
|||
%$ try
|
||||
%$ s = NaN(n, 1);
|
||||
%$ for i=1:n
|
||||
%$ if isoctave()
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s(i) = quadl(density, .0000000001, .1*i, 1e-10);
|
||||
%$ else
|
||||
%$ s(i) = integral(density, 0, .1*i);
|
||||
|
@ -412,7 +414,7 @@ end
|
|||
%$ try
|
||||
%$ s = NaN(n, 1);
|
||||
%$ for i=1:n
|
||||
%$ if isoctave()
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s(i) = quadl(density, .0000000001, .1*i, 1e-10);
|
||||
%$ else
|
||||
%$ s(i) = integral(density, 0, .1*i);
|
||||
|
@ -427,7 +429,7 @@ end
|
|||
%$ for i=1:n
|
||||
%$ x = .1*i;
|
||||
%$ q = 1-exp(-(x/scale)^shape);
|
||||
%$ if isoctave()
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ t(i+1) = abs(s(i)-q)<5e-5;
|
||||
%$ else
|
||||
%$ t(i+1) = abs(s(i)-q)<1e-6;
|
||||
|
@ -436,4 +438,4 @@ end
|
|||
%$ end
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:16
|
||||
%@eof:16
|
||||
|
|
|
@ -97,13 +97,14 @@ fclose(fid);
|
|||
% Define a set of variables to be loaded.
|
||||
listofvariablestobeloaded = {'b'; 'a'};
|
||||
% Test if we can load the data.
|
||||
exist('example1.m', 'file'); % To force the detection of the new file under old MATLAB
|
||||
try
|
||||
data = load_m_file_data_legacy('example1.m', listofvariablestobeloaded);
|
||||
delete('example1.m');
|
||||
t(1) = 1;
|
||||
catch
|
||||
t(1) = 0;
|
||||
end
|
||||
delete('example1.m');
|
||||
T = all(t);
|
||||
%@eof:1
|
||||
|
||||
|
@ -124,13 +125,14 @@ fclose(fid);
|
|||
% Define a set of variables to be loaded.
|
||||
listofvariablestobeloaded = {'e'; 'a'};
|
||||
% Test if we can load the data.
|
||||
exist('example2.m', 'file'); % To force the detection of the new file under old MATLAB
|
||||
try
|
||||
data = load_m_file_data_legacy('example2.m', listofvariablestobeloaded);
|
||||
delete('example2.m');
|
||||
t(1) = 0;
|
||||
catch
|
||||
t(1) = 1;
|
||||
end
|
||||
delete('example2.m');
|
||||
T = all(t);
|
||||
%@eof:2
|
||||
|
||||
|
@ -151,12 +153,13 @@ fclose(fid);
|
|||
% Define a set of variables to be loaded.
|
||||
listofvariablestobeloaded = {'c'; 'a'};
|
||||
% Test if we can load the data.
|
||||
exist('example3.m', 'file'); % To force the detection of the new file under old MATLAB
|
||||
try
|
||||
data = load_m_file_data_legacy('example3.m', listofvariablestobeloaded);
|
||||
delete('example3.m');
|
||||
t(1) = 1;
|
||||
catch
|
||||
t(1) = 0;
|
||||
end
|
||||
delete('example3.m');
|
||||
T = all(t);
|
||||
%@eof:3
|
||||
|
|
|
@ -147,7 +147,7 @@ t = exp(log(scale)+log(-log(1-proba))/shape);
|
|||
%$ if debug
|
||||
%$ [shape, scale, x(k-1)]
|
||||
%$ end
|
||||
%$ if isoctave
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ s = quadv(density, 0, x(k-1),1e-10);
|
||||
%$ else
|
||||
%$ s = integral(density, 0, x(k-1));
|
||||
|
@ -155,8 +155,8 @@ t = exp(log(scale)+log(-log(1-proba))/shape);
|
|||
%$ if debug
|
||||
%$ [s, abs(p-s)]
|
||||
%$ end
|
||||
%$ if isoctave
|
||||
%$ t(k) = abs(p-s)<1e-10;
|
||||
%$ if isoctave || matlab_ver_less_than('7.14')
|
||||
%$ t(k) = abs(p-s)<1e-9;
|
||||
%$ else
|
||||
%$ t(k) = abs(p-s)<1e-12;
|
||||
%$ end
|
||||
|
|
|
@ -21,10 +21,21 @@ end;
|
|||
verbatim;
|
||||
|
||||
bgp.write(M_);
|
||||
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
|
||||
if isoctave || matlab_ver_less_than('8.1')
|
||||
options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
|
||||
else
|
||||
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
|
||||
end
|
||||
if isoctave
|
||||
% Octave can't take a function handle of a function in a package
|
||||
% See https://savannah.gnu.org/bugs/index.php?46659
|
||||
fun = str2func('nk.bgpfun');
|
||||
else
|
||||
fun = @nk.bgpfun;
|
||||
end
|
||||
y = 1+(rand(3,1)-.5)*.5;
|
||||
g = 1+(rand(3,1)-.5)*.1;
|
||||
[y, fval, exitflag] = fsolve(@nk.bgpfun, [y;g], options);
|
||||
[y, fval, exitflag] = fsolve(fun, [y;g], options);
|
||||
assert(max(abs(y-1))<1e-9);
|
||||
|
||||
end;
|
||||
end;
|
||||
|
|
|
@ -16,10 +16,21 @@ end;
|
|||
verbatim;
|
||||
|
||||
bgp.write(M_);
|
||||
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
|
||||
if isoctave || matlab_ver_less_than('8.1')
|
||||
options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-6,'TolX',1e-6);
|
||||
else
|
||||
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
|
||||
end
|
||||
if isoctave
|
||||
% Octave can't take a function handle of a function in a package
|
||||
% See https://savannah.gnu.org/bugs/index.php?46659
|
||||
fun = str2func('ramsey.bgpfun');
|
||||
else
|
||||
fun = @ramsey.bgpfun;
|
||||
end
|
||||
y = 1+(rand(M_.endo_nbr,1)-.5)*.5;
|
||||
g = ones(M_.endo_nbr,1);% 1+(rand(M_.endo_nbr,1)-.5)*.1;
|
||||
[y, fval, exitflag] = fsolve(@ramsey.bgpfun, [y;g], options);
|
||||
[y, fval, exitflag] = fsolve(fun, [y;g], options);
|
||||
assert(max(abs(y(M_.endo_nbr+(1:M_.orig_endo_nbr))-1.02))<1e-6)
|
||||
|
||||
end;
|
||||
|
|
|
@ -45,13 +45,16 @@ verbatim;
|
|||
GY = NaN(MC,1);
|
||||
GK = NaN(MC,1);
|
||||
EG = NaN(MC,1);
|
||||
if isoctave
|
||||
if isoctave || matlab_ver_less_than('8.1')
|
||||
options = optimset('Display', 'off', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
|
||||
else
|
||||
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
|
||||
end
|
||||
if isoctave
|
||||
% Octave can't take a function handle of a function in a package
|
||||
% See https://savannah.gnu.org/bugs/index.php?46659
|
||||
fun = str2func('solow.bgpfun');
|
||||
else
|
||||
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
|
||||
fun = @solow.bgpfun;
|
||||
end
|
||||
for i=1:MC
|
||||
|
|
|
@ -76,7 +76,7 @@ for i=1:nvar
|
|||
SubsetOfVariables(i) = i_tmp;
|
||||
end
|
||||
|
||||
if isoctave
|
||||
if isoctave || matlab_ver_less_than('8.1')
|
||||
[observable_pos,index_observables,index_subset]=intersect_stable(SubsetOfVariables,options_.varobs_id);
|
||||
else
|
||||
[observable_pos,index_observables,index_subset]=intersect(SubsetOfVariables,options_.varobs_id,'stable');
|
||||
|
@ -114,7 +114,7 @@ if max(abs(sum(oo_.variance_decomposition,2)-100))>2
|
|||
error(['Variance decomposition at order ',num2str(options_.order),' does not work'])
|
||||
end
|
||||
|
||||
if isoctave
|
||||
if isoctave || matlab_ver_less_than('8.1')
|
||||
[observable_pos,index_observables,index_subset]=intersect_stable(SubsetOfVariables,options_.varobs_id);
|
||||
else
|
||||
[observable_pos,index_observables,index_subset]=intersect(SubsetOfVariables,options_.varobs_id,'stable');
|
||||
|
|
|
@ -20,4 +20,4 @@ end;
|
|||
|
||||
varobs dx dy;
|
||||
check;
|
||||
estimation(datafile='test.xlsx',nobs=1000,mh_replic=2000,mh_jscale=1.3);
|
||||
estimation(datafile='test.xls',nobs=1000,mh_replic=2000,mh_jscale=1.3);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue