Re: [eigen] Using Eigen with CppAD scalar types

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


The static functions must be members of the NumTraits class. I also
propose to make Nested a reference to reduce copies, so:

namespace Eigen {
    template<class Base>  struct NumTraits<  CppAD::AD<Base>  >
    {    typedef CppAD::AD<Base>    Real;

         typedef CppAD::AD<Base>    NonInteger;
         typedef CppAD::AD<Base>&  Nested;


         enum {
              IsComplex             = 0 ,
              IsInteger             = 0 ,
              IsSigned              = 1 ,
              RequireInitialization = 1 ,
              ReadCost              = 1 ,
              AddCost               = 2 ,
              MulCost               = 2
         };

      // machine epsilon with type of real part of x
      static inline Base epsilon(const AD<Base>&  x)
      {    return CppAD::numeric_limits<Base>::epsilon(); }
      // relaxed version of machine epsilon for comparison of different
      // operations that should result in the same value
      static inline Base dummy_precision(const AD<Base>&  x)
      {    return 100. * CppAD::numeric_limits<Base>::epsilon(); }
      // minimum normalized positive value
      static inline Base lowest(void)
      {    return CppAD::numeric_limits<  AD<Base>  >::min(); }
      // maximum finite value
      static inline Base highest(void)
      {    return CppAD::numeric_limits<  AD<Base>  >::max(); }
    };
}


> Does this mean that the CppAD::internal namespace is not used any more ?


That has never been the case (or perhaps in the alpha versions of the 3.0).

cheers,
Gael

>
>
>>
>>
>> gael
>> On Mon, Jun 18, 2012 at 4:42 PM, Brad Bell<bradbell@xxxxxxxxxx>  wrote:
>>>
>>> On 06/18/2012 07:36 AM, Brad Bell wrote:
>>>>
>>>> I think that I have correctly connected CppAD::AD<Base>  types to Eigen
>>>> (for the case where Base is a real type).
>>>>
>>>> Here is the Eigen custom scalar type interface
>>>>     http://www.coin-or.org/CppAD/Doc/eigen_det.cpp.xml
>>>
>>> Sorry for the second posting, the correct link for the scalar type
>>> interface
>>> is
>>>    http://www.coin-or.org/CppAD/Doc/cppad_eigen.hpp.xml
>>>
>>>> Here is an example usage
>>>>    http://www.coin-or.org/CppAD/Doc/eigen_det.cpp.xml
>>>>
>>>> Here is the corresponding C++ source code
>>>>
>>>>
>>>>  https://projects.coin-or.org/CppAD/browser/trunk/cppad/example/cppad_eigen.hpp
>>>>
>>>>  https://projects.coin-or.org/CppAD/browser/trunk/example/eigen_det.cpp
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
>



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