<div class="gmail_extra"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Thell Fowler</b> <span dir="ltr"><<a href="mailto:tbfowler4@gmail.com">tbfowler4@gmail.com</a>></span><br>
Date: Sun, Apr 22, 2012 at 11:18 AM<br>Subject: Re: [Rcpp-devel] Example of rcpp usage with Rmpfr, mpfr, gmp.<br>To: Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>><br><br><br><div class="gmail_extra">
<br><br><div class="gmail_quote"><div class="im">On Sun, Apr 22, 2012 at 10:49 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Hi Thell,<br>
<div><br>
On 22 April 2012 at 10:17, Thell Fowler wrote:</div><br></blockquote></div><div>--- >8 ---<br> <br></div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div>
| Simple and straight forward...<br>
|<br>
| My two use cases are:<br>
|<br>
| 1)  Pass input as 'numeric', convert to multiprecision 160-bit, do<br>
| calculations using multiprecision lgamma values, and return an mpfr array<br>
| object.<br>
| 2)  Pass input as mpfr objects (list or array), do calculations, and return<br>
| the modified values.<br>
|<br>
| Any examples or direction on how (if I can) to get to a Rcpp Rmpfr bridge with<br>
| speed would go a long way...<br>
<br>
</div>Sounds fine. Not sure how to return (or pass down) the mpfr arrays. But you may be able to<br>
look at the existing CRAN packages wrapping mpfr for ideas.<br>
<br></blockquote><div> </div></div><div>I'll try reading through  the Rmpfr source to see how it does its' magic.<br>Also, the Bessel package depends on Rmpfr so that might yield some ideas.<br><br></div><div class="im">
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

As a really simple minded idea, you can<br>
<br>
   1) use Rcpp to pass values from R down to a C/C++ layer<br>
 <br></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
   2) "cast" or copy your values into mpfr et al types, do you computations<br>
   and get the result, cast/copy it back to C/C++<br>
<br>
   3) use Rcpp to communicate back up<br>
<br>
which is pretty standard use of Rcpp to call external libraries or<br>
packages. Many of the CRAN packages using Rcpp do something similar.<br>
<br></blockquote><div> </div></div><div>I'll take a closer look at how this works.<br>At first thought I wonder what the function sig would use for the type?  Some sort of 'raw' type ?<br><br></div><div class="im">
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

You just need to add the required -I and -L flags to src/Makevars and you<br>
should be fine. [ Higher-end solutions use configure, or pkg-config, or<br>
... to find those values. Harcoded may work on standard Linux systems. ]<br>
<br></blockquote><div> </div></div><div>That part _should_ be pretty straight forward.<br><br></div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

[ And if you want to look into doing more of an integration (a la RcppArmadillo,<br>
RcppGSL, RcppEigen, ...), then the Rcpp-extending vignette shows you how to<br>
modify as<>() and wrap() to get automatic converters going.  But you surely<br>
don't need to do this for a first attempt to compute your stuff. I just<br>
mention it as you say 'R mpfr bridge' -- this would be the Rcpp way of doing<br>
it. ]<br>
<br>
Cheers, Dirk<br>
<span><font color="#888888"><br></font></span></blockquote><div> <br clear="all"></div></div></div>The Rcpp-extending vignette is what I originally thought would be the answer.<br>Good thing I asked first! ;)<span class="HOEnZb"><font color="#888888"><br>

<br>-- <br>Sincerely,<br>Thell<br>
</font></span></div>
</div><br><br clear="all"><br>-- <br>Sincerely,<br>Thell<br>
</div>