THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

t(): faster implementation without using aperm() [#22]

feature/c
Henrik Bengtsson 4 months ago
parent
commit
bc8ed0627f
  1. 9
      R/aperm.R

9
R/aperm.R

@ -81,7 +81,14 @@ t.listenv <- function(x) {
attr(x, "dim.") <- c(1L, dim)
attr(x, "dimnames.") <- list(NULL, attr(x, "dimnames.")[[1]])
} else if (ndim == 2L) {
x <- aperm(x, perm = 2:1)
dim <- rev(dim)
idxs <- matrix(seq_len(prod(dim)), nrow = dim[1], ncol = dim[2], byrow = TRUE)
map <- mapping(x)
map <- map[idxs]
mapping(x) <- map
map <- NULL
attr(x, "dim.") <- dim
attr(x, "dimnames.") <- rev(attr(x, "dimnames."))
} else {
stop("Argument 'x' is not a matrix")
}

Loading…
Cancel
Save