renjin icon indicating copy to clipboard operation
renjin copied to clipboard

apply rowwise max is very slow

Open thorstenwagner opened this issue 7 years ago • 4 comments

The following command needs for a 65700x2 matrix more than 30 seconds in renjin.

apply(fprob[1:nrow(fprob),],1,max)

Here is the fprob object: maxslowRData.zip

In R it is done in a couple of seconds. I'm using Renjin 0.8.2356

What is the reason?

Best, Thorsten

thorstenwagner avatar May 10 '17 09:05 thorstenwagner

Good question! The indexing on fprob might be getting deferred... in which case it's possible something is going wrong. Will check it out. Thanks for the benchmark!

akbertram avatar May 10 '17 09:05 akbertram

Any progress here? At the moment this is really a bottle neck for me :-( Or are there any alternative to do it faster?

thorstenwagner avatar Aug 02 '17 13:08 thorstenwagner

Try pmax(fprob[,1], fprob[,2]) since it looks like your trying to find the largest value in each row.

If the number of columns is variable, you can do

do.call(pmax, lapply(seq(ncol(fprob)), function(col) fprob[,col]))

mjkallen avatar Aug 03 '17 06:08 mjkallen

Thanks! This works perfectly!!!

thorstenwagner avatar Aug 03 '17 11:08 thorstenwagner