13 #ifndef eli_mutil_ad_dual_operators_hpp
14 #define eli_mutil_ad_dual_operators_hpp
16 #include "eli/code_eli.hpp"
33 template <
typename left__,
typename right__>
46 add(
const left__ &l,
const right__ &r) : l_val(l), r_val(r) {}
50 return l_val.real()+r_val.real();
55 return l_val.nonreal()+r_val.nonreal();
64 template <
typename left__,
typename right__,
bool comp_real_only>
76 template <
typename left__,
typename right__,
bool comp_real_only>
88 template <
typename left__,
typename right__,
bool comp_real_only>
100 template <
typename left__,
typename right__,
bool comp_real_only>
112 template <
typename left__,
typename right__,
bool comp_real_only>
124 template <
typename left__,
typename right__,
bool comp_real_only>
136 template <
typename left__,
typename right__,
bool comp_real_only>
148 template <
typename left__,
typename right__,
bool comp_real_only>
171 namespace dual_number
173 template <
typename left__,
typename right__>
186 subtract(
const left__ &l,
const right__ &r) : l_val(l), r_val(r) {}
190 return l_val.real()-r_val.real();
195 return l_val.nonreal()-r_val.nonreal();
204 template <
typename left__,
typename right__,
bool comp_real_only>
216 template <
typename left__,
typename right__,
bool comp_real_only>
228 template <
typename left__,
typename right__,
bool comp_real_only>
240 template <
typename left__,
typename right__,
bool comp_real_only>
252 template <
typename left__,
typename right__,
bool comp_real_only>
264 template <
typename left__,
typename right__,
bool comp_real_only>
276 template <
typename left__,
typename right__,
bool comp_real_only>
288 template <
typename left__,
typename right__,
bool comp_real_only>
311 namespace dual_number
313 template <
typename left__,
typename right__>
326 multiply(
const left__ &l,
const right__ &r) : l_val(l), r_val(r) {}
330 return l_val.real()*r_val.real();
335 return l_val.real()*r_val.nonreal()+l_val.nonreal()*r_val.real();
344 template <
typename left__,
typename right__,
bool comp_real_only>
356 template <
typename left__,
typename right__,
bool comp_real_only>
368 template <
typename left__,
typename right__,
bool comp_real_only>
380 template <
typename left__,
typename right__,
bool comp_real_only>
392 template <
typename left__,
typename right__,
bool comp_real_only>
404 template <
typename left__,
typename right__,
bool comp_real_only>
416 template <
typename left__,
typename right__,
bool comp_real_only>
428 template <
typename left__,
typename right__,
bool comp_real_only>
451 namespace dual_number
453 template <
typename left__,
typename right__>
466 divide(
const left__ &l,
const right__ &r) : l_val(l), r_val(r) {}
470 return l_val.real()/r_val.real();
475 right_data_type c(r_val.real());
476 return (l_val.nonreal()*c-l_val.real()*r_val.nonreal())/c/c;
485 template <
typename left__,
typename right__,
bool comp_real_only>
497 template <
typename left__,
typename right__,
bool comp_real_only>
509 template <
typename left__,
typename right__,
bool comp_real_only>
521 template <
typename left__,
typename right__,
bool comp_real_only>
533 template <
typename left__,
typename right__,
bool comp_real_only>
545 template <
typename left__,
typename right__,
bool comp_real_only>
557 template <
typename left__,
typename right__,
bool comp_real_only>
569 template <
typename left__,
typename right__,
bool comp_real_only>
eli::util::traits< left__ >::const_expr_ref l_val
Definition: dual_operators.hpp:322
eli::util::traits< right__ >::const_expr_ref r_val
Definition: dual_operators.hpp:183
Definition: dual_number.hpp:55
eli::util::traits< left__ >::const_expr_ref l_val
Definition: dual_operators.hpp:42
data_type nonreal() const
Definition: dual_operators.hpp:473
eli::util::promote_traits< left_data_type, right_data_type >::promote_t data_type
Definition: dual_operators.hpp:459
right__::data_type right_data_type
Definition: dual_operators.hpp:38
eli::util::promote_traits< left_data_type, right_data_type >::promote_t data_type
Definition: dual_operators.hpp:319
subtract(const left__ &l, const right__ &r)
Definition: dual_operators.hpp:186
eli::mutil::ad::dual_number::expression< eli::mutil::ad::dual_number::subtract< eli::mutil::ad::dual< left__, comp_real_only >, eli::mutil::ad::dual< right__, comp_real_only > >, comp_real_only > operator-(const eli::mutil::ad::dual< left__, comp_real_only > &l, const eli::mutil::ad::dual< right__, comp_real_only > &r)
Definition: dual_operators.hpp:207
eli::util::traits< right__ >::const_expr_ref r_val
Definition: dual_operators.hpp:43
Definition: dual_number.hpp:36
left__::data_type left_data_type
Definition: dual_operators.hpp:177
left__::data_type left_data_type
Definition: dual_operators.hpp:317
eli::util::traits< left__ >::const_expr_ref l_val
Definition: dual_operators.hpp:182
data_type real() const
Definition: dual_operators.hpp:468
data_type nonreal() const
Definition: dual_operators.hpp:53
eli::mutil::ad::dual_number::expression< eli::mutil::ad::dual_number::add< eli::mutil::ad::dual< left__, comp_real_only >, eli::mutil::ad::dual< right__, comp_real_only > >, comp_real_only > operator+(const eli::mutil::ad::dual< left__, comp_real_only > &l, const eli::mutil::ad::dual< right__, comp_real_only > &r)
Definition: dual_operators.hpp:67
eli::mutil::ad::dual_number::expression< eli::mutil::ad::dual_number::divide< eli::mutil::ad::dual< left__, comp_real_only >, eli::mutil::ad::dual< right__, comp_real_only > >, comp_real_only > operator/(const eli::mutil::ad::dual< left__, comp_real_only > &l, const eli::mutil::ad::dual< right__, comp_real_only > &r)
Definition: dual_operators.hpp:488
eli::util::traits< right__ >::const_expr_ref r_val
Definition: dual_operators.hpp:323
divide(const left__ &l, const right__ &r)
Definition: dual_operators.hpp:466
right__::data_type right_data_type
Definition: dual_operators.hpp:318
right__::data_type right_data_type
Definition: dual_operators.hpp:458
data_type nonreal() const
Definition: dual_operators.hpp:333
eli::util::promote_traits< left_data_type, right_data_type >::promote_t data_type
Definition: dual_operators.hpp:39
data_type real() const
Definition: dual_operators.hpp:328
const data__ & const_expr_ref
Definition: traits.hpp:45
Definition: dual_operators.hpp:174
data_type real() const
Definition: dual_operators.hpp:48
Definition: dual_number.hpp:28
data_type real() const
Definition: dual_operators.hpp:188
eli::util::traits< right__ >::const_expr_ref r_val
Definition: dual_operators.hpp:463
multiply(const left__ &l, const right__ &r)
Definition: dual_operators.hpp:326
add(const left__ &l, const right__ &r)
Definition: dual_operators.hpp:46
Definition: dual_operators.hpp:454
right__::data_type right_data_type
Definition: dual_operators.hpp:178
Definition: dual_operators.hpp:34
left__::data_type left_data_type
Definition: dual_operators.hpp:457
eli::util::traits< left__ >::const_expr_ref l_val
Definition: dual_operators.hpp:462
data_type nonreal() const
Definition: dual_operators.hpp:193
Definition: dual_operators.hpp:314
eli::mutil::ad::dual_number::expression< eli::mutil::ad::dual_number::multiply< eli::mutil::ad::dual< left__, comp_real_only >, eli::mutil::ad::dual< right__, comp_real_only > >, comp_real_only > operator*(const eli::mutil::ad::dual< left__, comp_real_only > &l, const eli::mutil::ad::dual< right__, comp_real_only > &r)
Definition: dual_operators.hpp:347
eli::util::promote_traits< left_data_type, right_data_type >::promote_t data_type
Definition: dual_operators.hpp:179
left__::data_type left_data_type
Definition: dual_operators.hpp:37