Ah! I had all the latest versions on my office computer and forgot to update my laptop as well (which had Rcpp from 0.8.6. from 9/2010 or so).<div><br></div><div>Thanks.</div><div>Chris<br><br><div class="gmail_quote">On Wed, May 18, 2011 at 9:07 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org">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;"><div><div></div><div class="h5"><br>
On 18 May 2011 at 08:42, Chris DuBois wrote:<br>
| Hi all,<br>
|<br>
| I've copied the following from a portion of the "Using matrices" section of the<br>
| Rcpp Quick Reference guide. I get a compilation error that I'm having trouble<br>
| decoding. Commenting out the third line allows it to compile, so it must be<br>
| something I've done wrong with the column selector, but I don't see it. <br>
|<br>
| Thanks in advance,<br>
| Chris<br>
|<br>
| PS. My g++ version is 4.5.2, in case that helps.<br>
|<br>
| src <- '<br>
| NumericMatrix xx(4, 5);<br>
| std::fill(xx.begin(), xx.end(), 8);<br>
| NumericMatrix::Column zzcol = xx( _, 1);<br>
| return(wrap(1));<br>
| '<br>
| fun <- cxxfunction(signature(x="numeric"), body = src, plugin="Rcpp")<br>
|<br>
| file3011595e.cpp:35:39: error: invalid conversion from ‘SEXPREC*’ to<br>
| ‘int’<br>
| file3011595e.cpp:35:39: error: initializing argument 1 of ‘Rcpp::Matrix<br>
| <RTYPE>::Proxy Rcpp::Matrix<RTYPE>::operator()(int, int) [with int RTYPE = 14,<br>
| Rcpp::Matrix<RTYPE>::Proxy = double&]’<br>
| file3011595e.cpp:35:39: error: conversion from ‘Rcpp::traits::storage_type<br>
| <14>::type’ to non-scalar type ‘Rcpp::Matrix<14>::Column’ requested<br>
| make: *** [file3011595e.o] Error 1<br>
<br>
</div></div>Works for me:<br>
<br>
R> src <- '<br>
<div class="im">+ NumericMatrix xx(4, 5);<br>
+ std::fill(xx.begin(), xx.end(), 8);<br>
+ NumericMatrix::Column zzcol = xx( _, 1);<br>
+ return(wrap(1));<br>
</div>+ '<br>
R> fun <- cxxfunction(signature(x="numeric"), body = src, plugin="Rcpp")<br>
R> fun(4.44)<br>
[1] 1<br>
R><br>
<br>
Are you by chance using an ancient Rcpp version?<br>
<br>
Dirk<br>
<font color="#888888"><br>
--<br>
Gauss once played himself in a zero-sum game and won $50.<br>
-- #11 at <a href="http://www.gaussfacts.com" target="_blank">http://www.gaussfacts.com</a><br>
</font></blockquote></div><br></div>