16 #include <type_traits>
54 template<
typename tbase>
70 class =
typename std::enable_if<std::is_arithmetic<fltyp>::value>::type>
77 class =
typename std::enable_if<std::is_arithmetic<fltyp>::value>::type>
87 FDualNumber(
const tbase &pr_,
const tbase &du_) : pr(pr_), du(du_) {}
96 tbase
prim()
const {
return pr; }
99 tbase
real()
const {
return pr; }
102 tbase
dual()
const {
return du; }
105 void set(
const tbase &pr_,
const tbase &du_)
112 void prim(
const tbase &pr_) { pr = pr_; }
115 void real(
const tbase &pr_) { pr = pr_; }
118 void dual(
const tbase &du_) { du = du_; }
192 du = du + pr * f.
dual();
201 du = du - pr * f_.
dual();
209 template<
typename tbase>
217 template<
typename tbase>
220 return a == f_.
real();
224 template<
typename tbase>
227 return a.
real() ==
b;
231 template<
typename tbase>
232 inline bool operator<(const FDualNumber<tbase> &f1,
235 return f1.
real() < f2.real();
239 template<
typename tbase>
240 inline bool operator<(const FDualNumber<tbase> &
f, tbase
a)
246 template<
typename tbase>
247 inline bool operator<(tbase a, const FDualNumber<tbase> &
f)
253 template<
typename tbase>
261 template<
typename tbase>
268 template<
typename tbase>
271 return (a > f.
real());
275 template<
typename tbase>
282 template<
typename tbase>
289 template<
typename tbase>
297 template<
typename tbase>
304 template<
typename tbase>
312 template<
typename tbase>
319 template<
typename tbase>
326 template<
typename tbase>
334 template<
typename tbase>
341 template<
typename tbase>
349 template<
typename tbase>
356 template<
typename tbase>
364 template<
typename tbase>
371 template<
typename tbase>
379 template<
typename tbase>
387 template<
typename tbase>
395 template<
typename tbase>
403 template<
typename tbase>
412 template<
typename tbase>
416 tbase
a = tbase(1) / f2.
real();
422 template<
typename tbase>
438 template<
typename tbase>
454 template<
typename tbase>
470 template<
typename tbase>
484 template<
typename tbase>
498 template<
typename tbase>
514 template<
typename tbase>
528 template<
typename tbase>
531 return log(f) /
log(tbase(10));
542 template<
typename tbase>
550 template<
typename tbase,
typename tbase1>
553 return exp(
log(a) * tbase(b));
557 template<
typename tbase,
typename tbase1>
560 return exp(
log(tbase(a)) * b);
571 template<
typename tbase>
585 template<
typename tbase>
599 template<
typename tbase>
615 template<
typename tbase>
631 template<
typename tbase>
FDualNumber< tbase > asin(const FDualNumber< tbase > &f)
asin([dual number])
FDualNumber< tbase > tan(const FDualNumber< tbase > &f)
tan([dual number])
FDualNumber(tbase &pr_, tbase &du_)
void setDual(const tbase &du_)
Set the dual value.
FDualNumber< tbase > & operator/=(const FDualNumber< tbase > &f_)
operator /=
FDualNumber< tbase > & operator*=(tbase sc_)
operator *=
FDualNumber< tbase > operator-(const FDualNumber< tbase > &f)
Negate the real and the dual parts.
FDualNumber< tbase > tanh(const FDualNumber< tbase > &f)
tanh([dual number])
FDualNumber< tbase > & operator+=(const FDualNumber< tbase > &f)
operator +=
tbase real() const
Same as prim(). Return the real value of the dual number.
void prim(const tbase &pr_)
Set the primal value.
FDualNumber< tbase > operator/(const FDualNumber< tbase > &f, tbase a)
[dual number] / [base number]
FDualNumber(const fltyp &f)
FDualNumber< tbase > & operator-=(const FDualNumber< tbase > &f)
operator -=
FDualNumber< tbase > & operator=(tbase sc_)
operator =
FDualNumber()
Standard constructor - both values are set to zero.
FDualNumber< tbase > acos(const FDualNumber< tbase > &f)
acos([dual number])
FDualNumber(FDualNumber< tbase > &nm)
Standard constructor with user supplied dual number.
void dual(const tbase &du_)
Set the dual value.
FDualNumber< tbase > exp(const FDualNumber< tbase > &f)
exp([dual number])
void real(const tbase &pr_)
Set the primal value.
tbase prim() const
Return the real value of the dual number.
double f(const Vector &xvec)
FDualNumber< tbase > operator*(const FDualNumber< tbase > &f, tbase a)
[dual number] * [base number]
FDualNumber< tbase > & operator-=(tbase sc_)
operator -=
FDualNumber< tbase > & operator+=(tbase sc_)
operator +=
FDualNumber< tbase > & operator=(const FDualNumber< tbase > &f)
operator =
FDualNumber< tbase > cos(const FDualNumber< tbase > &f)
cos([dual number])
FDualNumber(const tbase &pr_, const tbase &du_)
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
FDualNumber< tbase > sin(const FDualNumber< tbase > &f)
sin([dual number])
void setReal(const tbase &pr_)
Set the primal value.
FDualNumber< tbase > & operator*=(const FDualNumber< tbase > &f)
operator *=
FDualNumber< tbase > log(const FDualNumber< tbase > &f)
log([dual number])
FDualNumber< tbase > operator+(const FDualNumber< tbase > &f, tbase a)
[dual number] + [base number]
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
tbase dual() const
Return the dual value of the dual number.
bool operator>(const FDualNumber< tbase > &f1, const FDualNumber< tbase > &f2)
boolean operation >
FDualNumber< tbase > & operator/=(tbase sc_)
operator /=
FDualNumber< tbase > log10(const FDualNumber< tbase > &f)
log10([dual number])
bool operator==(const FDualNumber< tbase > &a1, const FDualNumber< tbase > &a2)
FDualNumber< tbase > cosh(const FDualNumber< tbase > &f)
cosh([dual number])
void set(const tbase &pr_, const tbase &du_)
Set the primal and the dual values.
FDualNumber< tbase > atan(const FDualNumber< tbase > &f)
atan([dual number])
FDualNumber< tbase > sinh(const FDualNumber< tbase > &f)
sinh([dual number])
FDualNumber(const FDualNumber< tbase > &nm)
Standard constructor with user supplied dual number.