[Rcpp-devel] Selecting rows and columns of matrices

Chris DuBois chris.dubois at gmail.com
Wed May 18 17:42:34 CEST 2011


Hi all,

I've copied the following from a portion of the "Using matrices" section of
the Rcpp Quick Reference
guide<http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-quickref.pdf>.
 I get a compilation error that I'm having trouble decoding.  Commenting out
the third line allows it to compile, so it must be something I've done wrong
with the column selector, but I don't see it.

Thanks in advance,
Chris

PS. My g++ version is 4.5.2, in case that helps.

src <- '
NumericMatrix xx(4, 5);
std::fill(xx.begin(), xx.end(), 8);
NumericMatrix::Column zzcol = xx( _, 1);
return(wrap(1));
 '
fun <-  cxxfunction(signature(x="numeric"), body = src, plugin="Rcpp")

file3011595e.cpp:35:39: error: invalid conversion from ‘SEXPREC*’ to ‘int’
file3011595e.cpp:35:39: error:   initializing argument 1 of
‘Rcpp::Matrix<RTYPE>::Proxy Rcpp::Matrix<RTYPE>::operator()(int, int) [with
int RTYPE = 14, Rcpp::Matrix<RTYPE>::Proxy = double&]’
file3011595e.cpp:35:39: error: conversion from
‘Rcpp::traits::storage_type<14>::type’ to non-scalar type
‘Rcpp::Matrix<14>::Column’ requested
make: *** [file3011595e.o] Error 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110518/284ad17a/attachment.htm>


More information about the Rcpp-devel mailing list