MathLink Question
- To: mathgroup at smc.vnet.net
- Subject: [mg8386] MathLink Question
- From: Kashif Rasul <kras2 at mfs01.cc.monash.edu.au>
- Date: Tue, 26 Aug 1997 20:41:23 -0400
- Organization: Monash Uni
- Sender: owner-wri-mathgroup at wolfram.com
Hi, How can I export a function to a C program and then evaluate it for a specific value inside the C program by sending it back to Mathematica? For example: CalcAt[0.5, 1-0.5#&] I have tried using the following double calcat(double x) { char* fname; long nargs; double result; MLGetFunction(stdlink, &fname, &nargs); MLPutFunction(stdlink, fname, nargs); MLPutDouble(stdlink, x); MLEndPacket(stdlink); while (MLNextPacket(stdlink) != RETURNPKT) MLNewPacket(stdlink); MLGetDouble(stdlink, &result); MLDisownSymbol(stdlink, fname); return result; } but it does not work. The program gets stuck in an infinite loop or something. Also I'm not even sure if one sends pure functions to C programs or if there is another way of doing this. Thank you in advance. Kashif Rasul