dpilger26 / NumCpp

C++ implementation of the Python Numpy library
https://dpilger26.github.io/NumCpp
MIT License
3.51k stars 548 forks source link

The formula gives an error, how can I change it? #189

Closed YoungjaeDev closed 1 year ago

YoungjaeDev commented 1 year ago

The below expression gives an error Looking at the code, I want to pick out all the items whose column 5 is i, but it seems that an error occurs on the operator side. How can I not do that?

func (std::vector<std::vector<float>>& obj_list)

nc::NdArray<float> nd_predictions{obj_list}

for (int i = 0; i < class_num; i++)
{
auto [rowIndices, _] = (nd_predictions(nd_predictions.rSlice(), 5) == i).nonzero(); //error 
...
}
dpilger26 commented 1 year ago

You are trying to compare floats and ints and there isn't an operator == defined for that. You could change it to static_cast<float>(i).