[eigen] Using custom scalar types.

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


If I compile the program:
====================
# include <cppad/cppad.hpp>
# include <cppad/example/cppad_eigen.hpp>

int main()
{
typedef Eigen::Matrix< CppAD::AD<double>, 1, 1> MatrixAD;
MatrixAD X;
X(0, 0) = 1;

std::cout << X << std::endl;
return 0;
}
====================
using eigen-3.1.3 with the trunk for the package
http://www.coin-or.org/CppAD/
I get the error message
..../include/Eigen/src/Core/IO.h:132:97: error: no matching function for call to ‘ceil(CppAD::AD<double>)’
Looking at the corresponding code I see the code
return cast<RealScalar,int>(ceil(-log(NumTraits<RealScalar>::epsilon())/log(RealScalar(10))));

On the page
http://eigen.tuxfamily.org/dox-devel/TopicCustomizingEigen.html
under the heading
Using custom scalar types
I see mention of
"define the math functions that makes sense for your type."
and perhaps ceil could be considered one such function. But I do not see mention of conversion from the scalar type to int, which also seems to be required ?

The problem is that, for AD types, I think that implicit conversion to int is dangerous because the AD information is lost and hence CppAD provides an explicit function for this purpose
http://www.coin-or.org/CppAD/Doc/integer.xml

Perhaps it would be OK if one restricts the casting operator to be explicit, but as I understand this is a c++11 extension and not available in c++98.






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