简体   繁体   English

特征向量判据问题

[英]Eigen Vector cout problems

i am using 我在用

Eigen::Vector2d vector(1,2)
std::cout << "x" << vector[0] << std::endl;

but this is not working because of invalid overload of cout 但这由于无效的cout重载而无法正常工作

But this value should be double or? 但是这个值应该是两倍还是?

Eigen::Vector2d vector(1,2)
double x = vector[0]
std::cout << "x" << x << std::endl;

this works... anyone know why ? 这可行...有人知道为什么吗? Or what i have to do to get the double value back ? 还是我需要做些什么才能取回双倍价值?

thanks for help 感谢帮助

Maybe the result of vector[0] is not double ? 也许vector[0]的结果不是double Maybe it's some class or a custom type? 也许是某些类或自定义类型? In the first snippet you've explicitly converted vector[0] to double . 在第一个代码段中,您已将vector[0]明确转换为double If that case, try casting the result in the second snippet: 如果是这种情况,请尝试将结果投射到第二个片段中:

Eigen::Vector2d vector(1,2);
std::cout << "x" << (double)(vector[0]) << std::endl;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM