我有一个复数矩阵 A 和一个复数 vector b。我想求解线性系统 Ax=b。 我尝试使用此页面上的示例,并使其适应我的复杂问题。 http://eigen.tuxfamily.org/dox/group__TutorialLinearAlgebra.html
这是我正在尝试做的一个简化示例:
我的对象是这样定义的:
typedef Eigen::Matrix<complexd, Eigen::Dynamic, Eigen::Dynamic> DoubleComplexMatrix;
typedef Eigen::Array<complexd, Eigen::Dynamic, 1> DoubleComplexArray;
在我的代码中我想解决这个问题
DoubleComplexMatrix A(3,3);
DoubleComplexArray b(3);
DoubleComplexArray x(3);
A << 1,2,3, 4,5,6, 7,8,10;
b << 3, 3, 4;
cout << "Here is the matrix A:\n" << A << endl;
cout << "Here is the vector b:\n" << b << endl;
ColPivHouseholderQR<DoubleComplexMatrix> dec(A);
x = dec.solve(b);
cout << "The solution is:\n" << x << endl;
错误出现在行:DoubleComplexArray x = dec.solve(b);
因为当我评论它时,没有更多的错误。
我收到这个错误:
TideSolve.cpp:98:38: error: no matching function for call to ‘Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<double>, -1, -1> >::solve(DoubleComplexArray&)’
DoubleComplexArray x = dec.solve(b);
这是否意味着特征求解器不适用于复数? (我敢肯定他们会这样做,而我只是很糟糕!)
除了 ColPivHouseholderQR
之外,我是否需要另一个求解器来处理复数?如果有,是哪一个?
我找到了 an old question有人使用了另一个求解器。
最佳答案
您应该使用 Eigen::Matrix
而不是 Eigen::Array
。后者用于原始二维值数组。前者用于线性代数矩阵和 vector 。请参阅相应的 manual page .
关于c++ - 如何解决复杂的线性系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35684598/