Getting an array into a C program through mathlink
- To: mathgroup at smc.vnet.net
- Subject: [mg130141] Getting an array into a C program through mathlink
- From: Brentt <brenttnewman at gmail.com>
- Date: Thu, 14 Mar 2013 07:12:29 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
Hello, I've been wrestling with this example code from the manual to try to get a numerical array to a C program through mathlink. But how does one set up the template file for this kind of program (e.g. setting up a pattern to actually call the program in Mathematica)? I tried to guess how to write a template for this code, but nothing seemed to work (primarily errors about incompatible types). void f(MLINK lp) > { > double *data; > int *dims; > char **heads; > int d; /* stores the rank of the array */ > > if(! MLGetReal64Array(lp, &data, &dims, &heads, &d)) > { > /* unable to read the array from lp */ > return; > } > > /* ... */ > > MLReleaseReal64Array(lp, data, dims, heads, d); > } > I've got some functions using simple data types working using Mathlink, and I even go the MLPut*Array type functions working. It's just getting an array from mathematica in to an external (C) program that I haven't found much detailed information in the manual about. A lot of examples like these that aren't really functional as is. Thank you in advance