Hello, I have a request related to the TSymbolicFunction class. The Create constructor of this class contains the BuildFormula method, which is called when an instance is created. Is it possible to remove it from the constructor to call it optionally? I will explain why.
I created a helper class for numerical integration:
class function TNumericalIntegration.IntegrateAsRect(Translator: TTranslator;
const Func, x: string;
const x1, x2: TFloat;
const nx: Integer = 10): TFloat;
begin
var SF := TNonAutomaticSymbolicFunction1D.Create(x, Func, GetParameters(Translator));
SF.ImportFunctionsFromTranslator(Translator);
try
SF.BuildFormula;
Result := TRectIntegrator.Integral(SF.F, x1, x2, nx);
finally
SF.Free;
end;
end;
The key point is to pass not only variables (parameters) to the function, but also user-defined functions. To do this, I first import the functions (ImportFunctionsFromTranslator), and only then call the BuildFormula method.
Another request related to the TFunctionalContext class. Is it possible to add a Count property to it? Or even better, to provide public access to FData (for example, through a property). Now I import functions with the following hack:
type
THackFunctionalContext = class(TFunctionalContext)
public
property FunctionalData: TList<TFunctionalData> read FData;
end;
procedure TNonAutomaticSymbolicFunction.ImportFunctionsFromTranslator(ATranslator: TTranslator);
var
i: Integer;
FD: TFunctionalData;
begin
for i := 0 to THackFunctionalContext(ATranslator.Functions).FunctionalData.Count - 1 do
begin
FD := THackFunctionalContext(ATranslator.Functions).FunctionalData[i];
Evaluator.AddFunction(FD.Name, FD.Formula, FD.Variables);
end;
end;
Of course, it is logical to have direct access to this data. I look forward to your feedback)