Skip to content
Prev 9480 / 10988 Next

[Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

Good point. Actually, I didn't even realize there were so many is-nan 
functions to choose from. But indeed, we used the R-core ISNAN function 
on doubles accessed via Rcpp.
This was also pointed out by Bill Dunlap and indeed seems to be the 
explanation for the difference. Very unfortunate, because it was our 
most preferred ISNAN function. Seems that those "some C++ systems" ruin 
it for others.
Wow, thank you for the thorough comparison. I ran some tests myself 
based on your code. It seems that I cannot get the "CountNans_expr" 
version to compile, any ideas?  Same problem with the Rcpp sugar isnan 
version.

The std::isnan version, however, does work and, on my machine, actually 
outperforms the call function. So performance-wise this is a very 
interesting candidate. How safe is it to use this function? Would that 
also be a "driving-without-seatbelts" equivalent?