Re: [eigen] Using custom scalar types.

[ Thread Index | Date Index | More Archives ]

I was able to fix this problem by defining a partial specialization for
    template<typename Scalar, bool IsInteger>
    struct significant_decimals_default_impl
which is defined in Eigen/src/Core/IO.h. The partial specialization can be in the change set

Perhaps there is some other way (without defining a cast from AD<Base> to int) that the same thing can be accomplished and that is documented and hence part of the Eigen API ?

On 04/22/2013 07:15 PM, Brad Bell wrote:
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
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
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

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+