applied_numerics_uulm/w3/testSolveLR.m

14 lines
401 B
Mathematica
Raw Normal View History

2022-05-15 20:14:47 +00:00
function testSolveLR()
success = test( [1,3,2; 2,15,2; 1,3,4], [1;2;3] )
success = success & test ( [1,1,1; 4,3,-1; 3,5,3], [4;2;0] )
success = success & test ( [1, 0, 0; 0, 1, 0; 0, 0, 1], [4; 2; 0] )
if success
disp("It works!")
else
disp("It broke!")
end
end
function success = test(A, b)
success = isequal(linsolve(A, b), solveLR(gaussLR(A), b))
end