-
-
Notifications
You must be signed in to change notification settings - Fork 379
Open
Description
Summary:
A useful addition for simpler expressions with more complex indexing/subsetting would be to support logical indices. On the backend, this could just be syntactic sugar which first constructs an array of indices of the true values before passing to the existing indexing implementations.
C++ example:
template <typename EigVec>
inline auto rvalue(EigVec&& v, const char* name, std::vector<bool> lgl_idx) {
std::vector<int> idx;
for (int i = 0; i < lgl_idx.size(); i++) {
if (lgl_idx[i]) {
idx.push_back(i);
}
}
return rvalue(std::forward<EigVec>(v), name, index_multi(idx));
}A simpler alternative, we could add an std::vector<bool> constructor for index_multi which performs the same logic above.
This also has a bit of overlap with the use of bool-ish types in the Stan languages, so there might be some edge-case/interaction that I'm not thinking of. Thoughts?
Current Version:
v2.35.0
TeemuSailynoja, wds15 and jgabry
Metadata
Metadata
Assignees
Labels
No labels