[Rcpp-devel] Rcpp:integer class?

Cedric Ginestet c.ginestet05 at googlemail.com
Tue Dec 21 18:23:19 CET 2010


Dear Rcpp experts,

I am trying to find a way a single integer to a function. See the code 
below. I am here obliged to translage v1 as an IntegerVector and then to 
select only its first argument. Is there a better way of doing this, 
where I don't have to declare an entire vector for such a task?

###########################################
src2 <- '
*IntegerVector x1(v1); *
   IntegerMatrix xD(D);
   IntegerVector Drow(xD.ncol());
   for(int i=0; i<xD.ncol(); i++) Drow[i]=xD(*x1[0]*,i);
return Drow;
'
rowExtraction <- 
cxxfunction(signature(D="matrix",v1="integer"),body=src2,plugin="Rcpp",verbose=TRUE)
rowExtraction(D,1)
############################################

Thank you very much,
Cedric


-- 
Cedric Ginestet
Centre for Neuroimaging Sciences (L3.04)
NIHR Biomedical Research Centre
Department of Neuroimaging
Institute of Psychiatry, Box P089
King's College London
De Crespigny Park
London
SE5 8AF
Tel: (+44) 20-3228-3052
Fax: (+44) 20-3228-2116
Email: cedric.ginestet at kcl.ac.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101221/a3cfb65b/attachment.htm>


More information about the Rcpp-devel mailing list