From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA01970; Mon, 8 Jul 2002 14:09:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA02335 for caml-list@pauillac.inria.fr; Mon, 8 Jul 2002 14:09:13 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA00050 for ; Mon, 8 Jul 2002 11:57:46 +0200 (MET DST) Received: from jerry.kfunigraz.ac.at (GIGAJERRY.kfunigraz.ac.at [143.50.55.161]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g689vjv12665 for ; Mon, 8 Jul 2002 11:57:45 +0200 (MET DST) Received: from tom.kfunigraz.ac.at (mc_tom [10.10.1.160]) by jerry.kfunigraz.ac.at (8.11.2/8.11.2) with ESMTP id g689viP10875 for ; Mon, 8 Jul 2002 11:57:44 +0200 (MET DST) Received: from kfunigraz.ac.at (IGAM08AV.kfunigraz.ac.at [143.50.39.35]) by tom.kfunigraz.ac.at (8.11.2/8.11.2) with ESMTP id g689vio10398 for ; Mon, 8 Jul 2002 11:57:44 +0200 (MET DST) Message-ID: <3D29605A.7090400@kfunigraz.ac.at> Date: Mon, 08 Jul 2002 11:50:18 +0200 From: Siegfried Gonzi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Foreign function calls Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I studied the manuals but didn't grasp it: how can I use the following subprogram (the get_mie() function) from OCaml: == #include #include #include #include #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