Loading...
Searching...
No Matches
fwd.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 INRIA
3 */
4
5#ifndef __pycppad_fwd_hpp__
6#define __pycppad_fwd_hpp__
7
8#include "pycppad/config.hpp"
10#include "pycppad/warning.hpp"
11
12#define BOOST_BIND_GLOBAL_PLACEHOLDERS
13#include <boost/python.hpp>
14#include <boost/python/scope.hpp>
15
16#undef BOOST_BIND_GLOBAL_PLACEHOLDERS
17
18#include <cppad/cppad.hpp>
19#include <Eigen/Core>
20
21#ifndef PYCPPAD_EXCLUDE_EIGEN_NUMTRAITS_SPECIALIZATION
22
23namespace Eigen
24{
25 template <class Base> struct NumTraits< CppAD::AD<Base> >
26 { // type that corresponds to the real part of an AD<Base> value
27 typedef CppAD::AD<Base> Real;
28 // type for AD<Base> operations that result in non-integer values
29 typedef CppAD::AD<Base> NonInteger;
30 // type to use for numeric literals such as "2" or "0.5".
31 typedef CppAD::AD<Base> Literal;
32 // type for nested value inside an AD<Base> expression tree
33 typedef CppAD::AD<Base> Nested;
34
35 enum {
36 // does not support complex Base types
37 IsComplex = 0 ,
38 // does not support integer Base types
39 IsInteger = 0 ,
40 // only support signed Base types
41 IsSigned = 1 ,
42 // must initialize an AD<Base> object
43 RequireInitialization = 1 ,
44 // computational cost of the corresponding operations
45 ReadCost = 1 ,
46 AddCost = 2 ,
47 MulCost = 2
48 };
49
50 // machine epsilon with type of real part of x
51 // (use assumption that Base is not complex)
52 static CppAD::AD<Base> epsilon(void)
53 { return CppAD::numeric_limits< CppAD::AD<Base> >::epsilon(); }
54
55 // relaxed version of machine epsilon for comparison of different
56 // operations that should result in the same value
57 static CppAD::AD<Base> dummy_precision(void)
58 { return 100. *
59 CppAD::numeric_limits< CppAD::AD<Base> >::epsilon();
60 }
61
62 // minimum normalized positive value
63 static CppAD::AD<Base> lowest(void)
64 { return CppAD::numeric_limits< CppAD::AD<Base> >::min(); }
65
66 // maximum finite value
67 static CppAD::AD<Base> highest(void)
68 { return CppAD::numeric_limits< CppAD::AD<Base> >::max(); }
69
70 // number of decimal digits that can be represented without change.
71 static int digits10(void)
72 { return CppAD::numeric_limits< CppAD::AD<Base> >::digits10; }
73 };
74} // namespace Eigen
75
76#endif // ifndef PYCPPAD_EXCLUDE_EIGEN_NUMTRAITS_SPECIALIZATION
77
78#endif // ifndef __pycppad_fwd_hpp__
Definition fwd.hpp:24
static CppAD::AD< Base > epsilon(void)
Definition fwd.hpp:52
CppAD::AD< Base > Nested
Definition fwd.hpp:33
CppAD::AD< Base > Literal
Definition fwd.hpp:31
static int digits10(void)
Definition fwd.hpp:71
static CppAD::AD< Base > dummy_precision(void)
Definition fwd.hpp:57
static CppAD::AD< Base > highest(void)
Definition fwd.hpp:67
CppAD::AD< Base > Real
Definition fwd.hpp:27
static CppAD::AD< Base > lowest(void)
Definition fwd.hpp:63
CppAD::AD< Base > NonInteger
Definition fwd.hpp:29