1#ifndef _RHEO_AD_POINT_H
2#define _RHEO_AD_POINT_H
45#include "rheolef/point.h"
95typedef ad3_basic<Float>
ad3;
99std::ostream&
operator<< (std::ostream& os,
const ad3_basic<T>& a);
167operator<< (std::ostream& os,
const ad3_basic<T>& a)
215template <
class T,
class U>
219 details::is_rheolef_arithmetic<U>::value
229template <
class T,
class U>
233 details::is_rheolef_arithmetic<U>::value
243template <
class T,
class U>
247 details::is_rheolef_arithmetic<U>::value
257template <
class T,
class U>
261 details::is_rheolef_arithmetic<U>::value
279template <
class T,
class U>
283 details::is_rheolef_arithmetic<U>::value
299template <
class T,
class U>
303 details::is_rheolef_arithmetic<U>::value
321 c._g =
_v*b._g +
_g*b._v;
324template <
class T,
class U>
328 details::is_rheolef_arithmetic<U>::value
338template <
class T,
class U>
342 details::is_rheolef_arithmetic<U>::value
360template <
class T,
class U>
364 details::is_rheolef_arithmetic<U>::value
382 c._g =
_g/b._v -
_v*b._g/b._v;
385template <
class T,
class U>
389 details::is_rheolef_arithmetic<U>::value
396 c._g = - a*b._g/b._v;
399template <
class T,
class U>
403 details::is_rheolef_arithmetic<U>::value
421template <
class T,
class U>
425 details::is_rheolef_arithmetic<U>::value
436#define _RHEOLEF_ad3_comparator(OP) \
440operator OP (const ad3_basic<T> &a, const ad3_basic<T> &b) \
442 return a._v OP b._v; \
444template <class T, class U> \
448 details::is_rheolef_arithmetic<U>::value \
451operator OP (const ad3_basic<T> &a, const U &b) \
455template <class T, class U> \
459 details::is_rheolef_arithmetic<U>::value \
462operator OP (const U &a, const ad3_basic<T> &b) \
467_RHEOLEF_ad3_comparator(==)
468_RHEOLEF_ad3_comparator(!=)
469_RHEOLEF_ad3_comparator(>)
470_RHEOLEF_ad3_comparator(>=)
471_RHEOLEF_ad3_comparator(<)
472_RHEOLEF_ad3_comparator(<=)
473#undef _RHEOLEF_ad3_comparator
482sqr (
const ad3_basic<T>& a)
486 c._g = (2*a._v)*a._g;
496 c._g = (
a._v >= 0 ? 1 : -1)*
a._g;
508 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*
c.v;
517 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]/
a.v;
525 T tmp(
c.v*FADBAD_TWO);
527 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]/tmp;
537 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
547 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
556 T tmp(FADBAD_ONE+_sqr(
c.v));
557 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
566 T tmp(FADBAD_ONE/sqrt(FADBAD_ONE-_sqr(
a.v)));
567 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
576 T tmp(-FADBAD_ONE/sqrt(FADBAD_ONE-_sqr(
a.v)));
577 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
586 T tmp(FADBAD_ONE/(FADBAD_ONE+_sqr(
a.v)));
587 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
599 for (
int i=0;i<
b.gsize;i++)
c.g[i]=tmp*
b.g[i];
609 for (
int i=0;i<
a.gsize;i++)
c.g[i]=tmp*
a.g[i];
615 if (
a.gsize==0)
return pow1(
a.v,b);
616 if (
b.gsize==0)
return pow2(a,
b.v);
618 USER_ASSERT(
a.gsize==
b.gsize,
"derivative vectors not of same size in pow");
621 for (
int i=0;i<
a.gsize;i++)
622 c.g[i]=tmp*
a.g[i]+tmp1*
b.g[i];
631 for (
int i=0;i<
a.gsize;i++)
c.g[i]=
a.g[i]*tmp;
ad3_basic< T > & operator*=(const ad3_basic< T > &b)
ad3_basic< T > & operator-=(const ad3_basic< T > &b)
ad3_basic< T > operator/(const ad3_basic< T > &b) const
ad3_basic< T > operator*(const ad3_basic< T > &b) const
ad3_basic< T > operator-() const
const point_basic< T > & grad() const
static point_basic< ad3_basic< T > > point(const point_basic< T > &x0)
ad3_basic< T > & operator/=(const ad3_basic< T > &b)
point_basic< T >::size_type size_type
ad3_basic< T > & operator+=(const ad3_basic< T > &b)
ad3_basic(const ad3_basic &)
ad3_basic< T > operator+() const
ad3_basic< T > & operator=(const ad3_basic< T > &)
rheolef::std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr1 >::value &&! details::is_field_expr_v2_constant< Expr1 >::value &&details::is_field_expr_v2_nonlinear_arg< Expr2 >::value &&! details::is_field_expr_v2_constant< Expr2 >::value, details::field_expr_v2_nonlinear_node_binary< details::function_traits< Function >::functor_type, details::field_expr_v2_nonlinear_terminal_wrapper_traits< Expr1 >::type, details::field_expr_v2_nonlinear_terminal_wrapper_traits< Expr2 >::type > > type
This file is part of Rheolef.
csr< T, sequential > operator-(const csr< T, sequential > &a)
tensor_basic< T > exp(const tensor_basic< T > &a, size_t d)
std::ostream & operator<<(std::ostream &os, const catchmark &m)
dia< T, M > operator/(const T &lambda, const dia< T, M > &d)
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator*=(ad3_basic< T > &a, const U &b)
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator/=(ad3_basic< T > &a, const U &b)
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator-=(ad3_basic< T > &a, const U &b)
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator+=(ad3_basic< T > &a, const U &b)
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > >::type operator+(const U &a, const ad3_basic< T > &b)
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
float_traits< T >::type type
helper for std::complex<T>: get basic T type