Creating an Eigen matrix from an array with row-major order

前端 未结 1 743
梦谈多话
梦谈多话 2021-02-15 14:08

I have an array of doubles, and I want to create a 4-by-4 matrix using the Eigen library. I also want to specify that the data is stored in row-major order. How can I do this?

1条回答
  •  别跟我提以往
    2021-02-15 14:46

    You need to pass a row-major matrix type to Map, e.g.:

    Map > M(data);
    

    then you can use M as an Eigen matrix, and the values of data will be modified, e.g.:

    M = M.inverse();
    

    If you want to copy the data to a true column-major Eigen matrix, then do:

    Matrix4d M = Map >(data);
    

    Of course, you can also copy to a row-major matrix by using the right type for M.

    0 讨论(0)
提交回复
热议问题