Hi Guys -- I have re-written aperm (from R-1.1.1) and I was going to call
it Aperm and bundle it with my tensor library, as it uses strides (like in
Python). But there might be some interest in including it in the base.
It is about 6 times quicker:
[starting R]
> library(tensor)
> tmp <- array(1:prod(1:10), 1:10)
> system.time(Aperm(tmp, c(3, 2, 1, 4:10)))
[1] 5.09 0.11 5.20 0.00 0.00> system.time(aperm(tmp, c(3, 2, 1, 4:10)))
[1] 32.89 0.15 33.04 0.00 0.00
[starting R]
> library(tensor)
> tmp <- array(1:prod(1:10), 1:10)
> system.time(aperm(tmp, c(3, 2, 1, 4:10)))
[1] 32.85 0.18 33.03 0.00 0.00> system.time(Aperm(tmp, c(3, 2, 1, 4:10)))
[1] 5.03 0.18 5.21 0.00 0.00
While studying the original aperm code (R-1.1.1) I noticed an error: there
is a missing break after the final case in the TYPEOF(a) switch before the
default which means that if anyone did call aperm with an array of VECSXP
then it would not complete:
> tmp <- array(list(3), c(2, 3))
> tmp[[2, 3]] <- "fred"
> tmp
[,1] [,2] [,3]
[1,] "Numeric,1" "Numeric,1" "Numeric,1"
[2,] "Numeric,1" "Numeric,1"
"Character,1"> aperm(tmp)
Error in aperm(a, perm, resize) : invalid argument> Aperm(tmp)
[,1] [,2]
[1,] "Numeric,1" "Numeric,1"
[2,] "Numeric,1" "Numeric,1"
[3,] "Numeric,1" "Character,1"
Cheers, Jonathan.
Jonathan Rougier Science Laboratories
Department of Mathematical Sciences South Road
University of Durham Durham DH1 3LE
tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._