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=0.3 required=5.0 tests=AWL,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 7D64FBB84 for ; Thu, 3 Jul 2008 19:29:03 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AngBANGobEjRVcbjf2dsb2JhbACCPzSPEUMBAQsFAgYHEZk3hVM X-IronPort-AV: E=Sophos;i="4.27,743,1204498800"; d="scan'208";a="26995518" Received: from rv-out-0506.google.com ([209.85.198.227]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Jul 2008 19:29:02 +0200 Received: by rv-out-0506.google.com with SMTP id f6so964866rvb.3 for ; Thu, 03 Jul 2008 10:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=MfK8RoPMKQ5+SpsYlDR0EfTs1s4TWOFt8t7AlRjSTcA=; b=eOTlsXslHD3C5jgefIA/Ut7B2dyrdj6ROtwjDBDDN1U/UQwIJxk7thcgE6HXv7HRwZ NNigfN31IGGiBMD7gtMoh1kETUAyRAnOQlJgNvuuNqvgQ9vRlnGGf+PqzRuPIhMaxmwG bS5HcddG4XrxgPmqBhSOdjp3AuDDKT+6mfmM8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=eFJNTIVe5iECZ0Zi53dcDDMb2USypI+0Q4yvpdTQiWd6XA6wtinqDcQRPG8wJJKZnu Iz3s2Fzh2Dd7jTIWFMRb4qzH/cugOLFWKYXvLElHImZW+2zerPbTIDX/orecby6YZ8nu gr8hkITeFMHDNhzlmbeEdl940SD3l7DNPVGkw= Received: by 10.140.207.2 with SMTP id e2mr50806rvg.187.1215106140772; Thu, 03 Jul 2008 10:29:00 -0700 (PDT) Received: by 10.141.19.4 with HTTP; Thu, 3 Jul 2008 10:29:00 -0700 (PDT) Message-ID: Date: Thu, 3 Jul 2008 13:29:00 -0400 From: "Ashish Agarwal" To: "Peng Zhang" Subject: Re: [Caml-list] Re: call ocaml from R Cc: caml-list@yquem.inria.fr In-Reply-To: <6999988a0807030821r1e11d042yd61b42dedd538620@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_18095_7774652.1215106140747" References: <6999988a0806241917p3d26a170s5ecfc8925e9d5e5d@mail.gmail.com> <6999988a0807030821r1e11d042yd61b42dedd538620@mail.gmail.com> X-Spam: no; 0.00; ocaml:01 ocaml:01 stub:01 mlvalues:01 alloc:01 val:01 beginner's:01 bug:01 stub:01 mlvalues:01 alloc:01 val:01 beginner's:01 bug:01 1975:98 ------=_Part_18095_7774652.1215106140747 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline There was some discussion about this on the main list, but there was no clear answer. http://groups.google.com/group/fa.caml/browse_thread/thread/46ad55d2102c1898/b92a26b04ce70c5d?lnk=gst&q=R#b92a26b04ce70c5d On Thu, Jul 3, 2008 at 11:21 AM, Peng Zhang wrote: > Is it at all possible? > > Following the manual, I know I can call ocaml when C is the main > program. I want to compile C file to Dynamic-link library, and call it > from R. > > Can somebody help to answer it? > > Thanks, > Peng > > On Tue, Jun 24, 2008 at 10:17 PM, Peng Zhang wrote: > > Hi folks, > > > > I need some help from you. What I want to do is that my main program > > is in R and I want to implement part of it with ocaml. > > > > The following is an example. > > > > /* mysin.R */ > > dyn.load("mysin.so") > > mysin <- function(x) > > .C("mysin", as.double(x), r = double(1))$r > > > > /* mycode.ml */ > > let sin_ml x = sin x > > let _ = Callback.register "sin_ml" sin_ml > > > > I want to use sin defined in mycode.ml in mysin.R > > > > Then I write the following stub code > > > > /* mysin.c */ > > #include > > #include > > #include > > #include > > #include > > > > void mysin(double * x, double * r){ > > value * closure_f; > > caml_startup(NULL); > > closure_f = caml_named_value("sin_ml"); > > *r = Double_val(caml_callback(*closure_f, caml_copy_double(*x))); > > } > > > > It isn't working right now. What I am not sure about is what to put in > > caml_startup. > > > > Can somebody help with me this? Thank you very much! > > > > Best, > > Peng > > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > ------=_Part_18095_7774652.1215106140747 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline There was some discussion about this on the main list, but there was no clear answer.

http://groups.google.com/group/fa.caml/browse_thread/thread/46ad55d2102c1898/b92a26b04ce70c5d?lnk=gst&q=R#b92a26b04ce70c5d



On Thu, Jul 3, 2008 at 11:21 AM, Peng Zhang <pczhang@gmail.com> wrote:
Is it at all possible?

Following the manual, I know I can call ocaml when C is the main
program. I want to compile C file to Dynamic-link library, and call it
from R.

Can somebody help to answer it?

Thanks,
Peng

On Tue, Jun 24, 2008 at 10:17 PM, Peng Zhang <pczhang@gmail.com> wrote:
> Hi folks,
>
> I need some help from you. What I want to do is that my main program
> is in R and I want to implement part of it with ocaml.
>
> The following is an example.
>
> /* mysin.R */
> dyn.load("mysin.so")
> mysin <- function(x)
>  .C("mysin", as.double(x), r = double(1))$r
>
> /* mycode.ml */
> let sin_ml x = sin x
> let _ = Callback.register "sin_ml" sin_ml
>
> I want to use sin defined in mycode.ml in mysin.R
>
> Then I write the following stub code
>
> /* mysin.c */
> #include <caml/mlvalues.h>
> #include <caml/memory.h>
> #include <caml/alloc.h>
> #include <caml/custom.h>
> #include <caml/callback.h>
>
> void mysin(double * x, double * r){
>  value * closure_f;
>  caml_startup(NULL);
>  closure_f = caml_named_value("sin_ml");
>  *r = Double_val(caml_callback(*closure_f, caml_copy_double(*x)));
> }
>
> It isn't working right now. What I am not sure about is what to put in
> caml_startup.
>
> Can somebody help with me this? Thank you very much!
>
> Best,
> Peng
>

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

------=_Part_18095_7774652.1215106140747--