[Vegan-commits] r1839 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Sep 12 16:02:52 CEST 2011
Author: jarioksa
Date: 2011-09-12 16:02:52 +0200 (Mon, 12 Sep 2011)
New Revision: 1839
Modified:
pkg/vegan/R/commsimulator.R
pkg/vegan/inst/ChangeLog
Log:
smaller overhead in commsimulator, but the effects on timing may be small
Modified: pkg/vegan/R/commsimulator.R
===================================================================
--- pkg/vegan/R/commsimulator.R 2011-09-12 14:02:13 UTC (rev 1838)
+++ pkg/vegan/R/commsimulator.R 2011-09-12 14:02:52 UTC (rev 1839)
@@ -4,6 +4,7 @@
method <- match.arg(method,
c("r0","r1","r2","r00","c0","swap", "tswap",
"backtrack", "quasiswap"))
+ x <- as.matrix(x)
if (any(x > 1))
x <- ifelse(x > 0, 1, 0)
nr <- nrow(x)
@@ -23,7 +24,6 @@
else if (method == "r00") {
out <- numeric(nr*nc)
out[sample(length(out), sum(x))] <- 1
- dim(out) <- dim(x)
}
else if (method == "c0") {
cs <- colSums(x)
@@ -31,22 +31,17 @@
for (j in 1:nc)
out[sample(nr, cs[j]), j] <- 1
} else if (method == "swap") {
- x <- as.matrix(x)
out <- .C("swap", m = as.integer(x), as.integer(nrow(x)),
as.integer(ncol(x)), as.integer(thin),
PACKAGE = "vegan")$m
- dim(out) <- dim(x)
} else if (method == "tswap") {
- x <- as.matrix(x)
out <- .C("trialswap", m = as.integer(x), as.integer(nrow(x)),
as.integer(ncol(x)), as.integer(thin),
PACKAGE = "vegan")$m
- dim(out) <- dim(x)
} else if (method == "quasiswap") {
out <- r2dtable(1, rowSums(x), colSums(x))[[1]]
out <- .C("quasiswap", m = as.integer(out), as.integer(nrow(x)),
as.integer(ncol(x)), PACKAGE = "vegan")$m
- dim(out) <- dim(x)
}
else if (method == "backtrack") {
fill <- sum(x)
@@ -94,7 +89,6 @@
out <- oldout
}
}
- colnames(out) <- colnames(x)
- rownames(out) <- rownames(x)
+ attributes(out) <- attributes(x)
out
}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2011-09-12 14:02:13 UTC (rev 1838)
+++ pkg/vegan/inst/ChangeLog 2011-09-12 14:02:52 UTC (rev 1839)
@@ -7,6 +7,11 @@
* New major version opened with the release of vegan_2.0-0 on
September 8, 2011.
+ * commsimulator: a bit less overhead -- all attributes set
+ simultaneously instead of setting separately dim, rownames and
+ colnames. The results should be identical(), running should be
+ marginally faster or neutral.
+
* permatswap: there was a bug in internal C routine, and therefore
not all permissible swaps were performed. Based on limited
analysis, the effects of this bug seem to be negligible. It is,
More information about the Vegan-commits
mailing list