MathGroup Archive 2001

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

Search the Archive

Re: Differential equations error with MathLink/JLink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27927] Re: Differential equations error with MathLink/JLink
  • From: Ralph Gauges <ralph.gauges at eml.villa-bosch.de>
  • Date: Sat, 24 Mar 2001 00:48:53 -0500 (EST)
  • Organization: Tiscali / Nacamar
  • References: <98vh54$8sr@smc.vnet.net> <99chhr$8bi@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi again,

I looked into this getFunction error a little more closely, but I still can not find out what
the problem seems to be.
Since it works in Java, there has to be a way to get it to work in python as well.
I added some print statement to the python wrapper around MLGetFunction. I think, the rest of
the code is not that important. So what basically happens is that python finds out that it
will get a RETURNPKT and that the MLGetNext wrapper finds out that the next thing will be a
function (MLTKFUNC=70="F"). Just to be sure, I call MLGetNext again right before
MLGetFunction is called (see below) and I still get MLTKFUNC as the return value. (See
output.) But then the actual MLGetFunction call just fails and returns this "MLGet out of
sequence" error. When I do the same thing in JLink (GetNext and then getFunction), it seems
to work.
Does anyone see, where the error in this function might be.
I can get around this by assembling the whole expression that solves a set of differential
equations and getting the result from that, but I would still be interested in finding out
why this does not work.

Thanks a lot


Ralph





static PyObject *
GetFunction(PyObject *self, PyObject *args)
{
  long int len;

  const char *Function;
  PyObject *PyFunction;
  long int x;
  printf("Checking next again.\n");
  x=MLGetNext(lp);
  printf("%d\n",x);
  printf("getting Function.\n");
  MLGetFunction(lp, &Function, &len);
  printf("Got %s %d\n",Function,len);
  if (MLError( lp)) {
    printf("Error occured.\n");
    error( lp);
  }
  PyFunction = Py_BuildValue("si", Function, len);
  MLDisownSymbol(lp, Function);

  return PyFunction;
}



Testoutput for D[x[t],t]:

Next packet.
INPUTNAMEPKT
Getting string.
InputName: text= In[1]:=
Next packet.
RETURNPKT
Python GetNext.
Get next.
MLTKFUNC
NEXT is PYMLTKFUNC
Checking next again.
70
getting Function.
Got (null) 1
Error occured.
Error detected by MathLink: MLGet out of sequence.





  • Prev by Date: AW: Problem with Mathematica fonts in pdfLaTeX
  • Next by Date: Re: a few questions
  • Previous by thread: Re: Differential equations error with MathLink/JLink
  • Next by thread: Re: Differential equations error with MathLink/JLink