Renamed root finding class and methods, now class methods

This commit is contained in:
2024-05-26 14:23:31 +02:00
parent ae30889bbb
commit ab453b347d
2 changed files with 20 additions and 33 deletions

View File

@@ -32,10 +32,6 @@ type
private
procedure AssertBisectResult(constref AIsolatingIntervals: TIsolatingIntervals; constref AExpectedRoots:
array of Cardinal);
protected
FRootIsolation: TRootIsolation;
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestBisectNoBound;
procedure TestBisectWithBound;
@@ -68,18 +64,6 @@ begin
end;
end;
procedure TPolynomialRootsTestCase.SetUp;
begin
inherited SetUp;
FRootIsolation := TRootIsolation.Create;
end;
procedure TPolynomialRootsTestCase.TearDown;
begin
FRootIsolation.Free;
inherited TearDown;
end;
procedure TPolynomialRootsTestCase.TestBisectNoBound;
const
expRoots: array of Cardinal = (34000, 23017, 5);
@@ -90,7 +74,7 @@ begin
// y = 3 * (x - 34000) * (x - 23017) * (x - 5) * (x^2 - 19) * (x + 112)
// = 3 * x^6 - 170730 * x^5 + 2329429920 * x^4 + 251300082690 * x^3 - 1270471872603 * x^2 + 4774763204640 * x - 24979889760000
a := TBigIntPolynomial.Create([-24979889760000, 4774763204640, -1270471872603, 251300082690, 2329429920, -170730, 3]);
r := FRootIsolation.Bisect(a);
r := TPolynomialRoots.BisectIsolation(a);
AssertBisectResult(r, expRoots);
r.Free;
end;
@@ -105,7 +89,7 @@ begin
// y = 3 * (x - 34000) * (x - 23017) * (x - 5) * (x^2 - 19) * (x + 112)
// = 3 * x^6 - 170730 * x^5 + 2329429920 * x^4 + 251300082690 * x^3 - 1270471872603 * x^2 + 4774763204640 * x - 24979889760000
a := TBigIntPolynomial.Create([-24979889760000, 4774763204640, -1270471872603, 251300082690, 2329429920, -170730, 3]);
r := FRootIsolation.Bisect(a, TBigInt.One << 15);
r := TPolynomialRoots.BisectIsolation(a, TBigInt.One << 15);
AssertBisectResult(r, expRoots);
r.Free;
end;