如何计算本征中外部行主矩阵的转置 [英] How to calculate the transpose of external, row major matrix in eigen

查看:105
本文介绍了如何计算本征中外部行主矩阵的转置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有一个外部的行主要矩阵A(mxn),并且已经为结果创建了一个外部的行主要矩阵B(nxm),以获得移调我要做的事情:

Having an external, row-major matrix A(m x n), and having already created the external, row-major matrix B(n x m) for the result, for getting the transpose I do:

Map<MatrixXd,RowMajor> (B,n,m) = Map<MatrixXd,RowMajor> (A,m,n).transpose()

其中A和B指向数据缓冲区。这在默认的大矩阵矩阵情况下很好用,但是对于行矩阵矩阵,结果仅对于m == n是正确的,对于m <> n,数字是偏斜的。我是在误解如何映射主要行的外部数据吗?

where A and B point to the data buffers. This works fine in the default case of col-major matrices, but for row-major matrices the result is correct only for m == n, for m <> n the numbers are skewed up. Am I misinterpreting how to map row-major external data?

推荐答案

Map 用于对齐控制。行优先布局必须通过矩阵类型指定:

The second template argument of Map is for alignment control. The row-major layout must be specified through the matrix type:

typedef Matrix<double,Dynamic,Dynamic,RowMajor> RowMajorMatrixXd;
Map<RowMajorMatrixXd>(B,n,m) = Map<RowMajorMatrixXd>(A,m,n).transpose() 

这篇关于如何计算本征中外部行主矩阵的转置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆