<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#c0c0c0">
Thanks Dirk. I was hoping for an example of the use of R functions in
Rcpp and did take a look at your Journal of Statistical software paper
but was hoping for more than is there on this issue. <br>
Maybe someone can post a full example.<br>
<br>
On a different issue, I tried the inline example in your JSS paper on
my Windows 7 machine after loading the inline library<br>
<br>
src = ' <br>
Rcpp::NumericVector xa(a);<br>
Rcpp::NumericVector xb(b);<br>
int n_xa = xa.size(), n_xb = xb.size();<br>
<br>
Rcpp::NumericVector xab(n_xa + n_xb - 1);<br>
for (int i = 0; i < n_xa; i++)<br>
for (int j = 0; j < n_xb; j++)<br>
xab[i + j] += xa[i] * xb[j];<br>
return xab;<br>
'<br>
fun <- cxxfunction(signature(a = "numeric", b = "numeric"),<br>
src, plugin = "Rcpp")<br>
<br>
R> fun(1:3, 1:4)<br>
<br>
and got the following error message<br>
<br>
Error in system(cmd, intern = !verbose) : 'C:/Program' not found<br>
<span class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span
class="Apple-style-span"
style="font-family: 'Lucida Console'; font-size: 21px; line-height: 27px; white-space: pre-wrap;"><br>
What could the problem be?<br>
<br>
Thanks in advance on both scores.<br>
<br>
Siddhartha.<br>
</span></span><br>
On 4/23/2011 9:25 PM, Dirk Eddelbuettel wrote:
<blockquote cite="mid:19891.35328.302886.48323@max.nulle.part"
type="cite">
<pre wrap="">
On 23 April 2011 at 21:05, Dirk Eddelbuettel wrote:
|
| On 23 April 2011 at 20:36, Siddhartha Chib wrote:
| | This is likely to be too simple a question perhaps. How does one use specific
| | functions from other packages when working with Rcpp? For that matter, is it
| | possible to use R functions such as optim in Rcpp?
|
| Yes, sure. I don't think we have a great example though.
[...]
| A concise example would be good. Maybe another list member has something?
PS This may be obvious too, but let's just state it plainly to be sure: in
iterative optimisation, if you repeatedly go back between R and C++ you
are likely to give up a bunch of the speed gain Rcpp can otherwise offer.
There are other tricks one can use to access the _C_ part of certain R
functions. Frequent list contributor Davor had done some nice work getting
at the inner (C language) part of loess(); that is now also in a CRAN
package 'rgam' which uses Rcpp and RcppArmdillo:
<a class="moz-txt-link-freetext" href="http://cran.r-project.org/web/packages/rgam/index.html">http://cran.r-project.org/web/packages/rgam/index.html</a>
Hope this helps, Dirk
</pre>
</blockquote>
<br>
</body>
</html>