[Mattice-commits] r81 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 12 04:46:45 CET 2008


Author: andrew_hipp
Date: 2008-12-12 04:46:45 +0100 (Fri, 12 Dec 2008)
New Revision: 81

Modified:
   pkg/R/regimes.R
Log:
started a recursive regMat function to call when n is large and maxNodes is small

Modified: pkg/R/regimes.R
===================================================================
--- pkg/R/regimes.R	2008-12-12 02:56:04 UTC (rev 80)
+++ pkg/R/regimes.R	2008-12-12 03:46:45 UTC (rev 81)
@@ -129,6 +129,9 @@
 }
 
 regimeMatrix <- function(n = NULL, nodeNames = NULL, regimeNames = NULL, maxNodes = NULL) {
+## a brute-force approach, very inefficient as n and maxNodes diverge
+## I think there's a recursive approach that would be efficient for small maxNodes, but it would probably be slower
+##   than this approach as maxNodes -> n
   if(identical(n, NULL) && identical(nodeNames, NULL)) stop("You have to give regimeMatrix the number of nodes, a vector of node names, or both")
   if(identical(nodeNames, NULL)) nodeNames <- as.character(seq(n))
   else n <- length(nodeNames)
@@ -147,6 +150,16 @@
   return(outmatrix)
 }
 
+#regMatRec <- function(n, maxNodes, dat) {
+#  for (i in 1:n) {
+#    call(regMatRec) with n = n - 1
+#    for (j in 1:dim(dat)[1]) {
+#      do something!
+#      }
+#    }
+#}
+    
+
 as.binary <- function(n, base = 2, r = FALSE, digits = NULL)
 # Robin Hankin <initialDOTsurname at soc.soton.ac.uk (edit in obvious way; spam precaution)>
 # submitted to R listserv Thu Apr 15 12:27:39 CEST 2004



More information about the Mattice-commits mailing list