Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[mg14754] Difference between Mathlink and frontend output

0 views
Skip to first unread message

Jim McGuire

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to math...@smc.vnet.net
I am reading a function from a package into a Mathlink which defines the
function

xx[a_, b_List, c_List, d_, e_, f_] :=
x[a] /. xxRules[b, c, d, e, f]

where xxRules is the result of a rather complicated NDSolve. When I
read the package into a Mathematica session and evaluate the function

Get["D:\\jimm\\svgcn018\\TED.m"];
xx[0.5, {0.5, 1.2566370362}, {0.000001, 60}, 1000, 100, 0]

I get the expected numerical result. However, when I try the same thing
with MathLink,

// constants for mathematica calls
double phiBound[]={0.5, 1.2566370362}; // array of starting + ending phi
values
double xBound[]={0.000001, 60.}; // array of starting + ending x values
double H=1000.; // distance between source
pupil plane
double rStart=100.; // distance from source to ID of
collector
int n=0; // number of iterations for
reflectivity

MLPutFunction(stdlink,"EvaluatePacket",1); // start evaluation
packet
MLPutFunction(stdlink,"Get",1); // load saved
Mathematica definitions
MLPutString(stdlink,"D:\\\\jimm\\\\svgcn018\\\\TED.m");
MLEndPacket(stdlink);

// Read and discard data until an error or return packet is found
while ((pkt = MLNextPacket(stdlink)) && pkt != RETURNPKT)
MLNewPacket(stdlink);
MLNewPacket(stdlink); // discard NULL symbol returned from GET

MLPutFunction(stdlink,"EvaluatePacket",1); // call Mathematica
function
MLPutFunction(stdlink, "ToString",1);
MLPutFunction(stdlink,"xx",6);
MLPutReal(stdlink,phiBound[0]);
MLPutRealList(stdlink,phiBound,2);
MLPutRealList(stdlink,xBound,2);
MLPutReal(stdlink,H);
MLPutReal(stdlink,rStart);
MLPutInteger(stdlink,n);
MLEndPacket(stdlink); // end of Mathematica
input

// Read and discard data until an error or return packet is found
while ((pkt = MLNextPacket(stdlink)) && pkt != RETURNPKT)
MLNewPacket(stdlink);

MLGetString(stdlink, &str);
printf(str);

I get the the unevaluated InterpolatingFunction

InterpolatingFunction[{{0.5,1.25663703619999989058442}}, <>][0.5]

I assume that the FrontEnd is forcing the evaluation and I am not with
the MathLink code. Any suggestions?

Thanks in advance.

Jim


0 new messages