Skip to content
Snippets Groups Projects
Verified Commit 56ed5bff authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Testsuite: remove useless debug mode from several .m tests

The output is always useful (and even needed in case of test failure).
parent 742a3101
No related branches found
No related tags found
No related merge requests found
debug = false;
source_dir = getenv('source_root'); source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']); addpath([source_dir filesep 'matlab']);
...@@ -7,10 +5,8 @@ dynare_config; ...@@ -7,10 +5,8 @@ dynare_config;
testFailed = 0; testFailed = 0;
if ~debug
skipline() skipline()
disp('*** TESTING: cyclereduction.m ***'); disp('*** TESTING: cyclereduction.m ***');
end
matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'cycle_reduction']; matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'cycle_reduction'];
addpath(matlab_cr_path); addpath(matlab_cr_path);
...@@ -37,16 +33,12 @@ try ...@@ -37,16 +33,12 @@ try
R = norm(C+B*X1+A*X1*X1,1); R = norm(C+B*X1+A*X1*X1,1);
if (R > cvg_tol) if (R > cvg_tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Matlab cycle_reduction solution is wrong') dprintf('Matlab cycle_reduction solution is wrong')
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Matlab cycle_reduction failed') dprintf('Matlab cycle_reduction failed')
end end
end
% 2. Solve the equation with the Fortran cycle reduction algorithm % 2. Solve the equation with the Fortran cycle reduction algorithm
tElapsed2 = 0.; tElapsed2 = 0.;
...@@ -56,27 +48,20 @@ try ...@@ -56,27 +48,20 @@ try
R = norm(C+B*X2+A*X2*X2,1); R = norm(C+B*X2+A*X2*X2,1);
if (R > cvg_tol) if (R > cvg_tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran cycle_reduction solution is wrong') dprintf('Fortran cycle_reduction solution is wrong')
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran cycle_reduction failed') dprintf('Fortran cycle_reduction failed')
end end
end
% 3. Compare solutions of the Fortran and Matlab routines % 3. Compare solutions of the Fortran and Matlab routines
if (norm(X1 - X2, 1) > cvg_tol) if (norm(X1 - X2, 1) > cvg_tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran and Matlab cycle reduction solutions differ'); dprintf('Fortran and Matlab cycle reduction solutions differ');
end end
end
% Compare the Fortran and Matlab execution time % Compare the Fortran and Matlab execution time
if debug
if tElapsed1<tElapsed2 if tElapsed1<tElapsed2
skipline() skipline()
dprintf('Matlab cyclic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1) dprintf('Matlab cyclic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
...@@ -86,7 +71,6 @@ if debug ...@@ -86,7 +71,6 @@ if debug
dprintf('Fortran cyclic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2) dprintf('Fortran cyclic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline() skipline()
end end
end
t1 = clock; t1 = clock;
......
debug = false;
source_dir = getenv('source_root'); source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']); addpath([source_dir filesep 'matlab']);
...@@ -7,10 +5,8 @@ dynare_config; ...@@ -7,10 +5,8 @@ dynare_config;
testFailed = 0; testFailed = 0;
if ~debug
skipline() skipline()
disp('*** TESTING: logarithmicreduction.m ***'); disp('*** TESTING: logarithmicreduction.m ***');
end
matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'logarithmic_reduction']; matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'logarithmic_reduction'];
addpath(matlab_cr_path); addpath(matlab_cr_path);
...@@ -37,16 +33,12 @@ try ...@@ -37,16 +33,12 @@ try
R = norm(C+B*X1+A*X1*X1,1); R = norm(C+B*X1+A*X1*X1,1);
if (R > cvg_tol) if (R > cvg_tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Matlab logarithmic_reduction solution is wrong') dprintf('Matlab logarithmic_reduction solution is wrong')
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Matlab logarithmic_reduction failed') dprintf('Matlab logarithmic_reduction failed')
end end
end
% 2. Solve the equation with the Fortran logarithmic reduction algorithm % 2. Solve the equation with the Fortran logarithmic reduction algorithm
tElapsed2 = 0.; tElapsed2 = 0.;
...@@ -56,27 +48,20 @@ try ...@@ -56,27 +48,20 @@ try
R = norm(C+B*X2+A*X2*X2,1); R = norm(C+B*X2+A*X2*X2,1);
if (R > cvg_tol) if (R > cvg_tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran logarithmic_reduction solution is wrong') dprintf('Fortran logarithmic_reduction solution is wrong')
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran logarithmic_reduction failed') dprintf('Fortran logarithmic_reduction failed')
end end
end
% 3. Compare solutions of the Fortran and Matlab routines % 3. Compare solutions of the Fortran and Matlab routines
if (norm(X1 - X2, 1) > cvg_tol) if (norm(X1 - X2, 1) > cvg_tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran and Matlab logarithmic reduction solutions differ'); dprintf('Fortran and Matlab logarithmic reduction solutions differ');
end end
end
% Compare the Fortran and Matlab execution time % Compare the Fortran and Matlab execution time
if debug
if tElapsed1<tElapsed2 if tElapsed1<tElapsed2
skipline() skipline()
dprintf('Matlab logarithmic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1) dprintf('Matlab logarithmic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
...@@ -86,7 +71,6 @@ if debug ...@@ -86,7 +71,6 @@ if debug
dprintf('Fortran logarithmic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2) dprintf('Fortran logarithmic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline() skipline()
end end
end
t1 = clock; t1 = clock;
......
debug = false;
source_dir = getenv('source_root'); source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']); addpath([source_dir filesep 'matlab']);
...@@ -9,10 +7,8 @@ cd solver-test-functions ...@@ -9,10 +7,8 @@ cd solver-test-functions
testFailed = 0; testFailed = 0;
if ~debug
skipline() skipline()
disp('*** TESTING: nonlinearsolvers.m ***'); disp('*** TESTING: nonlinearsolvers.m ***');
end
tolf = 1e-6; tolf = 1e-6;
tolx = 1e-6; tolx = 1e-6;
...@@ -62,33 +58,25 @@ for i=1:length(objfun) ...@@ -62,33 +58,25 @@ for i=1:length(objfun)
if isequal(func2str(objfun{i}), 'powell2') if isequal(func2str(objfun{i}), 'powell2')
if ~errorflag if ~errorflag
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i})) dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end end
end
elseif isequal(func2str(objfun{i}), 'trigonometric') elseif isequal(func2str(objfun{i}), 'trigonometric')
% FIXME block_trust_region (mex) fails, with exit code equal to 4, but not trust_region (matlab). Would be nice to undertsand the difference. % FIXME block_trust_region (mex) fails, with exit code equal to 4, but not trust_region (matlab). Would be nice to undertsand the difference.
if ~errorflag if ~errorflag
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i})) dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end end
end
else else
if errorflag || norm(objfun{i}(x))>tolf if errorflag || norm(objfun{i}(x))>tolf
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver (mex) failed on %s function (norm(f(x))=%s).', func2str(objfun{i}), num2str(norm(objfun{i}(x)))) dprintf('Nonlinear solver (mex) failed on %s function (norm(f(x))=%s).', func2str(objfun{i}), num2str(norm(objfun{i}(x))))
end end
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver (mex) failed on %s function.', func2str(objfun{i})) dprintf('Nonlinear solver (mex) failed on %s function.', func2str(objfun{i}))
end end
end end
end
t1 = clock; etime(t1, t0) t1 = clock; etime(t1, t0)
...@@ -111,31 +99,23 @@ for i=1:length(objfun) ...@@ -111,31 +99,23 @@ for i=1:length(objfun)
if isequal(func2str(objfun{i}), 'powell2') if isequal(func2str(objfun{i}), 'powell2')
if ~errorflag if ~errorflag
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i})) dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end end
end
if info~=3 if info~=3
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function with info==3 but did not the correct value of info.', func2str(objfun{i})) dprintf('Nonlinear solver is expected to fail on %s function with info==3 but did not the correct value of info.', func2str(objfun{i}))
end end
end
else else
if errorflag if errorflag
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver failed on %s function (info=%s).', func2str(objfun{i}), int2str(info)) dprintf('Nonlinear solver failed on %s function (info=%s).', func2str(objfun{i}), int2str(info))
end end
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver failed on %s function.', func2str(objfun{i})) dprintf('Nonlinear solver failed on %s function.', func2str(objfun{i}))
end end
end end
end
t2 = clock; t2 = clock;
......
debug = true;
source_dir = getenv('source_root'); source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']); addpath([source_dir filesep 'matlab']);
...@@ -7,10 +5,8 @@ dynare_config; ...@@ -7,10 +5,8 @@ dynare_config;
testFailed = 0; testFailed = 0;
if ~debug
skipline() skipline()
disp('*** TESTING: riccatiupdate.m ***'); disp('*** TESTING: riccatiupdate.m ***');
end
t0 = clock; t0 = clock;
...@@ -57,19 +53,14 @@ try ...@@ -57,19 +53,14 @@ try
R = norm(Ptmp_fortran-Ptmp_matlab,1); R = norm(Ptmp_fortran-Ptmp_matlab,1);
if (R > tol) if (R > tol)
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('The Fortran Riccati update is wrong') dprintf('The Fortran Riccati update is wrong')
end end
end
catch catch
testFailed = testFailed+1; testFailed = testFailed+1;
if debug
dprintf('Fortran Riccati update failed') dprintf('Fortran Riccati update failed')
end end
end
% Compare the Fortran and Matlab execution time % Compare the Fortran and Matlab execution time
if debug
if tElapsed1<tElapsed2 if tElapsed1<tElapsed2
skipline() skipline()
dprintf('Matlab Riccati update is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1) dprintf('Matlab Riccati update is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
...@@ -79,7 +70,6 @@ if debug ...@@ -79,7 +70,6 @@ if debug
dprintf('Fortran Riccati update is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2) dprintf('Fortran Riccati update is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline() skipline()
end end
end
% Compare results after multiple calls % Compare results after multiple calls
N = 50; N = 50;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment