1 ## treePop.R (2011-10-11)
3 ## Tree Reconstruction With the Triangles Method
5 ## Copyright 2011 Andrei-Alin Popescu
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
10 triangMtd <- function(X)
12 if (is.matrix(X)) X <- as.dist(X)
14 stop("missing values are not allowed in the distance matrix")
16 labels <- attr(X, "Labels")
17 if (is.null(labels)) labels <- as.character(1:N)
18 ans <- .C("triangMtd", as.double(X), as.integer(N), integer(2*N - 3),
19 integer(2*N - 3), double(2*N - 3),
20 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
21 obj <- list(edge = cbind(ans[[3]], ans[[4]]), edge.length = ans[[5]],
22 tip.label = labels, Nnode = N - 2L)
27 triangMtds <- function(X)
29 if (is.matrix(X)) X <- as.dist(X)
33 labels <- attr(X, "Labels")
34 if (is.null(labels)) labels <- as.character(1:N)
35 ans <- .C("triangMtds", as.double(X), as.integer(N), integer(2*N - 3),
36 integer(2*N - 3), double(2*N - 3),
37 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
38 obj <- list(edge = cbind(ans[[3]], ans[[4]]), edge.length = ans[[5]],
39 tip.label = labels, Nnode = N - 2L)