ISmExpressionProvider.Metabase

Syntax

Metabase: Object;

Description

The Metabase property determines the repository where the system searches for the custom unit used in the expression.

Comments

This property is relevant for statistical methods, for which the expressions can be specified:

Example

Executing the example requires that the repository contains a unit with the STAT_FUNC identifier containing the "test" custom function.

Add links to the Metabase, Stat system assemblies.

Sub UserProc;
Var
    sm: SmNonLinearEquations;
    functions: array[
2Of string;
    initvalues: array[
2Of double;
    status: integer;
    provider: ISmExpressionProvider;
Begin
    sm := 
New SmNonLinearEquations.Create;
    provider := sm 
As ISmExpressionProvider;
    
// Get the current repository for searching for a custom unit
    provider.Metabase := MetabaseClass.Active;
    
// Set equation expressions
    functions[0] := "y1+12.34-0.21*134";
    
// Pass custom function to equation expression
    functions[1] := "STAT_FUNC.test(y1,y2)";
    sm.Functions := functions;
    initvalues[
0] := 1;
    initvalues[
1] := 1;
    
// Determine initial approximations
    sm.InitApproximation := initvalues;
    
// Determine coefficient order
    sm.CoefficientsOrder := "y1;y2";
    
// Check if there are errors
    status := sm.Execute;
    debug.WriteLine(status);
    debug.WriteLine(sm.Errors);
    
If (status = 0Then
        debug.WriteLine(sm.Solution[
0].tostring);
        debug.WriteLine(sm.Solution[
1].tostring);
        debug.WriteLine(sm.FunctionValues[
0].tostring);
        debug.WriteLine(sm.FunctionValues[
1].tostring);
    
End If;
End Sub UserProc;

 

// Custom function
Public Function test(x1, x2: double): double;
Begin
    Return x1 * (x2 - 1);
End Function test;

Executing this example shows the calculation results in the console window: Custom function is to be used in method expressions.

See also:

ISmExpressionProvider