MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Difference between Mathlink and frontend output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14754] Difference between Mathlink and frontend output
  • From: Jim McGuire <jimm at opticalres.com>
  • Date: Thu, 12 Nov 1998 02:17:52 -0500
  • Organization: Optical Research Associates
  • Sender: owner-wri-mathgroup at wolfram.com

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


  • Prev by Date: Re: config. data from internet database
  • Next by Date: Re: A "singular" equation
  • Previous by thread: Vector Aarows and monitor problems
  • Next by thread: Levy Distribution