Reputation: 300
I am converting some python numpy code into C++ code using xtensor library. I am having some issues in indexing based operations. Here is the python code:
boxes = decoded_boxes[keep, :]
keep
is a numpy boolean array of dimension [19248]
decoded_boxes
is a numpy array of dimensions [19248, 4]
boxes
(output) if a numpy array of dimensions [24, 4]
I am not able to write equivalent code for this. I tried this but did not work.
xt::xarray<float> b1 = xt::filter(decoded_boxes, keep);
std::cout << "b1 shape = " << xt::adapt(b1.shape()) << std::endl;
gives only {24}
.
Upvotes: 1
Views: 195
Reputation: 300
I was able to work around as follows:
auto id = xt::arange(decoded_boxes.shape()[0]);
auto b2 = xt::filter(id, keep);
xt::xarray<float> b1 = xt::view(decoded_boxes, xt::keep(b2)); // shape 24, 4
Upvotes: 1