问题遇到的现象和发生背景
在使用Eigen库时,使用了动态矩阵;但在一处判断时需要将这个矩阵中的其中一个数与外界(double)进行判断,此时没法直接进行判断,自己上网查了很久也没有找到合理的解决方法。
用代码块功能插入代码,请勿粘贴截图
double rand_num;
rand_num=rand()/2;
if(rand_num{、
}
运行结果及报错内容
E:\C_BTIESI\code_output\opt_cal\charge_pile_dis\charge_pile_dis.cpp:161: error: invalid operands to binary expression ('double' and 'typename internal::enable_if::value && internal::traits::type>::ReturnAsIndexedView, typename IndexedViewType::type>::type' (aka 'Eigen::IndexedView, double, Eigen::internal::SingleRange>'))
E:\C_BTIESI\code_output\opt_cal\charge_pile_dis\charge_pile_dis.cpp:165: error: assigning to 'Eigen::DenseCoeffsBase, 1>::Scalar' (aka 'double') from incompatible type 'typename internal::enable_if::value && internal::traits::type>::ReturnAsIndexedView, typename IndexedViewType::type>::type' (aka 'Eigen::IndexedView, double, Eigen::internal::SingleRange>')
我想要达到的结果
能够自己去读取当前这个动态矩阵其中的一个元素
请把代码贴全