I have used the LibraryLink wrapper for some days. In general, there is only one result retruned by the LibraryFunction[]. Below is a simple example:
DLLEXPORT int add1(WolframLibraryData libData, mint Argc, MArgument *Args, MArgument Res) {
mint I0;
mint I1;
I0 = MArgument_getInteger(Args[0]);
I1 = I0 + 1;
MArgument_setInteger(Res, I1);
return LIBRARY_NO _ERROR;
}
However, in pratical applications, multiple results may also occur. For instance, I have a C function elevate_bspline_degree(), which has the following decalration:
void elevate_bspline_degree(double *Pw, double *U, int p)
This function mainly elevates the degree of the B-spline from p to p + 1, and calculate the new control points and new knots vector via the pointer variables Pw and U, respectively. Lastly, Corresponding value will be returned by Pw and U.
getCtrlpts[]andgetKnots[]. But I didn't mean that these should call the same function under the hood and do the computation two times. Just do the computation a single time, store the result, then use two functions to retrieve each of the two results. – Szabolcs Aug 01 '16 at 10:09int result1, result2;Function to compute both $x^2$ and $x^4$:void compute(int k) { result1 = k*k; result2 = result1*result1; }Functions to retrieve results:int square() { return result1; }andint pow4() { return result2; }. In Mathematica you will have a wrapper function which calls these in the correct order, i.e. compute first, then retrieve result 1 then retrieve result2. In a real scenario you probably need to allocate memory forresult1andresult2(mallocor similar). So you may need ... – Szabolcs Aug 01 '16 at 10:54TriangleCreate. Then you add data to it (e.g. set point coordinates). Then you call a function to compute something. Then you can retrieve multiple results, each with its own function. In Mathematica 9, finally you had toTriangleDeletethe expression. In M10 you can justClearit. – Szabolcs Aug 01 '16 at 10:55