Re: [eigen] Using Eigen with CppAD scalar types |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Using Eigen with CppAD scalar types
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 20 Jun 2012 18:27:45 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=sy7GDXooPoGcXrGScATfARSHidly6bBWYUWU8iciPbE=; b=zn9S6SiTzF1QUemPJvXGGHKagdNILrxRd28VVj7C37gcPcxttYjTCJXzzvSoI5Qg0H L5pGpWgvs23B6bFnHXu6/c8+/VjY+fxPZwBgOYVoNKaUDFjBVpPzJl44CDt8QHtcOy1d h/wFC5spY05dSt/DkhWjZHR2ZcuIwvAwt3kgDCu0mgE7EW7eEZAqAC0qqlchB7Bvjeyz kLul7BJ/lPsRsA0zvrXPO/h9c7XoN7XVG4kBO2XfvovIP6FbsTw4BPtWFFqBlgVfDCue rakUBqsfxmjSdMsrkDcKW+mT21jfPlv1Wq8Y+Y3SsY5CSOFPisqRjJhbG2lUq8YGi27r 7k8Q==
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
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
>