[Rcpp-devel] Inf to NA.

Cedric Ginestet c.ginestet05 at googlemail.com
Tue Dec 21 18:24:10 CET 2010


Dear Rcpp experts,

When passing a vector/argument with infinite values to a C++ function, 
the R wrapper returns NA's. [See the code below] Is there a way around 
this to ensure that infinite values are preserved from R to C++ and then 
from C++ to R again?

######################################
D <- matrix(c(0,1,Inf,Inf),2,2)
src3 <- '
   IntegerMatrix xD(D);
   IntegerVector Drow(xD.ncol());
   for(int i=0; i<xD.ncol(); i++) std::cout << xD[1,i] << std::endl;
return xD;
'
rowExtraction <- 
cxxfunction(signature(D="matrix"),body=src3,plugin="Rcpp",verbose=TRUE)
rowExtraction(D)
######################################

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/47219b3e/attachment-0001.htm>


More information about the Rcpp-devel mailing list