MathGroup Archive 2009

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

Search the Archive

Re: Problems using MathLink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg95271] Re: Problems using MathLink
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 14 Jan 2009 05:51:04 -0500 (EST)
  • References: <gkgq0p$48v$1@smc.vnet.net>

Hi,

you are sure that your array has the depth 3 and not
the dimension 3 x 3, and what is the third dimension
in a[3][3] ..

BTW, you never delete[] heads,dims.
If you wish to fill your main memory you should
use larger pieces of memory
that you don't recycle, you are faster done than.

Regards
   Jens

Jonathan Yik wrote:
> Hi,
> 
> I'm trying to write a subroutine in C++ that passes a rotation matrix to
> Mathematica through MathLink.  The code compiles fine, but when I try to run
> the compiled program, I get a segfault at the point in the program where the
> subroutine is called.  As far as I can tell, the fault occurs whenever the
> program calls MLPutRealArray or MLPutReal32Array.
> 
> Here is my code for the subroutine:
> 
> void rot(MLINK link, double theta)
> {
>   char **heads, **HEAD;
>   heads = new char*[3];
>   heads[0] = "List";
>   heads[1] = "List";
>   heads[2] = "List";
>   double a[3][3], *b;
>   a[0][0] = cos(theta);
>   a[0][1] = sin(theta);
>   a[0][2] = 0;
>   a[1][0] = - sin(theta);
>   a[1][1] = cos(theta);
>   a[1][2] = 0;
>   a[2][0] = 0;
>   a[2][1] = 0;
>   a[2][2] = 1;
>   long *dims, *D, depth;
>   dims = new long[3];
>   dims[0] = 3;
>   dims[1] = 3;
>   dims[2] = 3;
>   MLPutRealArray(link, *a, dims, heads, 3);
> }
> 
> Is there something in this code that I'm missing that causes the fault?  Or
> is this a but in the ml32i3.dll file?
> 
> Yours,
> 
> Johnathan Yik


  • Prev by Date: Re: Automatic Numbering in Mathematica
  • Next by Date: Re: Solving nonlinear coupled differential equations in Mathematica
  • Previous by thread: Re: undefined function
  • Next by thread: Re: Problems using MathLink