Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at>
To: caml-list@inria.fr
Subject: [Caml-list] Foreign function calls
Date: Mon, 08 Jul 2002 11:50:18 +0200	[thread overview]
Message-ID: <3D29605A.7090400@kfunigraz.ac.at> (raw)

Hi,


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

==
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <math.h>
#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, &pqext, &pqsca, &pqback, &pgsca);


/* return values; the passed array pointers become updated*/
for (i=1; i<=(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


                 reply	other threads:[~2002-07-08 12:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D29605A.7090400@kfunigraz.ac.at \
    --to=siegfried.gonzi@kfunigraz.ac.at \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox