[Rd] speed up R_IsNA, R_IsNaN for vector input
j@goreck| @end|ng |rom w|t@edu@p|
Sun Sep 29 13:09:55 CEST 2019
Dear R developers,
I spotted that R_isNA and R_IsNaN could be improved when applied on a
vector where we could take out small part of their logic, run it once,
and then reuse inside the loop.
I setup tiny plain-C experiment. Taking R_IsNA, R_IsNaN from R's
arithmetic.c, and building R_vIsNA and R_vIsNaN accordingly.
For double input of size 1e9 (having some NA and NaN) I observed
It looks like R_vIsN(A|aN) are close to ISNAN (which just wraps to
Should I follow up with a patch?
The experiment is a single nan.c file of 127 lines (includes R C
funs). Large enough to not paste in the email. Here is the link:
Run it as:
gcc nan.c -lm
./a.out R_vIsNA 8
./a.out R_IsNA 8
./a.out R_vIsNaN 8
./a.out R_IsNaN 8
./a.out ISNAN 8
More information about the R-devel