Fixed calculation of root-isolating intervals and tests

This commit is contained in:
2024-05-25 02:50:24 +02:00
parent 748964c871
commit ae30889bbb
2 changed files with 9 additions and 7 deletions

View File

@@ -49,20 +49,22 @@ procedure TPolynomialRootsTestCase.AssertBisectResult(constref AIsolatingInterva
AExpectedRoots: array of Cardinal);
var
exp: Cardinal;
ri: TIsolatingInterval;
found: Boolean;
i, foundIndex: Integer;
begin
AssertEquals('Unexpected number of isolating intervals.', Length(AExpectedRoots), AIsolatingIntervals.Count);
for exp in AExpectedRoots do
begin
found := False;
for ri in AIsolatingIntervals do
if (ri.A <= exp) and (exp <= ri.B) then
for i := 0 to AIsolatingIntervals.Count - 1 do
if (AIsolatingIntervals[i].A <= exp) and (exp <= AIsolatingIntervals[i].B) then
begin
found := True;
foundIndex := i;
Break;
end;
AssertTrue('No isolating interval for expected root ' + IntToStr(exp) + ' found.', found);
AIsolatingIntervals.Delete(foundIndex);
end;
end;