6 template <
typename VectorT>
7 VectorT fancySlice(
const VectorT& x,
const std::vector<int>& inds) {
8 VectorT out(inds.size());
9 for (
int i=0; i < inds.size(); ++i) out[i] = x[inds[i]];
13 template <
typename VectorT>
14 std::vector<int> flatnonzero(
const VectorT& x) {
16 for (
int i=0; i < x.size(); ++i)
if (x[i] != 0) out.push_back(i);