Eigen elements manipulation without loop

别来无恙 提交于 2019-12-11 03:35:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!