[Rcpp-devel] Rcpp:integer class?

Dirk Eddelbuettel edd at debian.org
Tue Dec 21 18:33:38 CET 2010


On 21 December 2010 at 17:23, Cedric Ginestet wrote:
| 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?

Look at the Rcpp::Params class.

Dirk

 
| ###########################################
| 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
| 
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list