Re: Passing functions to C-code

*To*: mathgroup at smc.vnet.net*Subject*: [mg31590] Re: Passing functions to C-code*From*: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>*Date*: Thu, 15 Nov 2001 05:52:24 -0500 (EST)*Organization*: Universitaet Leipzig*References*: <9stbsl$3dd$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, *what* do you like to pass the C-Code a) the name of the function ? Yes, you can do this and your C-code will get a Symbol tha can be used by MLPutFunction() b) the *definition*, this is a bit complicated on both sides because Definition[MyFunc] is just a wrapper that returns the printed form of the definition and you have to pass ToString[Definition[MyFunc]] as a string and you C-Code must be able to parse the Mathematica syntax c) the UpValues[], DownValues[] of MyFunc, that are Mathematica rules, and you program has to read it with :ArgumentType: Manual and has to deal with HoldPattern[]s to interpret it. Regards Jens "Lawrence A. Walker Jr." wrote: > > Hi, > > I am wondering if it is possible to pass functions to C-code using > Mathlink. I know that I can pass numbers, arrays, and matrices to my > C-code function. > > For example if I specify a function called > > MyFunc[x_,y_]:=x+y; > > Then I would like to pass this function to my linked C-code like so, > > myCfunc[MyFunc] > > If this is possible then I can pass error functions to my externally > link C-code for optimization. > > Thanks, > Lawrence