llt compiles for ColMajor but not RowMajor on custom type
Summary
I'm guessing that this might be an issue for autodiff.github.io (which defines the supposedly eigen compatible type), but I'm puzzled why the following llt().solve() invocation compiles for ColMajor but not RowMajor when using the autodiff::var scalar type
Environment
- Operating System : Mac
- Architecture : Arm64
- Eigen Version : 3.4.0
- Compiler Version : Apple clang version 14.0.0
- Compile Flags :
- Vector Extension :
Minimal Example
#include <autodiff/reverse/var.hpp>
#include <autodiff/reverse/var/eigen.hpp>
#include <Eigen/Cholesky>
int main(int argc, char *argv[])
{
Eigen::Matrix<double,N,1> b;
Eigen::Matrix<autodiff::var,N,N,Eigen::ColMajor> C;
C.llt().solve(b);
Eigen::Matrix<autodiff::var,N,N,Eigen::RowMajor> R;
R.llt().solve(b);
}
Steps to reproduce
- try to compile
What is the current bug behavior?
- fails to compile for RowMajor
What is the expected correct behavior?
Same behavior for ColMajor and RowMajor
Relevant logs
The error I'm getting is:
path/eigen-src/Eigen/src/Core/products/TriangularSolverMatrix.h:124:42: error: conditional expression is ambiguous; 'autodiff::detail::Variable<double>' can be converted to 'ExprPtr<double>' (aka 'shared_ptr<Expr<double>>') and vice versa
Scalar a = (Mode & UnitDiag) ? Scalar(1) : Scalar(1)/conj(tri(i,i));
^ ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
path/eigen-src/Eigen/src/Core/products/TriangularSolverMatrix.h:32:9: note: in instantiation of member function 'Eigen::internal::triangular_solve_matrix<autodiff::detail::Variable<double>, long, 1, 1, false, 1, 0, 1>::run' requested here
::run(size, cols, tri, triStride, _other, otherIncr, otherStride, blocking);
^
path/eigen-src/Eigen/src/Core/SolveTriangular.h:102:9: note: in instantiation of member function 'Eigen::internal::triangular_solve_matrix<autodiff::detail::Variable<double>, long, 2, 2, false, 0, 1, 1>::run' requested here
::run(size, othersize, &actualLhs.coeffRef(0,0), actualLhs.outerStride(), &rhs.coeffRef(0,0), rhs.innerStride(), rhs.outerStride(), blocking);
^
path/eigen-src/Eigen/src/Core/SolveTriangular.h:182:18: note: in instantiation of member function 'Eigen::internal::triangular_solver_selector<const Eigen::Transpose<const Eigen::Block<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, -1, -1, false>>, Eigen::Block<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, -1, -1, false>, 2, 2, 0, -1>::run' requested here
Side, Mode>::run(derived().nestedExpression(), otherCopy);
^
path/eigen-src/Eigen/src/Cholesky/LLT.h:364:72: note: in instantiation of function template specialization 'Eigen::TriangularViewImpl<const Eigen::Transpose<const Eigen::Block<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, -1, -1, false>>, 2, Eigen::Dense>::solveInPlace<2, Eigen::Block<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, -1, -1, false>>' requested here
if(rs>0) A11.adjoint().template triangularView<Upper>().template solveInPlace<OnTheRight>(A21);
^
path/eigen-src/Eigen/src/Cholesky/LLT.h:408:61: note: in instantiation of function template specialization 'Eigen::internal::llt_inplace<autodiff::detail::Variable<double>, 1>::blocked<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>>' requested here
{ return llt_inplace<typename MatrixType::Scalar, Lower>::blocked(m)==-1; }
^
path/eigen-src/Eigen/src/Cholesky/LLT.h:456:21: note: in instantiation of member function 'Eigen::internal::LLT_Traits<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, 1>::inplace_decomposition' requested here
bool ok = Traits::inplace_decomposition(m_matrix);
^
path/eigen-src/Eigen/src/Cholesky/LLT.h:109:7: note: in instantiation of function template specialization 'Eigen::LLT<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, 1>::compute<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>>' requested here
compute(matrix.derived());
^
path/eigen-src/Eigen/src/Cholesky/LLT.h:542:10: note: in instantiation of function template specialization 'Eigen::LLT<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>, 1>::LLT<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>>' requested here
return LLT<PlainObject>(derived());
^
path/main.cpp:30:5: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<autodiff::detail::Variable<double>, 5, 5, 1>>::llt' requested here
R.llt().solve(b);
^
1 error generated.