Tag Info

Hot answers tagged

6

a bit of an extended comment, Note there is no need for a delayed defintion of your pdf: pdf[r_] = Simplify[2 (Piecewise[{{0, r <= 0.59}, {1.36814, Inequality[0.59, Less, r, LessEqual, 0.7]}, {0, r > 0.7}}, Indeterminate] + Piecewise[{{0, r <= 0.7}, {1.99139, Inequality[0.7, Less, r, LessEqual, 0.85]}, {0, r > 0.85}}, ...


3

tl; dr Report errors through return values. MathLink programs can return any Mathematica expression they like which makes structured error handling possible. It looks like you have a function that returns integers with a template like :Begin: :Function: get_number :Pattern: getNumber[x_Integer] :Arguments: {x} :ArgumentTypes: {Integer32} ...


2

Yes: Just use return MLPutFunction(mlp, "EvaluatePacket", 1L) && MLPutFunction(mlp, "ToString", 1L) // <<<--- ! && MLPutFunction(mlp, "ToExpression", 1L) /* ... */


1

I guess that this is a linkage issue. The generated output.tm.c file is compiled a C code whereas "your code" is compiled as C++ code. Thus the function output will have C++ linkage while the function __tr0 expects the function to have C linkage. In your C++ code, declare the function with C linkage using extern "C", i.e.: #include "mathlink.h" using ...



Only top voted, non community-wiki answers of a minimum length are eligible