MathGroup Archive 1992

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

Search the Archive

Re: Mathematica Problem

  • Subject: Re: Mathematica Problem
  • From: Douglas B. Stein <doug>
  • Date: Tue, 6 Oct 1992 19:59:27 GMT
  • Apparently-to: mathgroup-send at yoda.physics.unc.edu

In article <9210052016.AA04687 at yoda.physics.unc.edu> JAIMUNGAL 
SEBASTIAN, jaimung at ecf.toronto.edu writes:
>Then I try to execute the new command : Pendulum[{1,0},{10,1},False]  ->
>LinkObject::linkd: LinkObject[a.out,1,1] is closed; the connection is
dead.
>
>What could be wrong.  [NB this program seems to work fine on another
computer 
>system but I get this error on this system]

The following is a response I made to the querent via email after he sent
me his code. I am sending it to the newsgroup since it may have wider
appeal...

Dear Jaimungal,

This one's easy. You have too many MLEndPacket calls. Remove the
following two:

>		/* Output the data point */
>		MLPutFunction(stdlink, "List", 3);
>			MLPutReal(stdlink, q);
>			MLPutReal(stdlink, p);
>			MLPutReal(stdlink, ham(q, p));
>		MLEndPacket(stdlink);
>

>		/* Create the image, 2Pi away... */
>		if (doubl) {
>			MLPutFunction(stdlink, "List", 3);
>				if (q < 0.0)
>					MLPutReal(stdlink, q + 2 * M_PI);
>				else
>					MLPutReal(stdlink, q - 2 * M_PI);
>				MLPutReal(stdlink, p);
>				MLPutReal(stdlink, ham(q, p));
>			MLEndPacket(stdlink);
>		} 

and keep the following one:

>void pendulum(q0, p0, pts, dt, doubl)
>double q0, p0, dt;
>int doubl, pts;
>{
>	fprintf(stderr, "pendulum(%g, %g, %d, %g, %d);\n",
>						q0, p0, pts, dt, doubl);
>
>	if (doubl) MLPutFunction(stdlink, "List", 2 * pts);
>	else MLPutFunction(stdlink,"List", pts);
>		point(q0, p0, pts, dt, doubl);
>	MLEndPacket(stdlink);
>}
>


Each call to Pendulum will result in one expression returned. Hence there
is one ReturnPacket[]. When you called any MLPut calls after your first
MLEndPacket encountered, MathLink would stop sending and would return an
error code for any call you made. It worked on the Sun because that was
an older version.

I've tried this on a Mac and it works! (I had to ifdef away the fprintf
calls and define M_PI which doesn't exist in math.h on Macintoshes). What
are some of the things you intend to do with the angle/angular
momentum/hamiltonian triples? I'm a physicist by training and am curious
about dynamical systems?

Doug


------------------------------------------

Doug Stein
Member of Technical Staff
MathLink Development
Wolfram Research, Inc.
doug at wri.com





  • Prev by Date: Re: Memory management by Share[]?
  • Next by Date: ReplaceAll feature
  • Previous by thread: Mathematica Problem
  • Next by thread: The case of the disappearing windows.