MathGroup Archive 2013

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

Search the Archive

Getting an array into a C program through mathlink

  • To: mathgroup at
  • Subject: [mg130141] Getting an array into a C program through mathlink
  • From: Brentt <brenttnewman at>
  • Date: Thu, 14 Mar 2013 07:12:29 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

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

  • Prev by Date: Re: Greek symbols mangled by InputForm
  • Next by Date: Re: Query regarding Function
  • Previous by thread: Re: Visible mesh edges in PDF output of 3D graphic
  • Next by thread: Front end text formatting - fraction font size and text in tables