14 lines
401 B
Mathematica
14 lines
401 B
Mathematica
|
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
|