1
는 주장 :고유치 다음 코드는 아이겐 죽는다 액세스 ProductBase 계수
함께MatrixXd L;
VectorXd x, b;
...
ASSERT_MATRIX_EQ(L*x, b);
,
그것은 오류 다이template <typename DerivedL, typename DerivedR>
void ASSERT_MATRIX_EQ(const Eigen::DenseBase<DerivedL>& A, const Eigen::DenseBase<DerivedR>& B, double tol=1e-7) {
ASSERT_EQ(A.rows(), B.rows());
ASSERT_EQ(A.cols(), B.cols());
for(int i=0; i < A.rows(); i++) {
for(int j=0; j < A.cols(); j++) {
ASSERT_NEAR(A(i,j), B(i,j), tol);
}
}
}
:
test_leq: /usr/include/eigen3/Eigen/src/Core/ProductBase.h:154: typename Base::CoeffReturnType Eigen::ProductBase<Eigen::GeneralProduct<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 4>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >::coeff(Index, Index) const: Assertion `this->rows() == 1 && this->cols() == 1' failed.
호에서 A(i,j)
. (그러나, 나는 잘 cout << A << endl;
를 호출 할 수 있습니다.) 라인 (154)에
, ProductBase.h
호기심 내가 일반적인 매트릭스 기능을 작성하기위한 Eigen's guide을 다음 해요 주장
// restrict coeff accessors to 1x1 expressions. No need to care about mutators here since this isnt a Lvalue expression
typename Base::CoeffReturnType coeff(Index row, Index col) const
{
#ifdef EIGEN2_SUPPORT
return lhs().row(row).cwiseProduct(rhs().col(col).transpose()).sum();
#else
EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
eigen_assert(this->rows() == 1 && this->cols() == 1);
return derived().coeff(row,col);
#endif
}
있습니다. 이 제네릭 함수를 올바르게 작성하려면 어떻게해야합니까?
편집 : ProductBase
에 1x1 매트릭스가 필요한 이유를 알고있는 것이 좋습니다.