Fix cycle reduction:
(i) making the norms consistent between cycle_reduction and its test; (ii) remove hard errors in cycle_reduction Fortran and Matlab routinesbgp-dev
parent
855887b249
commit
afb044c23e
|
@ -108,7 +108,7 @@ if (nargin == 5 && ~isempty(ch) )
|
||||||
if (res > cvg_tol)
|
if (res > cvg_tol)
|
||||||
info(1) = 403
|
info(1) = 403
|
||||||
info(2) = log(res)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ loop: do
|
||||||
info(2) = log(residual)
|
info(2) = log(residual)
|
||||||
write (cvg_tol_str,"(es8.2)") cvg_tol
|
write (cvg_tol_str,"(es8.2)") cvg_tol
|
||||||
write (residual_str,"(es8.2)") residual
|
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) // &
|
&// trim(residual_str) // &
|
||||||
&", whereas the tolerance criterion is " &
|
&", whereas the tolerance criterion is " &
|
||||||
// trim(cvg_tol_str) // "." )
|
// trim(cvg_tol_str) // "." )
|
||||||
|
|
|
@ -54,8 +54,8 @@ tElapsed1 = 0.;
|
||||||
try
|
try
|
||||||
tic; [X1,info] = cycle_reduction_matlab(C,B,A,cvg_tol,[0.]); tElapsed1 = toc;
|
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) ').'])
|
disp(['Elapsed time for the Matlab cycle reduction algorithm is: ' num2str(tElapsed1) ' (n=' int2str(n) ').'])
|
||||||
R = C+B*X1+A*X1*X1;
|
R = norm(C+B*X1+A*X1*X1,1);
|
||||||
if (max(abs(R(:))) > cvg_tol)
|
if (R > cvg_tol)
|
||||||
testFailed = testFailed+1;
|
testFailed = testFailed+1;
|
||||||
if debug
|
if debug
|
||||||
dprintf('Matlab cycle_reduction solution is wrong')
|
dprintf('Matlab cycle_reduction solution is wrong')
|
||||||
|
@ -74,8 +74,8 @@ tElapsed2 = 0.;
|
||||||
try
|
try
|
||||||
tic; [X2,info] = cycle_reduction(C,B,A,cvg_tol,[0.]); tElapsed2 = toc;
|
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) ').'])
|
disp(['Elapsed time for the Fortran cycle reduction algorithm is: ' num2str(tElapsed2) ' (n=' int2str(n) ').'])
|
||||||
R = C+B*X2+A*X2*X2;
|
R = norm(C+B*X2+A*X2*X2,1);
|
||||||
if (max(abs(R(:))) > cvg_tol)
|
if (R > cvg_tol)
|
||||||
testFailed = testFailed+1;
|
testFailed = testFailed+1;
|
||||||
if debug
|
if debug
|
||||||
dprintf('Fortran cycle_reduction solution is wrong')
|
dprintf('Fortran cycle_reduction solution is wrong')
|
||||||
|
@ -90,7 +90,7 @@ end
|
||||||
|
|
||||||
% 3. Compare solutions of the Fortran and Matlab routines
|
% 3. Compare solutions of the Fortran and Matlab routines
|
||||||
NumberOfTests = NumberOfTests+1;
|
NumberOfTests = NumberOfTests+1;
|
||||||
if (max(abs(X1(:) - X2(:))) > cvg_tol)
|
if (norm(X1 - X2, 1) > cvg_tol)
|
||||||
testFailed = testFailed+1;
|
testFailed = testFailed+1;
|
||||||
if debug
|
if debug
|
||||||
dprintf('Fortran and Matlab cycle reduction solutions differ');
|
dprintf('Fortran and Matlab cycle reduction solutions differ');
|
||||||
|
|
Loading…
Reference in New Issue