Disambiguate multiplication of a permutation matrix and a homogeneous vector

This commit is contained in:
Sergiu Deitsch 2025-09-27 14:03:07 +02:00
parent bea7f7c582
commit 8d7ebac6ec
No known key found for this signature in database
2 changed files with 17 additions and 0 deletions

View File

@ -1272,6 +1272,14 @@ template <typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>
struct generic_product_impl<Lhs, Rhs, HomogeneousShape, MatrixShape, ProductTag>
: generic_product_impl<typename Lhs::PlainObject, Rhs, DenseShape, MatrixShape, ProductTag> {};
template <typename Lhs, typename Rhs, int ProductTag>
struct generic_product_impl<Lhs, Rhs, PermutationShape, HomogeneousShape, ProductTag>
: generic_product_impl<Lhs, Rhs, PermutationShape, DenseShape, ProductTag> {};
template <typename Lhs, typename Rhs, int ProductTag>
struct generic_product_impl<Lhs, Rhs, HomogeneousShape, PermutationShape, ProductTag>
: generic_product_impl<Lhs, Rhs, DenseShape, PermutationShape, ProductTag> {};
} // end namespace internal
} // end namespace Eigen

View File

@ -124,6 +124,15 @@ void homogeneous(void) {
VERIFY_IS_APPROX(pts_xy1.transpose() * pts_xy1, pts_xy1.transpose() * pts_xy1.eval());
VERIFY_IS_APPROX(pts_xy2 * pts_xy2.transpose(), pts_xy2.eval() * pts_xy2.transpose());
}
{
const Eigen::PermutationMatrix<Size> P{Eigen::Vector<int, Size>::EqualSpaced(0, 1)};
const auto right = Eigen::Vector<Scalar, Size - 1>::Random().homogeneous();
const auto left = Eigen::RowVector<Scalar, Size - 1>::Random().homogeneous();
VERIFY_IS_APPROX(P * right, P * right.eval());
VERIFY_IS_APPROX(left * P, left.eval() * P);
}
}
EIGEN_DECLARE_TEST(geo_homogeneous) {