XSLPcalluserfunc
PurposeCall a user function from a program or from within another user functionSynopsisdouble XPRS_CC XSLPcalluserfunc(XSLPprob Prob, int FuncNumber, void *Arg1, void *Arg2, void *Arg3, void *Arg4, void *Arg5, void *Arg6)Arguments
Prob The current SLP problem. FuncNumber The internal number of the function to be called. Arg1 address of an array of double precision values holding the input values for the function. May be NULL if not required. Arg2 address of an array of integer values. This must be dimensioned at least XSLP_FUNCINFOSIZE and is normally populated by using XSLPsetuserfuncinfo. This array must always be provided, even if the user function does not use it. Arg3 address of a string buffer, normally used to hold the names of the input variables. May be NULL if not required. Arg4 address of a string buffer, normally used to hold the names of the return variables. May be NULL if not required. Arg5 address of an array of double precision values, normally used to hold the array of perturbations or flags for calculating first derivatives. May be NULL if not required. Arg6 address of an array of double precision values, used to hold the array of return values from the function. This argument can always be provided and, if not null, will be used to hold the return value(s) from the function. May be NULL if not required.Return valueIf the called function returns a single value, the return value of XSLPcalluserfunc is the called function value; if the called function returns the address of array of values, the return value of XSLPcalluserfunc is the value of the first item in the array.ExampleThe following example sets up the data to call user function number 2 with three input values, and prints the first return value from the function.double InputArray[3], ReturnArray[4]; double FuncInfo[XSLP_FUNCINFOSIZE]; InputArray[0] = 1.42; InputArray[1] = 5; InputArray[2] = -99; XSLPsetuserfuncinfo(Prob, FuncInfo, 0, 3, 1, 0, 0, 0); XSLPcalluserfunc(Prob, 2, InputArray, FuncInfo, NULL, NULL, NULL, ReturnArray); printf("Result = %lg\n",ReturnArray[0]);Further informationApart from Arg2 (which is always required) and Arg6 (which will always be used if it is provided), any argument required by the function must not be NULL. So, for example, if the function expects an array of input names then Arg3 must be provided.
It is the user's responsibility to ensure that any arrays used are large enough to hold the data.
Related topics
If you have any comments or suggestions about these pages, please send mail to docs@dashoptimization.com.