# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

calc_beta_cpp <- function(phy, upper_lim, algorithm, abs_tol, rel_tol) {
    .Call('_treestats_calc_beta_cpp', PACKAGE = 'treestats', phy, upper_lim, algorithm, abs_tol, rel_tol)
}

calc_beta_ltable_cpp <- function(ltable, upper_lim, algorithm, abs_tol, rel_tol) {
    .Call('_treestats_calc_beta_ltable_cpp', PACKAGE = 'treestats', ltable, upper_lim, algorithm, abs_tol, rel_tol)
}

branching_times_cpp <- function(phy) {
    .Call('_treestats_branching_times_cpp', PACKAGE = 'treestats', phy)
}

branching_times_ltable_cpp <- function(mat_in) {
    .Call('_treestats_branching_times_ltable_cpp', PACKAGE = 'treestats', mat_in)
}

calc_rho_complete_cpp <- function(phy) {
    .Call('_treestats_calc_rho_complete_cpp', PACKAGE = 'treestats', phy)
}

calc_rho_cpp <- function(phy) {
    .Call('_treestats_calc_rho_cpp', PACKAGE = 'treestats', phy)
}

calc_rho_ltable_cpp <- function(ltab) {
    .Call('_treestats_calc_rho_ltable_cpp', PACKAGE = 'treestats', ltab)
}

calc_phylodiv_cpp <- function(phy, t, extinct_acc) {
    .Call('_treestats_calc_phylodiv_cpp', PACKAGE = 'treestats', phy, t, extinct_acc)
}

calc_phylodiv_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_calc_phylodiv_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

calc_mean_branch_length_cpp <- function(edge_length) {
    .Call('_treestats_calc_mean_branch_length_cpp', PACKAGE = 'treestats', edge_length)
}

calc_mean_branch_length_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_calc_mean_branch_length_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

calc_gamma_cpp <- function(phy) {
    .Call('_treestats_calc_gamma_cpp', PACKAGE = 'treestats', phy)
}

calc_gamma_ltable_cpp <- function(ltab_in) {
    .Call('_treestats_calc_gamma_ltable_cpp', PACKAGE = 'treestats', ltab_in)
}

calc_nltt_cpp <- function(phy1, phy2) {
    .Call('_treestats_calc_nltt_cpp', PACKAGE = 'treestats', phy1, phy2)
}

calc_nltt_ltable_cpp <- function(ltab1, ltab2) {
    .Call('_treestats_calc_nltt_ltable_cpp', PACKAGE = 'treestats', ltab1, ltab2)
}

calc_crown_age_cpp <- function(phy) {
    .Call('_treestats_calc_crown_age_cpp', PACKAGE = 'treestats', phy)
}

calc_wiener_cpp <- function(edge_in, el, normalize, weight) {
    .Call('_treestats_calc_wiener_cpp', PACKAGE = 'treestats', edge_in, el, normalize, weight)
}

calc_max_betweenness_cpp <- function(edge_in, el) {
    .Call('_treestats_calc_max_betweenness_cpp', PACKAGE = 'treestats', edge_in, el)
}

calc_max_betweenness_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_max_betweenness_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_max_closeness_cpp <- function(edge_in, el, weight) {
    .Call('_treestats_calc_max_closeness_cpp', PACKAGE = 'treestats', edge_in, el, weight)
}

calc_diameter_cpp <- function(edge_in, el, weight) {
    .Call('_treestats_calc_diameter_cpp', PACKAGE = 'treestats', edge_in, el, weight)
}

calc_diameter_ltable_cpp <- function(l_from_R, weight) {
    .Call('_treestats_calc_diameter_ltable_cpp', PACKAGE = 'treestats', l_from_R, weight)
}

calc_colless_cpp <- function(parent_list, normalization) {
    .Call('_treestats_calc_colless_cpp', PACKAGE = 'treestats', parent_list, normalization)
}

calc_colless_ltable_cpp <- function(l_from_R, normalization) {
    .Call('_treestats_calc_colless_ltable_cpp', PACKAGE = 'treestats', l_from_R, normalization)
}

calc_eWcolless_cpp <- function(parent_list) {
    .Call('_treestats_calc_eWcolless_cpp', PACKAGE = 'treestats', parent_list)
}

calc_eWcolless_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_eWcolless_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

ILnumber_cpp <- function(tree_edge) {
    .Call('_treestats_ILnumber_cpp', PACKAGE = 'treestats', tree_edge)
}

ILnumber_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_ILnumber_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

calc_rquartet_cpp <- function(tree_edge) {
    .Call('_treestats_calc_rquartet_cpp', PACKAGE = 'treestats', tree_edge)
}

calc_rquartet_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_calc_rquartet_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

stairs_cpp <- function(tree_edge) {
    .Call('_treestats_stairs_cpp', PACKAGE = 'treestats', tree_edge)
}

stairs_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_stairs_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

stairs2_cpp <- function(tree_edge) {
    .Call('_treestats_stairs2_cpp', PACKAGE = 'treestats', tree_edge)
}

stairs2_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_stairs2_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

calc_rogers_cpp <- function(parent_list) {
    .Call('_treestats_calc_rogers_cpp', PACKAGE = 'treestats', parent_list)
}

calc_rogers_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_rogers_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_j_one_cpp <- function(parent_list) {
    .Call('_treestats_calc_j_one_cpp', PACKAGE = 'treestats', parent_list)
}

calc_j_one_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_j_one_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_Ibased_cpp <- function(parent_list) {
    .Call('_treestats_calc_Ibased_cpp', PACKAGE = 'treestats', parent_list)
}

calc_Ibased_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_Ibased_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

pitchforks_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_pitchforks_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

calc_colless_corr_cpp <- function(parent_list, normalization) {
    .Call('_treestats_calc_colless_corr_cpp', PACKAGE = 'treestats', parent_list, normalization)
}

calc_colless_corr_ltable_cpp <- function(l_from_R, normalization) {
    .Call('_treestats_calc_colless_corr_ltable_cpp', PACKAGE = 'treestats', l_from_R, normalization)
}

calc_colless_quad_cpp <- function(parent_list, normalization) {
    .Call('_treestats_calc_colless_quad_cpp', PACKAGE = 'treestats', parent_list, normalization)
}

calc_colless_quad_ltable_cpp <- function(l_from_R, normalization) {
    .Call('_treestats_calc_colless_quad_ltable_cpp', PACKAGE = 'treestats', l_from_R, normalization)
}

calc_root_imbalance_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_root_imbalance_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_double_cherries_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_double_cherries_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_four_prong_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_four_prong_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

check_is_binary_rcpp <- function(parent_list) {
    .Call('_treestats_check_is_binary_rcpp', PACKAGE = 'treestats', parent_list)
}

calc_max_del_width_cpp <- function(parent_list) {
    .Call('_treestats_calc_max_del_width_cpp', PACKAGE = 'treestats', parent_list)
}

calc_max_del_width_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_max_del_width_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_max_width_cpp <- function(parent_list) {
    .Call('_treestats_calc_max_width_cpp', PACKAGE = 'treestats', parent_list)
}

calc_max_width_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_max_width_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_max_depth_cpp <- function(parent_list) {
    .Call('_treestats_calc_max_depth_cpp', PACKAGE = 'treestats', parent_list)
}

calc_avg_vert_depth_cpp <- function(parent_list) {
    .Call('_treestats_calc_avg_vert_depth_cpp', PACKAGE = 'treestats', parent_list)
}

tot_internal_path_cpp <- function(parent_list) {
    .Call('_treestats_tot_internal_path_cpp', PACKAGE = 'treestats', parent_list)
}

calc_max_depth_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_max_depth_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_var_leaf_depth_cpp <- function(parent_list) {
    .Call('_treestats_calc_var_leaf_depth_cpp', PACKAGE = 'treestats', parent_list)
}

calc_var_leaf_depth_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_var_leaf_depth_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_sym_nodes_cpp <- function(parent_list) {
    .Call('_treestats_calc_sym_nodes_cpp', PACKAGE = 'treestats', parent_list)
}

calc_b1_cpp <- function(parent_list) {
    .Call('_treestats_calc_b1_cpp', PACKAGE = 'treestats', parent_list)
}

calc_b1_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_b1_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_b2_cpp <- function(parent_list) {
    .Call('_treestats_calc_b2_cpp', PACKAGE = 'treestats', parent_list)
}

calc_b2_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_b2_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_mw_over_md_cpp <- function(parent_list) {
    .Call('_treestats_calc_mw_over_md_cpp', PACKAGE = 'treestats', parent_list)
}

calc_mw_over_md_ltable_cpp <- function(l_from_R) {
    .Call('_treestats_calc_mw_over_md_ltable_cpp', PACKAGE = 'treestats', l_from_R)
}

calc_root_imbalance_cpp <- function(parent_list) {
    .Call('_treestats_calc_root_imbalance_cpp', PACKAGE = 'treestats', parent_list)
}

avgLadder_cpp <- function(tree_edge) {
    .Call('_treestats_avgLadder_cpp', PACKAGE = 'treestats', tree_edge)
}

max_ladder_cpp <- function(tree_edge) {
    .Call('_treestats_max_ladder_cpp', PACKAGE = 'treestats', tree_edge)
}

get_eigen_values_arma_cpp <- function(phy) {
    .Call('_treestats_get_eigen_values_arma_cpp', PACKAGE = 'treestats', phy)
}

prep_adj_mat <- function(parent_list, br_len, use_br_len) {
    .Call('_treestats_prep_adj_mat', PACKAGE = 'treestats', parent_list, br_len, use_br_len)
}

outer_cpp <- function(xx, x, sd) {
    .Call('_treestats_outer_cpp', PACKAGE = 'treestats', xx, x, sd)
}

calc_mpd_cpp <- function(edge, el) {
    .Call('_treestats_calc_mpd_cpp', PACKAGE = 'treestats', edge, el)
}

calc_var_mpd_cpp <- function(phy) {
    .Call('_treestats_calc_var_mpd_cpp', PACKAGE = 'treestats', phy)
}

calc_mntd_cpp <- function(phy) {
    .Call('_treestats_calc_mntd_cpp', PACKAGE = 'treestats', phy)
}

calc_mntd_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_calc_mntd_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

calc_inv_path_cpp <- function(edge, el, add_one) {
    .Call('_treestats_calc_inv_path_cpp', PACKAGE = 'treestats', edge, el, add_one)
}

#' Function to generate an ltable from a phy object.
#' @description This function is a C++
#' implementation of the function DDD::phylo2L. An L table summarises a
#' phylogeny in a table with four columns, being: 1) time at which a species
#' is born, 2) label of the parent of the species, where positive and negative
#' numbers indicate whether the species belongs to the left or right crown
#' lineage, 3) label of the daughter species itself (again positive or
#' negative depending on left or right crown lineage), and the last column 4)
#' indicates the time of extinction of a species, or -1 if the species is
#' extant.
#' @param phy phylo object
#' @return ltable (see description)
#' @export
#' @examples
#' simulated_tree <- ape::rphylo(n = 4, birth = 1, death = 0)
#' ltable <- phylo_to_l(simulated_tree)
#' reconstructed_tree <- DDD::L2phylo(ltable)
#' old_par <- par()
#' par(mfrow = c(1, 2))
#' # trees should be more or less similar, although labels may not match, and
#' # rotations might cause (initial) visual mismatches
#' plot(simulated_tree)
#' plot(reconstructed_tree)
#' par(old_par)
phylo_to_l <- function(phy) {
    .Call('_treestats_phylo_to_l', PACKAGE = 'treestats', phy)
}

l_to_newick <- function(ltable_R, drop_extinct) {
    .Call('_treestats_l_to_newick', PACKAGE = 'treestats', ltable_R, drop_extinct)
}

imbalance_steps_cpp <- function(ltable_R, normalization) {
    .Call('_treestats_imbalance_steps_cpp', PACKAGE = 'treestats', ltable_R, normalization)
}

Ax_tree <- function(edge, lengths, x, nNodes) {
    .Call('_treestats_Ax_tree', PACKAGE = 'treestats', edge, lengths, x, nNodes)
}

Lx_tree_weighted <- function(edge, w, x, nNodes) {
    .Call('_treestats_Lx_tree_weighted', PACKAGE = 'treestats', edge, w, x, nNodes)
}

calc_sackin_cpp <- function(tree_edge, normalization) {
    .Call('_treestats_calc_sackin_cpp', PACKAGE = 'treestats', tree_edge, normalization)
}

calc_sackin_ltable_cpp <- function(ltab, normalization) {
    .Call('_treestats_calc_sackin_ltable_cpp', PACKAGE = 'treestats', ltab, normalization)
}

calc_tot_coph_cpp <- function(tree_edge) {
    .Call('_treestats_calc_tot_coph_cpp', PACKAGE = 'treestats', tree_edge)
}

calc_tot_coph_ltable_cpp <- function(ltab) {
    .Call('_treestats_calc_tot_coph_ltable_cpp', PACKAGE = 'treestats', ltab)
}

calc_blum_cpp <- function(tree_edge, normalize) {
    .Call('_treestats_calc_blum_cpp', PACKAGE = 'treestats', tree_edge, normalize)
}

calc_blum_ltable_cpp <- function(ltab_in, normalize) {
    .Call('_treestats_calc_blum_ltable_cpp', PACKAGE = 'treestats', ltab_in, normalize)
}

cherries_cpp <- function(tree_edge) {
    .Call('_treestats_cherries_cpp', PACKAGE = 'treestats', tree_edge)
}

calc_double_cherries_cpp <- function(tree_edge) {
    .Call('_treestats_calc_double_cherries_cpp', PACKAGE = 'treestats', tree_edge)
}

calc_four_prong_cpp <- function(tree_edge) {
    .Call('_treestats_calc_four_prong_cpp', PACKAGE = 'treestats', tree_edge)
}

cherries_ltable_cpp <- function(ltable_R) {
    .Call('_treestats_cherries_ltable_cpp', PACKAGE = 'treestats', ltable_R)
}

pitchforks_cpp <- function(tree_edge) {
    .Call('_treestats_pitchforks_cpp', PACKAGE = 'treestats', tree_edge)
}

