[eigen] Conflict between coeffRef and CppAD

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


Dear all,

I have a problem when using CppAD for auto differentiation and sparse matrices from Eigen. I get a compilation error when trying to use coeffRef, the following example reproduces the problem

#include <cppad/example/cppad_eigen.hpp>
#include <cppad/speed/det_by_minor.hpp>
#include <Eigen/Sparse>

int main(){

  Eigen::SparseMatrix<double> mat(3, 3);

  for(size_t i=0; i<3; ++i){
    mat.coeffRef(i,i) = 1.0;
  } 

}

In file included from ../include/Eigen/Eigen/SparseCore:40:0,
                 from ../include/Eigen/Eigen/Sparse:19,
                 from cppad_eigen_sparse_test.cpp:6:
../include/Eigen/Eigen/src/SparseCore/SparseMatrix.h: In member function ‘Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Scalar& Eigen::SparseMatrix<_Scalar, _Flags, _Index>::insert(Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Index, Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Index) [with _Scalar = double, int _Options = 0, _Index = int, Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Scalar = double, Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Index = int]’:
../include/Eigen/Eigen/src/SparseCore/SparseMatrix.h:200:30:   instantiated from ‘Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Scalar& Eigen::SparseMatrix<_Scalar, _Flags, _Index>::coeffRef(Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Index, Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Index) [with _Scalar = double, int _Options = 0, _Index = int, Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Scalar = double, Eigen::SparseMatrix<_Scalar, _Flags, _Index>::Index = int]’
cppad_eigen_sparse_test.cpp:12:21:   instantiated from here
../include/Eigen/Eigen/src/SparseCore/SparseMatrix.h:226:9: error: call of overloaded ‘reserve(const ConstantReturnType)’ is ambiguous
.../include/Eigen/Eigen/src/SparseCore/SparseMatrix.h:226:9: note: candidates are:
../include/Eigen/Eigen/src/SparseCore/SparseMatrix.h:270:17: note: void Eigen::SparseMatrix<_Scalar, _Flags, _Index>::reserve(const SizesType&, const typename SizesType::value_type&) [with SizesType = Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<int>, Eigen::Matrix<int, -0x00000000000000001, 1> >, _Scalar = double, int _Options = 0, _Index = int, typename SizesType::value_type = int]
../include/Eigen/Eigen/src/SparseCore/SparseMatrix.h:276:17: note: void Eigen::SparseMatrix<_Scalar, _Flags, _Index>::reserve(const SizesType&, const typename SizesType::Scalar&) [with SizesType = Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<int>, Eigen::Matrix<int, -0x00000000000000001, 1> >, _Scalar = double, int _Options = 0, _Index = int, typename SizesType::Scalar = int]


There is already a similar forum post that has been solved:
https://forum.kde.org/viewtopic.php?f=74&t=124099

The eigen sparse plugin that Gael suggests fixes the problem with setFromTriplets, but the problem appears again when using coeffRef.

I am using Eigen 3.2.2 with gcc version 4.6.3 and the CppAD version from the web http://www.coin-or.org/download/source/CppAD/cppad-20150410.epl.tgz

I would appreciate if someone could also explain the reason of the problem.

Best,

--
Hilario.


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