]> git.donarmstrong.com Git - ape.git/commitdiff
faster rcoal... at last!
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 14 May 2009 08:19:05 +0000 (08:19 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 14 May 2009 08:19:05 +0000 (08:19 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@73 6e262413-ae40-0410-9e79-b911bd7a66b7

ChangeLog
DESCRIPTION
R/rtree.R

index d76cb8db266152314af17f8b51b17a2239a74428..9191a65ad570749ac6c449b469c9158c1624b841 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@ OTHER CHANGES
     o Instances of the form class(phy) == "phylo" have been replaced
       by inherits(phy, "phylo").
 
+    o rcoal() should be faster.
+
 
 
                CHANGES IN APE VERSION 2.3
index eeb4b873c1d9a45da60d8c14d2ec0e9a133d74db..54665c2b68ac86879d5005c2ad45fa24b0ff9d61 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
 Version: 2.3-1
-Date: 2009-05-10
+Date: 2009-05-13
 Title: Analyses of Phylogenetics and Evolution
 Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Gangolf Jobb, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
index 9425dadf22f5df689990e1ffe6a3829e3ce99c6b..f331ca3101f0472575ef35b6e92f3abf84021764 100644 (file)
--- a/R/rtree.R
+++ b/R/rtree.R
@@ -1,8 +1,8 @@
-## rtree.R (2008-05-07)
+## rtree.R (2000-05-13)
 
 ##   Generates Random Trees
 
-## Copyright 2004-2008 Emmanuel Paradis
+## Copyright 2004-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -113,7 +113,7 @@ rcoal <- function(n, tip.label = NULL, br = "coalescent", ...)
         edge.length <- rep(x, 2)
     } else if (n == 3) {
         edge[] <- c(4L, 5L, 5L, 4L, 5L, 1:3)
-        edge.length <- c(x[2], x[1], x[1], sum(x))
+        edge.length <- c(x[c(2, 1, 1)], sum(x))
     } else {
         edge.length <- numeric(nbr)
         h <- numeric(2*n - 1) # initialized with 0's
@@ -132,14 +132,15 @@ rcoal <- function(n, tip.label = NULL, br = "coalescent", ...)
         }
     }
     phy <- list(edge = edge, edge.length = edge.length)
-    phy$tip.label <-
-      if (is.null(tip.label)) paste("t", 1:n, sep = "")
-      else tip.label
+    if (is.null(tip.label))
+        tip.label <- paste("t", 1:n, sep = "")
+    phy$tip.label <- sample(tip.label)
     phy$Nnode <- n - 1L
     class(phy) <- "phylo"
-    ##reorder(phy)
+    phy <- reorder(phy)
     ## to avoid crossings when converting with as.hclust:
-    read.tree(text = write.tree(phy))
+    phy$edge[phy$edge[, 2] <= n, 2] <- 1:n
+    phy
 }
 
 rmtree <- function(N, n, rooted = TRUE, tip.label = NULL, br = runif, ...)