Re: Using a Mathematica's function in a C program
- To: mathgroup at smc.vnet.net
- Subject: [mg31268] Re: Using a Mathematica's function in a C program
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 26 Oct 2001 04:28:07 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <9r57cm$s3o$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, here is a function that request the numerical evaluation of n function values of mathFuncSymbol[x1,x2,x3] for a list {x1,x2,x3,y1,y2,y3,....} @=:Evaluate: MapNApply[fun_Symbol,l_List]:=Map[N[Apply[fun,#]] &,l] @>@| void GetFValuesFromMath(char *mathFuncSymbol,double *f, point3d *p, int n) { double *vptr; int i; long cnt; MLPutFunction(stdlink,"EvaluatePacket",1L); MLPutFunction(stdlink,"MapNApply",2L); MLPutSymbol(stdlink,mathFuncSymbol); MLPutFunction(stdlink,"List",n); for(i=0; i<n; i++) MLPutRealList(stdlink,(double *)(p+i),3L); while(MLNextPacket(stdlink) !=RETURNPKT) MLNewPacket(stdlink); MLGetRealList(stdlink,&vptr,&cnt); memcpy(f,vptr,cnt*sizeof(double)); MLDisownRealList(stdlink,vptr,cnt); for(i=0; i<n; i++) f[i]-=c; } and mathFuncSymbol[] is send to the top level ML function. Regards Jens Julie RIGAUD wrote: > > Hi ! > I'm using Mathlink with a C program. > Is it possible to declare a function in Mathematica and use and evaluate it in the C program ? > (for the moment, i'm trying to resolve my problem by using MLGetFunction( ) but it doesn't seem to work ...) > Thanks a lot for your response. > Julie > >