我正在将Eigen用于计算流体动力学应用程序,我注意到似乎是一个错误。我对代码进行了抽象,以便任何人都可以复制它。我正在使用本征3.3.7。
以下代码重现了问题
#include <cmath>
#include <iostream>
#include "Eigen/Eigen"
using namespace std;
using namespace Eigen;
int main() {
const int dim = 3;
const int nb = pow(3, dim);
const int nq = pow(2, dim);
vector<double> A(dim*nb);
for (uint i=0; i<A.size(); i++) A[i] = i;
vector<double> D(dim*nq*nb);
for (uint i=0; i<D.size(); i++) D[i] = 2*i;
vector<double> C(dim*dim*nq, 0.);
Map< const Matrix<double, dim, Dynamic, RowMajor> > mat_A(A.data(), dim, nb);
Map< const Matrix<double, dim, Dynamic, RowMajor>, 0, OuterStride<> >
mat_B(D.data(), dim, nb, OuterStride<> (nq*nb));
Map< Matrix<double, dim, Dynamic, RowMajor>, 0, InnerStride<>>
mat_C(C.data(), dim, dim, InnerStride<> (nq));
mat_C.noalias() = mat_A * mat_B.transpose();
cout << mat_C << endl << endl;
mat_C = mat_A * mat_B.transpose();
cout << mat_C << endl << endl;
}
代码的输出是
12402 0 0
31356 0 0
50310 0 0
12402 164034 315666
31356 497916 964476
50310 831798 1.61329e+06
结果应相同。我在这里做错了吗?
据我所知,通过从gitlab存储库中提取master分支解决了这个问题。它可能链接到此issue。谢谢您的帮助。