Multiplication of a permutation matrix and a homogeneous vector regression
Summary
Following !1986 (merged) the multiplication of a permutation matrix and a homogeneous vector results in compilation errors due to ambiguity in partial specialization resolution.
Environment
- Operating System : Linux
- Architecture : x86_64
- Eigen Version : bea7f7c5
- Compiler Version : GCC 15.2.1
- Compile Flags : (none)
- Vector Extension : (none)
Minimal Example
#include <Eigen/Geometry>
int main()
{
Eigen::PermutationMatrix<3> P{Eigen::Vector3i::EqualSpaced(0, 1)};
Eigen::Vector3d a = P * Eigen::Vector2d::Random().homogeneous();
Eigen::Vector3d b = Eigen::RowVector2d::Random().homogeneous() * P;
}
Relevant logs
In file included from /home/sergiu/Projects/eigen/Eigen/Core:388,
from /home/sergiu/Projects/eigen/Eigen/Geometry:11,
from eigen5-permhomog.cpp:1:
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h: In instantiation of ‘static void Eigen::internal::Assignment<DstXprType, Eigen::Product<Lhs, Rhs, Options>, Eigen::internal::assign_op<Scalar, Scalar>, Eigen::internal::Dense2Dense, typename std::enable_if<((Options == Eigen::DefaultProduct) || (Options == Eigen::AliasFreeProduct)), void>::type>::run(DstXprType&, const SrcXprType&, const Eigen::internal::assign_op<Scalar, Scalar>&) [with DstXprType = Eigen::Matrix<double, 3, 1>; Lhs = Eigen::PermutationMatrix<3>; Rhs = Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>; int Options = 0; Scalar = double; SrcXprType = Eigen::Product<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, 0>]’:
/home/sergiu/Projects/eigen/Eigen/src/Core/AssignEvaluator.h:920:51: required from ‘constexpr void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<double, 3, 1>; Src = Eigen::Product<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, 0>; Func = assign_op<double, double>]’
920 | Assignment<ActualDstTypeCleaned, Src, Func>::run(actualDst, src, func);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/PlainObjectBase.h:734:39: required from ‘constexpr Derived& Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, 0>; Derived = Eigen::Matrix<double, 3, 1>]’
734 | internal::call_assignment_no_alias(this->derived(), other.derived(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
735 | internal::assign_op<Scalar, typename OtherDerived::Scalar>());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/PlainObjectBase.h:529:17: required from ‘Eigen::PlainObjectBase<Derived>::PlainObjectBase(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, 0>; Derived = Eigen::Matrix<double, 3, 1>]’
529 | _set_noalias(other);
| ~~~~~~~~~~~~^~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/Matrix.h:394:108: required from ‘Eigen::Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>::Matrix(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, 0>; Scalar_ = double; int Rows_ = 3; int Cols_ = 1; int Options_ = 0; int MaxRows_ = 3; int MaxCols_ = 1]’
394 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived>& other) : Base(other.derived()) {}
| ^
eigen5-permhomog.cpp:6:27: required from here
6 | Eigen::Vector3d a = P * Eigen::Vector2d::Random().homogeneous();
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:133:43: error: ambiguous template instantiation for ‘struct Eigen::internal::generic_product_impl<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, Eigen::PermutationShape, Eigen::HomogeneousShape, 3>’
133 | generic_product_impl<Lhs, Rhs>::evalTo(dst, src.lhs(), src.rhs());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:1138:8: note: candidates are: ‘template<class Lhs, class Rhs, int ProductTag, class MatrixShape> struct Eigen::internal::generic_product_impl<Lhs, Rhs, Eigen::PermutationShape, MatrixShape, ProductTag> [with Lhs = Eigen::PermutationMatrix<3>; Rhs = Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>; int ProductTag = 3; MatrixShape = Eigen::HomogeneousShape]’
1138 | struct generic_product_impl<Lhs, Rhs, PermutationShape, MatrixShape, ProductTag> {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:1268:8: note: ‘template<class Lhs, class Rhs, int ProductTag, class MatrixShape> struct Eigen::internal::generic_product_impl<Lhs, Rhs, MatrixShape, Eigen::HomogeneousShape, ProductTag> [with Lhs = Eigen::PermutationMatrix<3>; Rhs = Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>; int ProductTag = 3; MatrixShape = Eigen::PermutationShape]’
1268 | struct generic_product_impl<Lhs, Rhs, MatrixShape, HomogeneousShape, ProductTag>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:133:43: error: incomplete type ‘Eigen::internal::generic_product_impl<Eigen::PermutationMatrix<3>, Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 2, 1> >, 0>, Eigen::PermutationShape, Eigen::HomogeneousShape, 3>’ used in nested name specifier
133 | generic_product_impl<Lhs, Rhs>::evalTo(dst, src.lhs(), src.rhs());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h: In instantiation of ‘static void Eigen::internal::Assignment<DstXprType, Eigen::Product<Lhs, Rhs, Options>, Eigen::internal::assign_op<Scalar, Scalar>, Eigen::internal::Dense2Dense, typename std::enable_if<((Options == Eigen::DefaultProduct) || (Options == Eigen::AliasFreeProduct)), void>::type>::run(DstXprType&, const SrcXprType&, const Eigen::internal::assign_op<Scalar, Scalar>&) [with DstXprType = Eigen::Transpose<Eigen::Matrix<double, 3, 1> >; Lhs = Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>; Rhs = Eigen::PermutationMatrix<3>; int Options = 0; Scalar = double; SrcXprType = Eigen::Product<Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, 0>]’:
/home/sergiu/Projects/eigen/Eigen/src/Core/AssignEvaluator.h:920:51: required from ‘constexpr void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<double, 3, 1>; Src = Eigen::Product<Eigen::Homogeneous<Eigen::CwiseNullaryOp<scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, 0>; Func = assign_op<double, double>]’
920 | Assignment<ActualDstTypeCleaned, Src, Func>::run(actualDst, src, func);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/PlainObjectBase.h:734:39: required from ‘constexpr Derived& Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, 0>; Derived = Eigen::Matrix<double, 3, 1>]’
734 | internal::call_assignment_no_alias(this->derived(), other.derived(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
735 | internal::assign_op<Scalar, typename OtherDerived::Scalar>());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/PlainObjectBase.h:529:17: required from ‘Eigen::PlainObjectBase<Derived>::PlainObjectBase(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, 0>; Derived = Eigen::Matrix<double, 3, 1>]’
529 | _set_noalias(other);
| ~~~~~~~~~~~~^~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/Matrix.h:394:108: required from ‘Eigen::Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>::Matrix(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, 0>; Scalar_ = double; int Rows_ = 3; int Cols_ = 1; int Options_ = 0; int MaxRows_ = 3; int MaxCols_ = 1]’
394 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived>& other) : Base(other.derived()) {}
| ^
eigen5-permhomog.cpp:7:68: required from here
7 | Eigen::Vector3d b = Eigen::RowVector2d::Random().homogeneous() * P;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:133:43: error: ambiguous template instantiation for ‘struct Eigen::internal::generic_product_impl<Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, Eigen::HomogeneousShape, Eigen::PermutationShape, 3>’
133 | generic_product_impl<Lhs, Rhs>::evalTo(dst, src.lhs(), src.rhs());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:1146:8: note: candidates are: ‘template<class Lhs, class Rhs, int ProductTag, class MatrixShape> struct Eigen::internal::generic_product_impl<Lhs, Rhs, MatrixShape, Eigen::PermutationShape, ProductTag> [with Lhs = Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>; Rhs = Eigen::PermutationMatrix<3>; int ProductTag = 3; MatrixShape = Eigen::HomogeneousShape]’
1146 | struct generic_product_impl<Lhs, Rhs, MatrixShape, PermutationShape, ProductTag> {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:1272:8: note: ‘template<class Lhs, class Rhs, int ProductTag, class MatrixShape> struct Eigen::internal::generic_product_impl<Lhs, Rhs, Eigen::HomogeneousShape, MatrixShape, ProductTag> [with Lhs = Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>; Rhs = Eigen::PermutationMatrix<3>; int ProductTag = 3; MatrixShape = Eigen::PermutationShape]’
1272 | struct generic_product_impl<Lhs, Rhs, HomogeneousShape, MatrixShape, ProductTag>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sergiu/Projects/eigen/Eigen/src/Core/ProductEvaluators.h:133:43: error: incomplete type ‘Eigen::internal::generic_product_impl<Eigen::Homogeneous<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 1, 2> >, 1>, Eigen::PermutationMatrix<3>, Eigen::HomogeneousShape, Eigen::PermutationShape, 3>’ used in nested name specifier
133 | generic_product_impl<Lhs, Rhs>::evalTo(dst, src.lhs(), src.rhs());