定制标量类型的两个动态尺寸本征矩阵之间的乘积

时间:2018-09-26 21:57:42

标签: eigen

我有两个自定义的标量类型TS。根据{{​​3}}

的建议,我在operator*T的特征矩阵之间重载了矩阵积S
template <typename MatrixL, typename MatrixR>
typename std::enable<(std::is_same<MatrixL::Scalar, T>::value && std::is_same<MatrixR::Scalar,S>::value) || (std::is_same<MatrixR::Scalar, T>::value && std::is_same<MatrixL::Scalar, S>::value), Eigen::Matrix<T, MatrixL::RowsAtCompileTime, MatrixR::ColsAtCompileTime>::type
operator*(const MatrixL& lhs, const MatrixR& rhs) {
  return lhs.template cast<T>() * rhs.template cast<T>();
}

我发现我可以将一个静态大小的矩阵与另一个静态大小的矩阵相乘,或者将一个静态大小的矩阵与一个动态大小的矩阵相乘。但是编译器将无法将动态大小的矩阵乘以另一个动态大小的矩阵。

Eigen::Matrix<T, 2, 2> T_static;
Eigen::Matrix<T, Dynamic, Dynamic> T_dynamic(2, 2);
Eigen::Matrix<S, 2, 2> S_static;
Eigen::Matrix<S, Dynamic, Dynamic> S_dynamic(2, 2);
T_static * S_static;    // works
T_static * S_dynamic;   // works
T_dynamic * S_static;   // works
T_dynamic * S_dynamic;  // compilation error

我得到的错误看起来像

external/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h:435:28: note:   template argument deduction/substitution failed:
external/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h:1413:13: note:   deduced conflicting types for parameter 'AccPacketType' ('drake::symbolic::RationalFunction' and 'Eigen::internal::gebp_kernel<drake::symbolic::RationalFunction, drake::symbolic::Polynomial, long int, Eigen::internal::blas_data_mapper<drake::symbolic::RationalFunction, long int, 0, 0>, 2, 4, false, false>::RhsPacket {aka drake::symbolic::Polynomial}')
             EIGEN_GEBGP_ONESTEP(6);
             ^
external/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h:1413:13: error: no matching function for call to 'Eigen::internal::gebp_traits<drake::symbolic::RationalFunction, drake::symbolic::Polynomial, false, false>::madd(Eigen::internal::gebp_kernel<drake::symbolic::RationalFunction, drake::symbolic::Polynomial, long int, Eigen::internal::blas_data_mapper<drake::symbolic::RationalFunction, long int, 0, 0>, 2, 4, false, false>::LhsPacket&, Eigen::internal::gebp_kernel<drake::symbolic::RationalFunction, drake::symbolic::Polynomial, long int, Eigen::internal::blas_data_mapper<drake::symbolic::RationalFunction, long int, 0, 0>, 2, 4, false, false>::RhsPacket&, Eigen::internal::gebp_kernel<drake::symbolic::RationalFunction, drake::symbolic::Polynomial, long int, Eigen::internal::blas_data_mapper<drake::symbolic::RationalFunction, long int, 0, 0>, 2, 4, false, false>::AccPacket&, Eigen::internal::gebp_kernel<drake::symbolic::RationalFunction, drake::symbolic::Polynomial, long int, Eigen::internal::blas_data_mapper<drake::symbolic::RationalFunction, long int, 0, 0>, 2, 4, false, false>::RhsPacket&)'
             EIGEN_GEBGP_ONESTEP(6);

其中drake::symbolic::Polynomial是类型S,而drake::symbolic::RationalFunction是类型T。我在Ubuntu 16.04机器上使用llvm-4.0。

0 个答案:

没有答案