问题
I want to check if the elements of my matrix are smaller than zero then I want to assign zero to them, in matlab it was done using this:
ind = find(floatFrame < 0);
floatFrame(ind) = 0;
Is there any equivalent for Eigen matrices?
回答1:
You can use the select function, which is similar to the ternary ?:
operator in C. For your example:
floatFrame = (floatFrame < 0).select(0, floatFrame)
来源:https://stackoverflow.com/questions/25766754/eigen-elements-manipulation-without-loop