[Rd] mean(x) for ALTREP

Gabe Becker becker.gabe at gene.com
Thu Apr 26 17:34:37 CEST 2018


The R 3.5.0 release includes the fundamental ALTREP framework but does not
include many 'hooks' within R's source code to make use of methods on the
ALTREP custom vector classes. I have implemented a fair number, including
for mean() to use the custom Sum method when available, in the ALTREP
branch but unfortunately we did not have time to test and port them to the
trunk in time for this release. The current plan, as I understand it, is
that we will continue to develop and test these, and other hooks, and then
when ready they will be ported into trunk/R-devel over the course this
current development cycle for inclusion in the next release of R.

My hope is that the end-user benefits of ALTREP will really show through
much more in future releases, but for now, things like mean will will
behave as they always have from a user perspective.


On Thu, Apr 26, 2018 at 2:31 AM, Serguei Sokol <sokol at insa-toulouse.fr>

> Hi,
> By looking at a doc about ALTREP https://svn.r-project.org/R/br
> anches/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.
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

Gabriel Becker, Ph.D
Bioinformatics and Computational Biology
Genentech Research

	[[alternative HTML version deleted]]

More information about the R-devel mailing list