[Vegan-commits] r614 - pkg/vegan/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Dec 7 16:23:00 CET 2008
Author: jarioksa
Date: 2008-12-07 16:22:59 +0100 (Sun, 07 Dec 2008)
New Revision: 614
Modified:
pkg/vegan/R/permatswap.R
Log:
shaved off 15% running time in permatswap
Modified: pkg/vegan/R/permatswap.R
===================================================================
--- pkg/vegan/R/permatswap.R 2008-12-07 05:55:14 UTC (rev 613)
+++ pkg/vegan/R/permatswap.R 2008-12-07 15:22:59 UTC (rev 614)
@@ -11,6 +11,7 @@
} else {method <- match.arg(method, c("swap", "quasiswap", "tswap", "backtracking"))}
m <- as.matrix(m)
+ att <- attributes(m)
n.row <- nrow(m)
n.col <- ncol(m)
if (mtype == "prab") m <- ifelse(m > 0, 1, 0)
@@ -62,14 +63,13 @@
if (sum(perm[[i]][id,] > 0) != sum(m[id,] > 0)) {
tmp <- .C("rswapcount",
m = as.double(perm[[i]][id,]),
- as.integer(nrow(perm[[i]][id,])),
- as.integer(ncol(perm[[i]][id,])),
+ as.integer(n.row),
+ as.integer(n.col),
as.integer(sum(m[id,] > 0)),
PACKAGE="vegan")$m
- perm[[i]][id,] <- matrix(tmp, nrow(perm[[i]][id,]), ncol(perm[[i]][id,]))
+ attributes(perm[[i]][id,]) <- att
} else perm[[i]][id,] <- commsimulator(temp, method=method)
}
- thin <- burnin <- 0
}
} # for j end
specs <- list(reg=reg, hab=hab, burnin=burnin, thin=thin)
More information about the Vegan-commits
mailing list