[Mono-devel-list] Mono and GSL
bsuss_ca at yahoo.ca
bsuss_ca at yahoo.ca
Mon Mar 24 22:35:42 EST 2003
Hi,
I've been playing around with getting Mono to work
with the Gnu Scientific
Library (GSL). I have figured out how to marshall
double functions and complex
functions that return doubles. However, I have not
been able to get functions
to return complex values. My successes are
illustrated below and might be
useful to someone. My failure can be noted by
uncommenting the comment. If you
have any clue about how to get this to work, it would
be much appreciated.
The complex number is a C struct that looks like:
>>
typedef struct
{
double dat[2];
} gsl_complex;
<<
Thanks for any help or suggestions!
Here's my sample code:
>>
using System;
using System.Runtime.InteropServices;
class GSL
{
[DllImport("libgsl")]
static extern double gsl_sf_bessel_J0(double x);
[DllImport("libgsl")]
static extern double gsl_complex_abs( complex z);
[DllImport("libgsl")]
static extern complex gsl_complex_sin (complex z);
public struct complex
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public double[] dat;
complex(double re, double im)
{
this.dat=new double[] {re,im};
}
}
public static void test()
{
Console.WriteLine(gsl_sf_bessel_J0(0.0));
complex c1;
c1.dat=new double[] {3,4};
Console.WriteLine(gsl_complex_abs(c1));
complex c2;
c2=gsl_complex_sin(c1);
Console.WriteLine(c1.dat[0]);
//Console.WriteLine(c2.dat[0]);
}
}
class Tester
{
static void Main()
{
GSL.test();
}
}
<<
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
More information about the Mono-devel-list
mailing list