MathGroup Archive 2002

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

Search the Archive

Re: How to pass an input to the child MathKernel?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33496] Re: How to pass an input to the child MathKernel?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 24 Mar 2002 01:43:48 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <a7esml$mpm$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

the online-manual gives an example as well as THE BOOK


Open the link:

In[]:=link = LinkLaunch["math -mathlink"]

send an expression:

In[]:=LinkWrite[link, Unevaluated[EvaluatePacket[Expand[(x + 1)^3]]]]

read the data the link returns:

In[]:=LinkRead[link];
      LinkRead[link]

Out[]=ReturnPacket[1 + 3 x + 3 x^2 + x^3]


In[]:=LinkClose[link]

Regards
  Jens

Vladimir Bondarenko wrote:
> 
> Gentlemen,
> 
> What is the simplest way to implement the step # 2 ?
> 
>    1. From within a working MathKernel, run a new instance of the MathKernel
>       using the same machine
> >  2. Pass an input to the child MathKernel
>    3. Evaluate the passed input within the child MathKernel
>    4. Return the evaluated input into the parent MathKernel
>    5. Close the child MathKernel
> 
> Vladimir Bondarenko
> 
> P.S.
> 
> If I try something like
> 
> >  ReadList["!MathKernel", 2 + 1, RecordLists -> True]
> 
>    ReadList::"readf": " 3 is not a valid format specification."
> 
>    ReadList["!MathKernel", 3, RecordLists -> True]
> 
> then I probably use the parent (old) instance of the MathKernel.
> 
> If I use
> 
> >  ReadList[Run["MathKernel.exe"], 2 + 1, RecordLists -> True]
> 
>    General::"stream": " 0 is not a string, InputStream[ ], or OutputStream[ ]."
> 
>    ReadList[0, 3, RecordLists -> True]
> 
> then I do run the child MathKernel, but it looks like that the computation
> was done, again, by the parent MathKernel  8-(


  • Prev by Date: Re: Approximation of a Function
  • Next by Date: Re: Getting Symbolic Real and Imag Parts? (Once Again)
  • Previous by thread: Re: How to pass an input to the child MathKernel?
  • Next by thread: Integrate fails