小编Rot*_*yut的帖子

使用Auto与Eigen的错误结果

我使用auto得到了不同的结果,并Vector在求和两个向量时使用.

我的代码:

#include "stdafx.h"
#include <iostream>
#include "D:\externals\eigen_3_1_2\include\Eigen\Geometry"

typedef Eigen::Matrix<double, 3, 1>       Vector3;

void foo(const Vector3& Ha, volatile int j) 
{
    const auto resAuto = Ha + Vector3(0.,0.,j * 2.567);
    const Vector3 resVector3 = Ha + Vector3(0.,0.,j * 2.567);

    std::cout << "resAuto = " << resAuto <<std::endl;
    std::cout << "resVector3 = " << resVector3 <<std::endl;
}

int main(int argc, _TCHAR* argv[])
{
    Vector3 Ha(-24.9536,-29.3876,65.801);
    Vector3 z(0.,0.,2.567);

    int j = 7;

    foo(Ha,j);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

结果:

resAuto = -24.9536,-29.3876,65.801 …

eigen c++11

7
推荐指数
1
解决办法
509
查看次数

标签 统计

c++11 ×1

eigen ×1