本征元素操作无循环 [英] Eigen elements manipulation without loop
本文介绍了本征元素操作无循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查矩阵中的元素是否小于零,然后再给它们赋零,在matlab中,它是使用以下方法完成的:
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?
推荐答案
您可以使用选择功能,类似于C中的三元?:
运算符。例如:
You can use the select function, which is similar to the ternary ?:
operator in C. For your example:
floatFrame = (floatFrame < 0).select(0, floatFrame)
这篇关于本征元素操作无循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文