[Rd] mean(x) for ALTREP
Serguei Sokol
sokol at insa-toulouse.fr
Thu Apr 26 11:31:47 CEST 2018
Hi,
By looking at a doc about ALTREP
https://svn.r-project.org/R/branches/ALTREP/ALTREP.html (by the way
congratulations for that and for R-3.5.0 in general), I was a little bit
surprised by the following example:
> x <- 1:1e10
> system.time(print(mean(x)))
[1] 5e+09
user system elapsed
38.520 0.008 38.531
Taking 38.520 s to calculate a mean value of an arithmetic sequence
seemed a lot to me. It probably means that calculations are made by
running into a for loop while in the case of arithmetic sequence a mean
value can simply be calculated as (b+e)/2 where b and e are the begin
and end value respectively. Is it planned to take benefit of ALTREP for
functions like mean(), sum(), min(), max() and some others to avoid
running a for loop wherever possible? It seems so natural to me but
after all some implementation details preventing this can escape to me.
Best,
Serguei.
More information about the R-devel
mailing list