Skip to content

Commit

Permalink
minor updates on ignore and utils
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjie2wang committed Nov 16, 2019
1 parent 8c5da3a commit 44be9c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -30,3 +30,4 @@ TAGS
GTAGS
GRTAGS
GPATH
.clang_complete
20 changes: 5 additions & 15 deletions src/utils.h
Expand Up @@ -100,24 +100,14 @@ namespace Intsurv {
return arma::conv_to<arma::uvec>::from(res);
}
// function that returns the indices of the first unique indices
inline arma::uvec find_first_unique(const arma::vec& x,
bool fromLast = false)
inline arma::uvec find_first_unique(const arma::vec& x)
{
std::unordered_set<double> seen;
std::vector<unsigned int> res;
if (fromLast) {
for (size_t i {1}; i <= x.n_rows; ++i) {
if (seen.insert(x(x.n_rows - i)).second) {
// if duplicated, add index to vector res
res.push_back(i);
}
}
} else {
for (size_t i {0}; i < x.n_rows; ++i) {
if (seen.insert(x(i)).second) {
// if duplicated, add index to vector res
res.push_back(i);
}
for (size_t i {0}; i < x.n_rows; ++i) {
if (seen.insert(x(i)).second) {
// if duplicated, add index to vector res
res.push_back(i);
}
}
return arma::conv_to<arma::uvec>::from(res);
Expand Down

0 comments on commit 44be9c1

Please sign in to comment.