]> git.donarmstrong.com Git - ape.git/blob - R/additive.R
changes in reorder(, "cladewise")
[ape.git] / R / additive.R
1 ## additive.R (2011-10-11)
2
3 ##   Incomplete Distance Matrix Filling
4
5 ## Copyright 2011 Andrei-Alin Popescu
6
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
9
10 .addit_ultra <- function(libs, X)
11 {
12     if (is.matrix(X)) X <- as.dist(X)
13     X[is.na(X)] <- -1
14     X[X < 0] <- -1
15     X[is.nan(X)] <- -1
16     N <- attr(X, "Size")
17     labels <- attr(X, "Labels")
18     if (is.null(labels)) labels <- as.character(1:N)
19     m <- sum(X == -1)
20     ans <- .C(libs, as.double(X), as.integer(N),
21               as.integer(m), double(N*N), PACKAGE = "ape")
22     matrix(ans[[4]], N, N)
23 }
24
25 additive <- function(X) .addit_ultra("additive", X)
26
27 ultrametric <- function(X) .addit_ultra("ultrametric", X)