SLPcalluserfunc
PurposeCall a user function directly from MoselSynopsisfunction SLPcalluserfunc(FuncName:string|FuncNumber:integer, iArray:array(Ri:range) of real,
FuncInfo:array(RA:range) of integer,
InString:array(RI:range) of string,
OutString:array(RO:range) of string,
dArray:array(Rd:range) of real
[, rArray:array(Rr:range) of real]) :real
Arguments
FuncName The name of the user function to be called FuncNumber The index of the user function to be called iArray A real array containing the input values to the function to be called FuncInfo An integer array containing the function and argument information array for the function to be called. This must always be dimensioned at least 1..xslp_funcinfosize. InString A string array containing the names of the input arguments for the function to be called OutString A string array containing the names of the output arguments for the function to be called dArray A real array containing the partial derivative flags for the function to be called rArray A real array to hold the values returned from the function to be calledReturn valueThe first (or only) value returned by the function being calledExampleThe following example initializes data for a call to the user function called MoselArray and then calls the functiondeclarations InArray:array(1..100) of real FuncInfo:array(1..xslp_funcinfosize) of integer RetArray:array(1..200) of real NullString: dynamic array(1..1) of string NullReal: dynamic array(1..1) of real end-declarations SLPDATA("UF","MoselArea","","DOUBLE,INTEGER","DLL","MyLib") Count := 5 N := 1 forall (i in 1..Count) do InArray(N) := rho(i) InArray(N+1) := theta(i) N := N+2 end-do SLPsetuserfuncinfo(FuncInfo,1,Count,1,0,0,0) Result := SLPcalluserfunc("MoselArea", InArray, FuncInfo, NullString, NullString, NullReal, RetArray)Note the use of empty dynamic arrays where SLPcalluserfunc requires an argument but the user function does not.Further informationSLPcalluserfunc can take the name or the index of the user function as its first argument. Use of the index (obtained by using SLPgetindex) is more efficient when there are repeated calls to the same function.
SLPcalluserfunc always has arguments representing all the possible input arguments to the user function. If the user function does not use an argument (it is missing in the SLPDATA declaration), then an empty dynamic array of the appropriate type should be used, as in the above example.
If the user function requires the use of the return array argument (rArray) then this must be included in the SLPcalluserfunc statement. If the user function does not require it, then its presence in the SLPcalluserfunc statement is optional. If it is present, it will be filled with the value(s) returned by the function.
If the function returns more than one value, the first one will be used as the return value of SLPcalluserfunc.
Related topics
If you have any comments or suggestions about these pages, please send mail to docs@dashoptimization.com.