本文整理汇总了C++中rcpp::NumericVector::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ NumericVector::erase方法的具体用法?C++ NumericVector::erase怎么用?C++ NumericVector::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcpp::NumericVector
的用法示例。
在下文中一共展示了NumericVector::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collapse_single_cpp
//[[Rcpp::export]]
Rcpp::List collapse_single_cpp(
Rcpp::IntegerVector ances,
Rcpp::IntegerVector desc,
Rcpp::NumericVector elen,
Rcpp::NumericVector nnode,
Rcpp::LogicalVector show_progress) {
int n_singles = n_singletons(ances);
std::vector<int> tab_node = tabulate_tips(ances);
Rcpp::IntegerVector tab_node_rcpp(tab_node.size());
tab_node_rcpp = tab_node;
Rcpp::IntegerVector position_singleton = which_integer(tab_node_rcpp, Rcpp::IntegerVector::create(1));
Rcpp::IntegerVector position_singleton_orig = position_singleton;
RProgress::RProgress pb("Progress [:bar] :current/:total (:percent) :eta", (double) n_singles, 60);
if (show_progress) {
pb.tick(0);
}
while (position_singleton.size() > 0) {
// Rcpp::Rcout << "tabNode is ";
// for (unsigned k = 0; k < tabNode.size(); ++k)
// Rcpp::Rcout << " " << tabNode[k];
// Rcpp::Rcout << std::endl;
// Rcpp::Rcout << "position singleton is ";
// for (unsigned k = 0; k < positionSingleton.size(); ++k)
// Rcpp::Rcout << " " << positionSingleton[k];
// Rcpp::Rcout << std::endl;
int i = position_singleton[0];
Rcpp::IntegerVector iV(1);
iV = i;
//Rcpp::Rcout << "i is " << i << " and iV is " << iV << std::endl;
Rcpp::IntegerVector prev_node = which_integer(desc, iV + 1);
Rcpp::IntegerVector next_node = which_integer(ances, iV + 1);
//Rcpp::Rcout << "prev_node is " << prev_node << " and next_node is " << next_node << std::endl;
//Rcpp::Rcout << "before desc:";
//for (unsigned k = 0; k < desc.size(); ++k)
// Rcpp::Rcout << " " << desc[k];
//Rcpp::Rcout << std::endl;
desc[prev_node] = desc[next_node];
//Rcpp::Rcout << "after desc:";
//for (unsigned k = 0; k < desc.size(); ++k)
// Rcpp::Rcout << " " << desc[k];
//Rcpp::Rcout << std::endl;
Rcpp::IntegerVector to_rm = which_integer(ances, iV + 1);
//Rcpp::Rcout << "to_rm is " << to_rm << std::endl;
desc.erase(to_rm[0]);
ances.erase(to_rm[0]);
desc = match_and_substract(desc, iV);
ances = match_and_substract(ances, iV);
nnode = nnode - 1;
if (elen.size() > 0) {
elen[prev_node] = elen[prev_node] + elen[next_node];
elen.erase(next_node[0]);
}
tab_node = tabulate_tips(ances);
tab_node_rcpp(tab_node.size());
tab_node_rcpp = tab_node;
position_singleton = which_integer(tab_node_rcpp, Rcpp::IntegerVector::create(1));
if (show_progress) {
pb.tick();
}
}
Rcpp::List res = Rcpp::List::create(
Rcpp::Named("ances") = ances,
Rcpp::Named("desc") = desc,
Rcpp::Named("Nnode") = nnode,
Rcpp::Named("edge.length") = elen,
Rcpp::Named("position_singletons") = position_singleton_orig);
return res;
}