Fix cycle reduction:

(i) making the norms consistent between cycle_reduction and its test;
(ii) remove hard errors in cycle_reduction Fortran and Matlab routines
bgp-dev
NormannR 2022-10-04 22:37:40 +02:00 committed by Normann Rion
parent 855887b249
commit afb044c23e
3 changed files with 7 additions and 7 deletions

View File

@ -108,7 +108,7 @@ if (nargin == 5 && ~isempty(ch) )
if (res > cvg_tol)
info(1) = 403
info(2) = log(res)
error(['The norm of the residual is ' num2str(res) ' whereas the tolerance criterion is ' num2str(cvg_tol)]);
dprintf('The norm of the residual is %s whereas the tolerance criterion is %s', num2str(res), num2str(cvg_tol));
end
end

View File

@ -99,7 +99,7 @@ loop: do
info(2) = log(residual)
write (cvg_tol_str,"(es8.2)") cvg_tol
write (residual_str,"(es8.2)") residual
call mexErrMsgTxt("The norm of the residual is "&
call mexPrintf("The norm of the residual is "&
&// trim(residual_str) // &
&", whereas the tolerance criterion is " &
// trim(cvg_tol_str) // "." )

View File

@ -54,8 +54,8 @@ tElapsed1 = 0.;
try
tic; [X1,info] = cycle_reduction_matlab(C,B,A,cvg_tol,[0.]); tElapsed1 = toc;
disp(['Elapsed time for the Matlab cycle reduction algorithm is: ' num2str(tElapsed1) ' (n=' int2str(n) ').'])
R = C+B*X1+A*X1*X1;
if (max(abs(R(:))) > cvg_tol)
R = norm(C+B*X1+A*X1*X1,1);
if (R > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Matlab cycle_reduction solution is wrong')
@ -74,8 +74,8 @@ tElapsed2 = 0.;
try
tic; [X2,info] = cycle_reduction(C,B,A,cvg_tol,[0.]); tElapsed2 = toc;
disp(['Elapsed time for the Fortran cycle reduction algorithm is: ' num2str(tElapsed2) ' (n=' int2str(n) ').'])
R = C+B*X2+A*X2*X2;
if (max(abs(R(:))) > cvg_tol)
R = norm(C+B*X2+A*X2*X2,1);
if (R > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Fortran cycle_reduction solution is wrong')
@ -90,7 +90,7 @@ end
% 3. Compare solutions of the Fortran and Matlab routines
NumberOfTests = NumberOfTests+1;
if (max(abs(X1(:) - X2(:))) > cvg_tol)
if (norm(X1 - X2, 1) > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Fortran and Matlab cycle reduction solutions differ');