16 #ifndef dealii_differentiation_ad_adolc_math_h
17 #define dealii_differentiation_ad_adolc_math_h
21 #ifdef DEAL_II_WITH_ADOLC
23 # include <adolc/adouble.h>
24 # include <adolc/adtl.h>
25 # include <adolc/internal/adolc_settings.h>
26 # include <adolc/internal/adubfunc.h>
44 # define DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(func_to, func_from) \
45 inline adouble func_to(const adouble &x) \
47 return func_from(static_cast<const badouble &>(x)); \
49 inline adtl::adouble func_to(const adtl::adouble &x) \
51 return adtl::func_from(x); \
57 # define DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(func) \
58 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(func, func)
63 # define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(func_to, func_from) \
64 inline adouble func_to(const adouble &x, const adouble &y) \
66 return func_from(static_cast<const badouble &>(x), \
67 static_cast<const badouble &>(y)); \
69 inline adouble func_to(const double x, const adouble &y) \
71 return func_from(x, static_cast<const badouble &>(y)); \
73 inline adouble func_to(const adouble &x, const double y) \
75 return func_from(static_cast<const badouble &>(x), y); \
77 inline adtl::adouble func_to(const adtl::adouble &x, \
78 const adtl::adouble &y) \
80 return adtl::func_from(x, y); \
82 inline adtl::adouble func_to(const double x, const adtl::adouble &y) \
84 return adtl::func_from(x, y); \
86 inline adtl::adouble func_to(const adtl::adouble &x, const double y) \
88 return adtl::func_from(x, y); \
94 # define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(func) \
95 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(func, func)
100 # define DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2(func) \
101 inline adouble func(const adouble &x, const adouble &y) \
103 return func(static_cast<const badouble &>(x), \
104 static_cast<const badouble &>(y)); \
106 inline adtl::adouble func(const adtl::adouble &x, \
107 const adtl::adouble &y) \
109 return adtl::func(x, y); \
116 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(pow)
117 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(fmax)
118 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(
max, fmax)
119 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION(fmin)
120 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY(
min, fmin)
122 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(exp)
123 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(log)
124 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
log10)
125 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sqrt)
126 # if defined(DEAL_II_ADOLC_WITH_ATRIG_ERF)
127 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
erf)
129 erfc(
const adouble &x)
134 erfc(
const adtl::adouble &x)
140 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
fabs)
141 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY(abs,
fabs)
142 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
ceil)
143 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
floor)
145 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(sin)
146 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(cos)
147 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(tan)
148 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
asin)
149 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
acos)
150 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
atan)
151 DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2(
atan2)
153 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
sinh)
154 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
cosh)
155 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
tanh)
156 # if defined(DEAL_II_ADOLC_WITH_ATRIG_ERF)
157 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
asinh)
158 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
acosh)
159 DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION(
atanh)
162 # undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_2
163 # undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION
164 # undef DEAL_II_EXPOSE_ADOLC_BINARY_MATH_FUNCTION_COPY
165 # undef DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION
166 # undef DEAL_II_EXPOSE_ADOLC_UNARY_MATH_FUNCTION_COPY
172 #endif // DEAL_II_WITH_ADOLC