parsim.c - tree evaluation
Version Tag $Id: parsim.c,v 1.35 2006/02/06 19:55:46 db60 Exp $
long getplen(const Branch *const barray, const long root, unsigned char **bmat, unsigned char **scratch, const long m, const long n, const long *weights);
Calculates the length of a tree using Fitch parsimony. In LVB, a large amount of time is spent in this function.
Pointer to the first element of the array containing the tree to be evaluated.
Index of the root of the tree to be evaluated. barray
[root
] is
the root.
Pointer to the first element in an array of pointers, each of which
points to a row in the binary-encoded data matrix that will be used to
calculate the length of the tree. bmat
[0..n
-1] must point to the
first elements of encoded rows for objects 0..n
-1 respectively.
bmat
is not const-qualified, since it is necessarily accessed
through non-const-qualified pointers.
The number of columns (bases) in the encoded data matrix.
The number of objects in the tree, which is also the number of rows (objects) in the encoded data matrix.
Pointer to first element of an m-element array giving the weights of the sites. For each site, each change is counted the number of times given in the corresponding element of this array. For no weighting, each element of the array should be 1.
scratch
must point to an array of n
-2 pointers, each of which
must point to an allocated m
-element array of unsigned char. Arrays
accessible through scratch
are used for temporary storage and have
meaningless contents on return.
Returns total changes in all characters for the tree accessed through
barray
, according to the data matrix accessed through bmat
.