[Phylobase-commits] r922 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 9 20:30:29 CEST 2014
Author: francois
Date: 2014-04-09 20:30:28 +0200 (Wed, 09 Apr 2014)
New Revision: 922
Modified:
pkg/src/checkPhylo4.cpp
Log:
fixed bug in getAllNodesFast (result shouldn't depend on whether the tree is rooted, just on presence of 0 in edge matrix), commented variables not used anymore.
Modified: pkg/src/checkPhylo4.cpp
===================================================================
--- pkg/src/checkPhylo4.cpp 2014-04-08 21:23:25 UTC (rev 921)
+++ pkg/src/checkPhylo4.cpp 2014-04-09 18:30:28 UTC (rev 922)
@@ -130,17 +130,18 @@
}
//[[Rcpp::export]]
-Rcpp::IntegerVector getAllNodesFast (Rcpp::IntegerMatrix edge, bool rooted) {
+Rcpp::IntegerVector getAllNodesFast (Rcpp::IntegerMatrix edge) {
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;
+ Rcpp::IntegerVector ans;
+ if (maxN[0] == 0) {
+ ans = Rcpp::seq_len(maxN[1] + 1);
+ ans = ans - 1;
}
else {
- ans.erase(0);
- return ans - 1;
+ ans = Rcpp::seq_len(maxN[1]);
}
+ return ans;
}
@@ -287,7 +288,7 @@
Rcpp::IntegerVector ances = getAnces(ed);
//Rcpp::IntegerVector desc = getDesc(ed);
int nroots = nRoots(ances);
- bool rooted = nroots > 0;
+ //bool rooted = nroots > 0;
Rcpp::NumericVector edLength = obj.slot("edge.length");
Rcpp::CharacterVector edLengthNm = edLength.names();
Rcpp::CharacterVector label = obj.slot("label");
@@ -295,10 +296,10 @@
Rcpp::CharacterVector edLabel = obj.slot("edge.label");
Rcpp::CharacterVector edLabelNm = edLabel.names();
Rcpp::IntegerVector allnodesSafe = getAllNodesSafe(ed);
- Rcpp::IntegerVector allnodesFast = getAllNodesFast(ed, rooted);
+ Rcpp::IntegerVector allnodesFast = getAllNodesFast(ed);
int nEdLength = edLength.size();
- int nLabel = label.size();
- int nEdLabel = edLabel.size();
+ //int nLabel = label.size();
+ //int nEdLabel = edLabel.size();
int nEdges = nrow;
bool hasEdgeLength = !all_naC(edLength);
More information about the Phylobase-commits
mailing list