当前位置: 首页>>代码示例>>C++>>正文


C++ IntegerVector::erase方法代码示例

本文整理汇总了C++中rcpp::IntegerVector::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ IntegerVector::erase方法的具体用法?C++ IntegerVector::erase怎么用?C++ IntegerVector::erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcpp::IntegerVector的用法示例。


在下文中一共展示了IntegerVector::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nTipsFastCpp

//[[Rcpp::export]]
int nTipsFastCpp (Rcpp::IntegerVector ances) {
// if nodes are correctly numbered min(ances) - 1 = nb of tips
// (after removing the root, which is equal to 0).
    int nroots = nRoots(ances);
    if (nroots > 0) {
	int whichRoot = Rcpp::which_min(ances);
	ances.erase(whichRoot);
    }
    int tmp = Rcpp::min(ances);
    return tmp - 1;
}
开发者ID:rforge,项目名称:phylobase,代码行数:12,代码来源:checkPhylo4.cpp

示例2: getAllNodesFast

//[[Rcpp::export]]
Rcpp::IntegerVector getAllNodesFast (Rcpp::IntegerMatrix edge, bool rooted) {
    Rcpp::IntegerVector tmp = Rcpp::as_vector(edge);
    Rcpp::IntegerVector maxN = Rcpp::range(tmp);
    Rcpp::IntegerVector ans = Rcpp::seq_len(maxN[1] + 1);
    if (rooted) {
	return ans - 1;
    }
    else {
	ans.erase(0);
	return ans - 1;
    }
}
开发者ID:rforge,项目名称:phylobase,代码行数:13,代码来源:checkPhylo4.cpp

示例3: 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;
}
开发者ID:cran,项目名称:rncl,代码行数:79,代码来源:collapse_singles.cpp


注:本文中的rcpp::IntegerVector::erase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。