## Calculate ancestral likelihoods given a COO-like probability matrix

### Description

This function does a pass through a COO-like transition probability matrix for a node, inputting the probabilities that have been passed down from above for the left and right branch, and the sum of weights for each ancestral state, and returns the ancestral relative probabilities.

### Usage

rcpp_calc_anclikes_sp_using_COOprobs(Rcpp_leftprobs, Rcpp_rightprobs,
RCOO_left_i_list, RCOO_right_j_list, RCOO_probs_list, Rsp_rowsums,
printmat = TRUE)


### Arguments

 Rcpp_leftprobs Probabilities of the states at the base of the left descendant branch Rcpp_rightprobs Probabilities of the states at the base of the right descendant branch RCOO_left_i_list 0-based index of the allowed left states RCOO_right_j_list 0-based index of the allowed right states RCOO_probs_list Value of the specified nonzero cells Rsp_rowsums A vector of size (numstates) giving the sum of the relative probabilites of each combination of descendant states, assuming the probabilities of the left- and right-states are all equal (set to 1). This is thus the sum of the weights, and dividing by this normalization vector means that the each row of the speciation probability matrix will sum to 1. Default assumes the weights sum to 1 but this is not usually the case. Rsp_rowsums need only be calculated once per tree+model combination, stored, and then re-used for each node in the tree, yielding significant time savings. printmat Should the probability matrix output be printed to screen? (useful for debugging, but can be dramatically slow in R.app for some reason for even moderate numbers of states; perhaps overrunning the line length...)

### Details

This C++ implementation should be slightly faster than the R version, although for a simple pass through an array the difference may not be great.

### Value

R_anc_relprobs Vector of the probabilities of the ancestral states

### Author(s)

Nicholas Matzke matzke@berkeley.edu

rcpp_calc_anclikes_sp

rcpp_calc_anclikes_sp #bibliography /Dropbox/_njm/__packages/cladoRcpp_setup/cladoRcpp_refs.bib @cite Matzke_2013 @cite Matzke_2014

### Examples

# For the basic logic of a probablistic cladogenesis model, see
?rcpp_calc_anclikes_sp

# For examples of running the functions, see the comparison of all functions at: