[eigen] Eigen 3.3-rc2: no type named 'Traits' in 'Eigen::internal::general_matrix_matrix_product...'

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi all,

I've run into a new problem with Eigen 3.3-rc2. I'm guessing it's either a problem with how we've defined traits for the auto-diff types in Stan or it's a bug with not including the typedef (I saw something similar was patched a while ago).

Here's a short example that fails to compile:
// ex.cpp
#include <stan/math/rev/mat.hpp>

template <typename T>
Eigen::Matrix<T, -1, -1> foo(const Eigen::Matrix<T, -1, -1>& m) {
  return m * m;
}

int main() {
  Eigen::Matrix<stan::math::var, -1, -1> x(2, 2);
  x << 1, 0, 0, 1;
  foo(x);
  return 0;
}

I'm using branch feature/0187-eigen-3.3 from https://github.com/stan-dev/math. To compile, I typed: clang++ ex.cpp -isystem lib/eigen_3.3-rc2 -isystem . -isystem lib/cvodes_2.9..0/include/
(I could simplify it further if that would help).

And here's the error message I get:

> clang++ ex.cpp -isystem lib/eigen_3.3-rc2 -isystem . -isystem lib/cvodes_2.9.0/include/
In file included from ex.cpp:1:
In file included from ./stan/math/rev/mat.hpp:4:
In file included from ./stan/math/rev/core.hpp:14:
In file included from ./stan/math/rev/core/matrix_vari.hpp:4:
In file included from ./stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from ./stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from lib/eigen_3.3-rc2/Eigen/Dense:1:
In file included from lib/eigen_3.3-rc2/Eigen/Core:480:
lib/eigen_3.3-rc2/Eigen/src/Core/products/GeneralMatrixMatrix.h:233:26: error: no type named 'Traits'
      in 'Eigen::internal::general_matrix_matrix_product<long, stan::math::var, 0, false,
      stan::math::var, 0, false, 0>'
  typedef typename Gemm::Traits Traits;
          ~~~~~~~~~~~~~~~^~~~~~
lib/eigen_3.3-rc2/Eigen/src/Core/products/GeneralMatrixMatrix.h:484:10: note: in instantiation of
      template class 'Eigen::internal::gemm_functor<stan::math::var, long,
      Eigen::internal::general_matrix_matrix_product<long, stan::math::var, 0, false,
      stan::math::var, 0, false, 0>, Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, Eigen::Matrix<stan::math::var, -1, -1, 0,
      -1, -1>, Eigen::internal::gemm_blocking_space<0, stan::math::var, stan::math::var, -1, -1, -1,
      1, false> >' requested here
        (GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), a_lhs.rows(), a_rhs.cols(), a_lhs...
         ^
lib/eigen_3.3-rc2/Eigen/src/Core/products/GeneralMatrixMatrix.h:435:7: note: in instantiation of
      function template specialization
      'Eigen::internal::generic_product_impl<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, Eigen::DenseShape, Eigen::DenseShape,
      8>::scaleAndAddTo<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1> >' requested here
      scaleAndAddTo(dst, lhs, rhs, Scalar(1));
      ^
lib/eigen_3.3-rc2/Eigen/src/Core/ProductEvaluators.h:148:37: note: in instantiation of function
      template specialization 'Eigen::internal::generic_product_impl<Eigen::Matrix<stan::math::var,
      -1, -1, 0, -1, -1>, Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, Eigen::DenseShape,
      Eigen::DenseShape, 8>::evalTo<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1> >' requested
      here
    generic_product_impl<Lhs, Rhs>::evalTo(dst, src.lhs(), src.rhs());
                                    ^
lib/eigen_3.3-rc2/Eigen/src/Core/AssignEvaluator.h:814:46: note: in instantiation of member function
      'Eigen::internal::Assignment<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Product<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, 0>,
      Eigen::internal::assign_op<stan::math::var, stan::math::var>, Eigen::internal::Dense2Dense,
      void>::run' requested here
  Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);
                                             ^
lib/eigen_3.3-rc2/Eigen/src/Core/PlainObjectBase.h:721:17: note: in instantiation of function
      template specialization
      'Eigen::internal::call_assignment_no_alias<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Product<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, 0>,
      Eigen::internal::assign_op<stan::math::var, stan::math::var> >' requested here
      internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_o...
                ^
lib/eigen_3.3-rc2/Eigen/src/Core/PlainObjectBase.h:531:7: note: in instantiation of function template
      specialization 'Eigen::PlainObjectBase<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>
      >::_set_noalias<Eigen::Product<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, 0> >' requested here
      _set_noalias(other);
      ^
lib/eigen_3.3-rc2/Eigen/src/Core/Matrix.h:379:9: note: in instantiation of function template
      specialization 'Eigen::PlainObjectBase<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>
      >::PlainObjectBase<Eigen::Product<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, 0> >' requested here
      : Base(other.derived())
        ^
ex.cpp:5:10: note: in instantiation of function template specialization
      'Eigen::Matrix<stan::math::var, -1, -1, 0, -1,
      -1>::Matrix<Eigen::Product<Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>,
      Eigen::Matrix<stan::math::var, -1, -1, 0, -1, -1>, 0> >' requested here
  return m * m;
         ^
ex.cpp:11:3: note: in instantiation of function template specialization 'foo<stan::math::var>'
      requested here
  foo(x);
  ^
1 error generated.


Thank you.


Daniel

P.S. Is there a place with guidelines for writing traits correctly for 3..3? This code works for 3.2 and I haven't been able to find additional information on traits for custom types, especially with 3.3. If possible, we'd work through the guidelines to the best of our ability before hitting the list.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/