Added TBigIntPolynomial.ToString

This commit is contained in:
Stefan Müller 2024-05-20 01:04:18 +02:00
parent d503968cee
commit 7ac4a3519a
1 changed files with 13 additions and 0 deletions

View File

@ -40,6 +40,7 @@ type
function CalcValueAt(const AX: Int64): TBigInt; function CalcValueAt(const AX: Int64): TBigInt;
function IsEqualTo(const AOther: TBigIntPolynomial): Boolean; function IsEqualTo(const AOther: TBigIntPolynomial): Boolean;
function ScaleVariable(const AScaleFactor: TBigInt): TBigIntPolynomial; function ScaleVariable(const AScaleFactor: TBigInt): TBigIntPolynomial;
function ToString: string;
class function Create(const ACoefficients: array of TBigInt): TBigIntPolynomial; static; class function Create(const ACoefficients: array of TBigInt): TBigIntPolynomial; static;
end; end;
@ -109,6 +110,18 @@ begin
SetLength(Result.FCoefficients, 0); SetLength(Result.FCoefficients, 0);
end; end;
function TBigIntPolynomial.ToString: string;
var
i: Integer;
begin
Result := FCoefficients[0].ToString;
for i := 1 to Length(FCoefficients) - 1 do
if i > 1 then
Result := Result + ' + ' + FCoefficients[i].ToString + ' * x^' + IntToStr(i)
else
Result := Result + ' + ' + FCoefficients[i].ToString + ' * x';
end;
class function TBigIntPolynomial.Create(const ACoefficients: array of TBigInt): TBigIntPolynomial; class function TBigIntPolynomial.Create(const ACoefficients: array of TBigInt): TBigIntPolynomial;
var var
high, i: integer; high, i: integer;