<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/a5e8fb42c629d04a23cbf4074c167426"
  from="Siegfried Gonzi &lt;siegfried.gonzi@k...&gt;"
  author="Siegfried Gonzi"
  date="2002-07-08T12:09:14"
  subject="[Caml-list] Foreign function calls"
  prev="2002/07/8d12ac2d99463ad68064b36be9eba6e9"
  next="2002/07/4d3d90399b5d02aacc1097cf0afe66fd"
  prev-thread="2002/07/8d12ac2d99463ad68064b36be9eba6e9"
  next-thread="2002/07/7e2792e8388e42aaaa374716c37998e6"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Foreign function calls">
<msg 
  url="2002/07/a5e8fb42c629d04a23cbf4074c167426"
  from="Siegfried Gonzi &lt;siegfried.gonzi@k...&gt;"
  author="Siegfried Gonzi"
  date="2002-07-08T12:09:14"
  subject="[Caml-list] Foreign function calls">
</msg>
</thread>

<contents>
Hi,


I studied the manuals but didn't grasp it: how can I use the following 
subprogram (the get_mie() function) from OCaml:

==
#include &lt;stdio.h&gt;
#include &lt;stddef.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;math.h&gt;
#include "/home/gonzi/Wissenschaft/mie/complex.h"
#include "/home/gonzi/Wissenschaft/mie/nrutil.h"
#include "/home/gonzi/Wissenschaft/mie/bhmie.h"
#define mxnang 1000
#define nmxx 3000
#define CXONE Complex(1.0, 0.0)


void get_mie(float re_part, float im_part,float x, unsigned long 
nang,float* erg_s1_re,float* erg_s1_im,float* erg_s2_re,float* 
erg_s2_im, float* erg)
{
fcomplex cxref;
fcomplex cxs1[mxnang], cxs2[mxnang];
float pqext,pqsca,pqback,pgsca;
unsigned long i;

cxref=Complex(re_part,im_part);

/* function call */
bhmie(x, cxref, nang, cxs1, cxs2, &amp;pqext, &amp;pqsca, &amp;pqback, &amp;pgsca);


/* return values; the passed array pointers become updated*/
for (i=1; i&lt;=(2*nang-1); i++)
{
   erg_s1_re[i] = cxs1[i].r;
   erg_s1_im[i] = cxs1[i].i;
   erg_s2_re[i] = cxs2[i].r;
   erg_s2_im[i] = cxs2[i].i;
}
erg[0] = pqext;
erg[1] = pqsca;
erg[2] = pqback;
erg[3] = pgsca;
}
==


In Python I did it with SWIG (I took me as an absolute beginner in 
foreign function calls only an afternoon).


S. Gonzi
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

