Added TBigIntPolynomial.ScaleVariable
This commit is contained in:
parent
0bbae0a83e
commit
4c0ff2f23f
|
@ -39,6 +39,7 @@ type
|
|||
property Coefficient[const AIndex: Integer]: TBigInt read GetCoefficient;
|
||||
function CalcValueAt(const AX: Int64): TBigInt;
|
||||
function IsEqualTo(const AOther: TBigIntPolynomial): Boolean;
|
||||
function ScaleVariable(const AScaleFactor: TBigInt): TBigIntPolynomial;
|
||||
class function Create(const ACoefficients: array of TBigInt): TBigIntPolynomial; static;
|
||||
end;
|
||||
|
||||
|
@ -88,6 +89,26 @@ begin
|
|||
Result := False;
|
||||
end;
|
||||
|
||||
function TBigIntPolynomial.ScaleVariable(const AScaleFactor: TBigInt): TBigIntPolynomial;
|
||||
var
|
||||
len, i: Integer;
|
||||
factor: TBigInt;
|
||||
begin
|
||||
if AScaleFactor <> TBigInt.Zero then
|
||||
begin
|
||||
len := Length(FCoefficients);
|
||||
SetLength(Result.FCoefficients, len);
|
||||
Result.FCoefficients[0] := FCoefficients[0];
|
||||
factor := AScaleFactor;
|
||||
for i := 1 to len - 1 do begin
|
||||
Result.FCoefficients[i] := FCoefficients[i] * factor;
|
||||
factor := factor * AScaleFactor;
|
||||
end;
|
||||
end
|
||||
else
|
||||
SetLength(Result.FCoefficients, 0);
|
||||
end;
|
||||
|
||||
class function TBigIntPolynomial.Create(const ACoefficients: array of TBigInt): TBigIntPolynomial;
|
||||
var
|
||||
high, i: integer;
|
||||
|
|
Loading…
Reference in New Issue