| 1 |
%Driver script, works as a unit test |
| 2 |
%Will force MATLAB to return with exit code depending on comparison |
| 3 |
%of solution vectors from matlab function and muelu |
| 4 |
addpath('../../bin') |
| 5 |
|
| 6 |
try |
| 7 |
%Create a small problem with only one level |
| 8 |
A = laplacianfun([80, 80]); |
| 9 |
b = (1:6400)'; |
| 10 |
matlabSoln = 0 * b; %Set 'initial guesses' to all 0 |
| 11 |
mueluSoln = matlabSoln; |
| 12 |
%Note: In both of these problems, set reuse type to full so that P is not discarded |
| 13 |
mueluProblem = muelu('setup', A, 'xml parameter file', 'mueluParams.xml'); |
| 14 |
matlabProblem = muelu('setup', A, 'xml parameter file', 'matlabParams.xml'); |
| 15 |
mueluSoln = muelu(mueluProblem, b); |
| 16 |
matlabSoln = muelu(matlabProblem, b); |
| 17 |
%Compare the solutions to near machine precision for equality |
| 18 |
areEqual = true(1); |
| 19 |
for index = 1:numel(matlabSoln) |
| 20 |
%Use machine precision minus a few digits |
| 21 |
precision = eps(mueluSoln(index)) * 1000; |
| 22 |
if(abs(mueluSoln(index) - matlabSoln(index)) > precision) |
| 23 |
areEqual = false(1); |
| 24 |
break |
| 25 |
end |
| 26 |
end |
| 27 |
muelu('cleanup'); |
| 28 |
if areEqual |
| 29 |
disp('Test passed, MueLu produced same solution as gold standard in MATLAB.'); |
| 30 |
exit(0); |
| 31 |
else |
| 32 |
disp('Test failed, MueLu''s solution did not match MATLAB''s.'); |
| 33 |
exit(-1); |
| 34 |
end |
| 35 |
|
| 36 |
catch me |
| 37 |
disp('Test failed, on exception:'); |
| 38 |
disp(getReport(me)); |
| 39 |
exit(-2) |
| 40 |
end |