MathGroup Archive 2001

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

Search the Archive

Re: Mathlink and BorlandC++

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30435] Re: [mg30391] Mathlink and BorlandC++
  • From: Omega Consulting <omega_consulting at yahoo.com>
  • Date: Sat, 18 Aug 2001 04:04:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

At 12:03 AM 8/15/2001, konraad dullaert wrote:
>Hey,
>
>
>I'm writting a program in Borland where I need to solve a differential
>equation (have to use NDSolve).
>After opening a link to Mathlink, you have to put the function that you want
>to use.
>
>         MLPutFunction (alink, "NDSolve, 3)
>
>But how do I send the two equations (namely the differential equation and the
>initial value) and the interval in which the equation has to solved to the
>Mathematica Kernel?
>
>Thanks for the effort,
>
>Konraad

You have to send the full expression out on the link piece by piece. Take 
the following.

NDSolve[{D[y[x],x]==y[x],y[1]==2},y,{x,0,3}]

To see the full expression, use FullForm

HoldForm[FullForm[NDSolve[{D[y[x],x]==y[x],y[1]==2},y,{x,0,3}]]]

NDSolve[List[Equal[D[y[x],x],y[x]],Equal[y[1],2]],y,List[x,0,3]]

Or maybe TreeForm works better for you.

HoldForm[TreeForm[NDSolve[{D[y[x],x]==y[x],y[1]==2},y,{x,0,3}]]]

So you would do the following

MLPutFunction (alink, "NDSolve", 3);
   MLPutFunction (alink, "List", 2);
     MLPutFunction (alink, "Equal", 2);
       MLPutFunction (alink, "D", 2);
         MLPutFunction (alink, "y", 1);
           MLPutSymbol(alink, "x");
         MLPutSymbol (alink, "x");
       MLPutFunction (alink, "y", 1);
         MLPutSymbol(alink, "x");
     MLPutFunction (alink, "Equal", 2);
       MLPutFunction (alink, "y", 1);
         MLPutInteger(alink, 1);
       MLPutInteger (alink, 2);
   MLPutSymbol (alink, "y", 1);
   MLPutFunction (alink, "List", 3);
     MLPutSymbol(alink, "x");
     MLPutInteger(alink, 0);
     MLPutInteger(alink, 3);

If you're uncomfortable with FullForm, you can send an InputForm string and 
have M_ turn it into an expression with the ToExpression command.

MLPutFunction (alink, "ToExpression", 1);
   MLPutString(alink, "NDSolve[{D[y[x],x]==y[x],y[1]==2},y,{x,0,3}]");




  • Prev by Date: Re: byte[ ] of J/Link
  • Next by Date: Re: Re: Rotation3D, MatrixRotation3D ?
  • Previous by thread: Re: Mathlink and BorlandC++
  • Next by thread: AW: problems with lists