[英]eigen matrix const type
consider the following test 考虑以下测试
Eigen::MatrixXd B(Eigen::MatrixXd::Random(5,5));
const Eigen::MatrixXd C(Eigen::MatrixXd::Random(5,5));
std::cout << "B " << typeid(B).name() << std::endl;
std::cout << "C " << typeid(C).name() << std::endl;
std::cout << " === " << std::endl;
std::cout << "B.T " << typeid(B.transpose()).name() << std::endl;
std::cout << "C.T " << typeid(C.transpose()).name() << std::endl;
and its output 及其输出
B N5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEE
C N5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEE
===
B.T N5Eigen9TransposeINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEEEE
C.T N5Eigen9TransposeIKNS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEEEE
demangled demangled
B Eigen::Matrix<double, -1, -1, 0, -1, -1>
C Eigen::Matrix<double, -1, -1, 0, -1, -1>
===
B.T Eigen::Transpose<Eigen::Matrix<double, -1, -1, 0, -1, -1> >
C.T Eigen::Transpose<Eigen::Matrix<double, -1, -1, 0, -1, -1> const>
Why is C
not shown as const
? 为什么
C
不显示为const
? How does Eigen figure out it is? Eigen如何知道它是什么? Is this an Eigen issue or is this
typeid
? 这是一个Eigen问题还是这个
typeid
?
This is due to the behaviour of typeid
: 这是由于
typeid
的行为造成的:
§5.2.8/5 [expr.typeid] The top-level cv-qualifiers of the glvalue expression or the type-id that is the operand of
typeid
are always ignored.§5.2.8/ 5 [expr.typeid]总会忽略glvalue表达式或作为
typeid
操作数的type-id的顶级cv限定词。
So in both cases, the typeid
will only apply to Eigen::MatrixXd
. 因此,在两种情况下,
typeid
仅适用于Eigen::MatrixXd
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.