From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id CE0DBBC0A for ; Mon, 4 Jun 2007 09:37:46 +0200 (CEST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.180]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l547bie3008368 for ; Mon, 4 Jun 2007 09:37:45 +0200 Received: by wa-out-1112.google.com with SMTP id m34so1694512wag for ; Mon, 04 Jun 2007 00:37:44 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=DXpJICxS448RicQsL6126gF5+N+IvfunooTP90hvfW5QyvlA4RzRZ629WLMHsSx+q3OmUIXU9CErupbcn8odAqB2wYzqALdVA66esOTTwmnBbuMdb9IIo9D3JmsGhDx1E10lAfVISpUj9D41Fq7H/SUO/T3ynjIgL2pFtM+9v7U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=HlaC+Jcz8lMt+mhLSNouAcQYIsh8GnDB9qbvzMKZLRRFCaWog/kxfTOAQUMZVinTH7uJO7jNJEcGVjuhIfXLlg4NsL2XJde5mRYCBVIXRfuDed7gTEBO8SS4Ee63ZUMBkn2S5nlBuUD8gtEF2u4cETQ9hcN0XJRxrAPB97nn394= Received: by 10.114.24.1 with SMTP id 1mr4520360wax.1180942664236; Mon, 04 Jun 2007 00:37:44 -0700 (PDT) Received: by 10.115.60.4 with HTTP; Mon, 4 Jun 2007 00:37:44 -0700 (PDT) Message-ID: <9f09a07a0706040037gf551211ubcddcafe496a6c1d@mail.gmail.com> Date: Mon, 4 Jun 2007 09:37:44 +0200 From: "Matthieu Dubuget" To: caml-list@inria.fr Subject: Re: [Caml-list] nonlinear fit function binding In-Reply-To: <7625D6A1880B4C4DA11D2EBB8B43D2B90282F387@FRDEF-EXMB03.europe.am.socgen> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_20850_3107816.1180942664203" References: <7625D6A1880B4C4DA11D2EBB8B43D2B90282F387@FRDEF-EXMB03.europe.am.socgen> X-j-chkmail-Score: MSGID : 4663C148.000 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 4663C148.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; matthieu:01 dubuget:01 matthieu:01 dubuget:01 bigarrays:01 wrappers:01 params:01 bigarray:01 bigarray:01 bigarrays:01 ocaml:01 ocaml:01 wrappers:01 params:01 caml-list:01 ------=_Part_20850_3107816.1180942664203 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks for your reply, Rabih. 2007/5/31, RABIH.ELCHAAR@sgam.com : > > I did a wrapping of the levmar library. > Unfortunately, since I am to use this in a commercial product, and I was not able (yet ?) to convince my boss to release the sources, I can't use with levmar, wich is GPLed... I may switch to cminpack. But i think this is not related to my current question. The approach I chose is to allocate bigarrays from Caml, and pass them to > the main C function, along with the function f. > Does it mean that each time f function is called by the minimization, the C wrappers has to copy the params C array into your Bigarray pre-allocated storage place? That's why I choosed to leave the C array untouched and wrap a Bigarray around it (should not be a big amount of memory). Am I wrong in going this way? In the main function, I register f and all the bigarrays as global roots, > and then call as many times the c sub function to compute the minimization. I do not understand this part. f is passed to the main (C) function from OCaml: why do you need to register it as a global root? Same question for the Bigarrays? Does it mean that else, nothing in OCaml world would point to them? > > Feel free to ask for more precisions if needed > > Hope this helps. > Surely. I really need to acquire a better understanding of GC and C interface in OCaml. Really, I do not understand what happens to those C allocated Bigarrays... Salutations Matthieu ------=_Part_20850_3107816.1180942664203 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks for your reply, Rabih.

2007/5/31, RABIH.ELCHAAR@sgam.com <RABIH.ELCHAAR@sgam.com>:

I did a wrapping of the levmar library.


Unfortunately, since I am to use this in a commercial product, and I was not able (yet ?) to convince my boss to release the sources, I can't use with levmar, wich is GPLed... I may switch to cminpack. But i think this is not related to my current question.

The approach I chose is to allocate bigarrays from Caml, and pass them to the main C function, along with the function f.

Does it mean that each time f function is called by the minimization, the C wrappers has to copy the params C array into your Bigarray pre-allocated storage place? That's why I choosed to leave the C array untouched and wrap a Bigarray around it  (should not be a big amount of memory). Am I wrong in going this way?

In the main function, I register f and all the bigarrays as global roots, and then call as many times the c sub function to compute the minimization.

I do not understand this part. f is passed to the main (C) function from OCaml: why do you need to register it as a global root? Same question for the Bigarrays? Does it mean that else, nothing in OCaml world would point to them?  

Feel free to ask for more precisions if needed

Hope this helps.

Surely. I really need to acquire a better understanding of GC and C interface in OCaml.
Really, I do not understand what happens to those C allocated Bigarrays...

Salutations

Matthieu

------=_Part_20850_3107816.1180942664203--