search for: narm_

Displaying 2 results from an estimated 2 matches for "narm_".

Did you mean: narm
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...ch is supported by the fact that summing over 'z' is costs half of 'y'. Now, I *cannot* reproduce the above using the following 'inline' example: > sum2 <- inline::cfunction(sig=c(x="double", narm="logical"), body=' double *x_ = REAL(x); int narm_ = asLogical(narm); int n = length(x); double sum = 0; for (R_xlen_t i = 0; i < n; i++) { if (!narm_ || !ISNAN(x_[i])) sum += x_[i]; } return ScalarReal(sum); ') > x <- rep(0, 1e8) > stopifnot(typeof(x) == "double") > system.time(sum2(x, narm=FALSE)) user sy...
2015 Jun 01
0
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
.../nmath.h#L28-L33), whereas my sum2() code uses double. So using long double, I can reproduce the penalty of having NA_real_ with na.rm=FALSE; > sum3 <- inline::cfunction(sig=c(x="double", narm="logical"), body=' #define LDOUBLE long double double *x_ = REAL(x); int narm_ = asLogical(narm); int n = length(x); LDOUBLE sum = 0.0; for (R_xlen_t i = 0; i < n; i++) { if (!narm_ || !ISNAN(x_[i])) sum += x_[i]; } return ScalarReal((double)sum); ') > x <- rep(0, 1e8) > stopifnot(typeof(x) == "double") > system.time(sum3(x, narm=FALSE))...