我遇到了一个模糊的问题,在3.3,3.3.rc1的第一个候选版本中,密集矩阵的全枢轴Householder分解的逆方法中的Assignment部分特化。这是一个最小的例子,它产生了我们正在编译Stan数学库的错误:
#include <Eigen/Dense>
int main() {
using Eigen::MatrixXd;
MatrixXd m(2, 2);
m << 1, 0, 0, 1;
Eigen::FullPivHouseholderQR<MatrixXd> hh
= m.fullPivHouseholderQr();
MatrixXd m_inv_transpose = hh.inverse();
}
我们没有以正确的方式使用FullPivHouseholderQR吗?
以下是我在Mac OS X上使用clang ++时遇到的错误(Apple LLVM版本7.0.2(clang-700.1.81)):
temp2$ clang++ -isystem ~/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1 fph.cpp In file included from fph.cpp:1: In file included from /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/Dense:1: In file included from /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/Core:389: /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/Core/AssignEvaluator.h:813:3: error: ambiguous partial specializations of 'Assignment, Eigen::Inverse > >, Eigen::internal::assign_op, Eigen::internal::Dense2Dense, void>' Assignment::run(actualDst, src, func); ^ /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/Core/PlainObjectBase.h:721:17: note: in instantiation of function template specialization 'Eigen::internal::call_assignment_no_alias, Eigen::Inverse > >, Eigen::internal::assign_op >' requested here internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op()); ^ /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/Core/PlainObjectBase.h:531:7: note: in instantiation of function template specialization 'Eigen::PlainObjectBase >::_set_noalias > > >' requested here _set_noalias(other); ^ /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/Core/Matrix.h:379:9: note: in instantiation of function template specialization 'Eigen::PlainObjectBase >::PlainObjectBase > > >' requested here : Base(other.derived()) ^ fph.cpp:9:30: note: in instantiation of function template specialization 'Eigen::Matrix::Matrix > > >' requested here MatrixXd m_inv_transpose = hh.inverse(); ^ /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/Core/AssignEvaluator.h:851:8: note: partial specialization matches [with DstXprType = Eigen::Matrix, SrcXprType = Eigen::Inverse > >, Functor = Eigen::internal::assign_op, Weak = void] struct Assignment ^ /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/LU/InverseImpl.h:290:8: note: partial specialization matches [with DstXprType = Eigen::Matrix, XprType = Eigen::FullPivHouseholderQR >] struct Assignment, internal::assign_op, Dense2Dense> ^ /Users/carp/cmdstan/stan/lib/stan_math/lib/eigen_3.3.rc1/Eigen/src/QR/FullPivHouseholderQR.h:579:8: note: partial specialization matches [with DstXprType = Eigen::Matrix, MatrixType = Eigen::Matrix, Scalar = double] struct Assignment >, internal::assign_op, Dense2Dense> ^ 1 error generated.