简体   繁体   中英

How to fix this Eigen matrix inversion overflow error?

#include "Eigen/Core"
#include <iostream>

using namespace std;
using namespace Eigen;

int main() {

    Matrix <float, 2, 2 > J;
    J << 0.0f, -1.0f, 1.0f, 0.0f;

    Matrix <float, 2, 2 > I;
    I << 1.0f, 0.0f, 0.0f, 1.0f;

    Matrix <float, 2, 2 > A;
    A = 20.0f * I + 30.0f * J;

    Matrix <float, 2, 2 > B;

    B = 10.0f * I + 25.0f * J;

    Matrix <float, 2, 2 > C;
    C = B;
    cout << C.inverse() << endl;

    return 0;
}

It gives an error which i couldn't fix. I don't know what is meant by "unsolved externals" here and if it is an overflow error how to fix it??

If you look at the documentation of MatrixBase::inverse you'll see that it requires you to include Eigen/LU . Godbolt Demo: https://godbolt.org/z/ydfALn

If you just include Eigen/Core , you only get a forward-declaration of inverse , the compiler will assume it will be implemented elsewhere and the linker will fail, because it can't find the symbol.

Including Eigen/Dense would work as well, since that includes ia the Eigen/LU header.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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