From hb at stat.berkeley.edu  Mon May 14 11:35:15 2007
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Mon, 14 May 2007 02:35:15 -0700
Subject: [Rd] Native implementation of rowMedians()
In-Reply-To: <17992.7115.324752.778339@stat.math.ethz.ch>
References: <59d7961d0705132114j7f8261e0oc25cfe7379cbb0e7@mail.gmail.com>
	<17992.7115.324752.778339@stat.math.ethz.ch>
Message-ID: <59d7961d0705140235m5ac98fd1qd8403812326c71d6@mail.gmail.com>

On 5/14/07, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
> Hi Henrik,
> >>>>> "HenrikB" == Henrik Bengtsson <hb at stat.berkeley.edu>
> >>>>>     on Sun, 13 May 2007 21:14:24 -0700 writes:
>
>     HenrikB> Hi,
>     HenrikB> I've got a version of rowMedians(x, na.rm=FALSE) for matrices that
>     HenrikB> handles missing values implemented in C.  It has been optimized for
>     HenrikB> memory and speed.  To avoid coercing integers to doubles, and hence
>     HenrikB> allocate an additional 200% memory, there is one C function for
>     HenrikB> integers and one for doubles.
>
>     HenrikB> The rowMedians() implementation is currently sitting in my non-CRAN
>     HenrikB> package R.native available by:
>
>     HenrikB> source("http://www.braju.com/R/hbLite.R")
>     HenrikB> hbLite("R.native")
>     HenrikB> library(R.native)
>     HenrikB> example(rowMedians)
>
>     HenrikB> The source code package is available at:
>
>     HenrikB> http://www.braju.com/R/repos/R.native_0.1.2.tar.gz
>
>     HenrikB> Before I submit a package to CRAN consisting of pretty much just
>     HenrikB> rowMedians(), would it make more sense for it to go into one of the
>     HenrikB> core packages?  If so, how should I proceed?
>
> As they say: You have to convince at least one member of R-core
> that ``it's worth it''.  {Then he may have to bear the battle
> with dissenting core members  ;- }
>
> I'm quite interested, but really you have to do the work of unbundling
> it from all the R.oo stuff before I have another longer look.

Great.  The R code without R.oo (that's what it does), will be

rowMedians.matrix <- function(x, na.rm=FALSE, ...) {
  .Call("rowMedians", x, as.logical(na.rm), PACKAGE="R.native");
}

rowMedians <- function(...) UseMethod("rowMedians", ...)

and the C code is in src/rowMedians.c, and the doc in
man/rowMedians.matrix.R (all in
http://www.braju.com/R/repos/R.native_0.1.2.tar.gz).

Thanks

Henrik

PS. I'll be off email until Friday (US time). DS.


>
> Martin
>



[Rd] Native implementation of rowMedians()
Henrik Bengtsson