gpt4 book ai didi

c++ - 将 eigen "Transformation"类设置为后/右乘法的主要列

转载 作者:太空宇宙 更新时间:2023-11-04 13:19:55 50 4
gpt4 key购买 nike

我有一个函数可以对变换矩阵进行大量后乘/右乘。现在我想将此函数转换为使用 Eigen,问题是 Eigen Transformation 类将乘法作为前/左乘法进行。这意味着它在乘法时是行矩阵格式,而存储是列矩阵格式。

有没有办法将 Eigen::Transformation 类成员从行专业更改为列专业?

最佳答案

Eigen 的完整签名 Matrix类是

Matrix<typename Scalar,
int RowsAtCompileTime,
int ColsAtCompileTime,
int Options = 0,
int MaxRowsAtCompileTime = RowsAtCompileTime,
int MaxColsAtCompileTime = ColsAtCompileTime>

第 4 个参数 Optionsdescribed as

Options is a bit field. Here, we discuss only one bit: RowMajor. It specifies that the matrices of this type use row-major storage order; by default, the storage order is column-major. See the page on storage orders. For example, this type means row-major 3x3 matrices

所以你可以说,例如,

Matrix<int, 3, 4, ColMajor> foo;    // column major
Matrix<int, 4, 3, RowMajor> bar; // row major

More documentation on Storage Orders

如果您指的转换是 Eigen::Transform这还有一个 Options 模板参数,您也可以将其传递给 RowMajorColMajor。它生成的任何矩阵都将遵循您指定的相同约定。

Transform<typename Scalar,
int Dim,
int Mode,
int _Options = AutoAlign>

同样,_Options 参数被描述为

_Options has the same meaning as in class Matrix. It allows to specify DontAlign and/or RowMajor. These Options are passed directly to the underlying matrix type.

关于c++ - 将 eigen "Transformation"类设置为后/右乘法的主要列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35687617/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com