简体   繁体   English

本征矩阵const类型

[英]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.

相关问题 为什么“const Eigen :: Matrix <>&”和“const Ref <Eigen :: Matrix <>>”显然不兼容? - Why are “const Eigen::Matrix<>&” and “const Ref<Eigen::Matrix<> >” apparently incompatible? 是否可以初始化const Eigen矩阵? - Is it possible to initialize a const Eigen matrix? 在C ++的Eigen库中,我该如何解决:无效使用不完整类型&#39;const class Eigen :: MatrixSquareRootReturnValue <Eigen::Matrix<float, -1, -1> &gt;” - In C++'s Eigen library, how do I solve: invalid use of incomplete type ‘const class Eigen::MatrixSquareRootReturnValue<Eigen::Matrix<float, -1, -1> >’ const T * const指向特征矩阵 - const T* const point to Eigen Matrix 正确访问常量本征矩阵的一行 - Access const correctly a row of an Eigen Matrix 使用 Eigen 时出错:无效使用不完整类型 &#39;const class Eigen - Error using Eigen: invalid use of incomplete type ‘const class Eigen 使用 Eigen::Transpose 的正确方法<const Matrix3> ? - Correct way to use Eigen::Transpose<const Matrix3>? 获得特征矩阵元素类型的好方法 - Good way to get Eigen matrix element type 编写一个类型特征来检测特征中的矩阵表达式 - Writing a type trait for detecting Matrix Expressions in Eigen 在EIGEN中分别声明和初始化地图类型矩阵 - Declare and initialize a map type matrix separately in EIGEN
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM