NeoPZ
fad.h
Go to the documentation of this file.
1 // Emacs will be in -*- Mode: c++ -*-
2 //
3 // ************ DO NOT REMOVE THIS BANNER ****************
4 //
5 // Nicolas Di Cesare <Nicolas.Dicesare@ann.jussieu.fr>
6 // http://www.ann.jussieu.fr/~dicesare
7 //
8 // CEMRACS 98 : C++ courses,
9 // templates : new C++ techniques
10 // for scientific computing
11 //
12 //********************************************************
13 //
14 // A short implementation ( not all operators and
15 // functions are overloaded ) of 1st order Automatic
16 // Differentiation in forward mode (FAD) using
17 // EXPRESSION TEMPLATES.
18 //
19 //********************************************************
20 #ifndef _fad_h_
21 #define _fad_h_
22 
23 #include <algorithm>
24 
25 #include <cmath>
26 #include <math.h>
27 
28 #include <utils/vectors.h>
29 #include <utils/promote.h>
30 #include <type_traits>
31 
32 #include <Hash/TPZHash.h>
33 
34 using namespace std;
35 
36 template <class T> class FadExpr;
37 template <class T> class FadCst;
38 
39 template <class T> class FadUnaryPlus;
40 template <class T> class FadUnaryMin;
41 
42 template <class L, class R> class FadBinaryAdd;
43 template <class L, class R> class FadBinaryMinus;
44 template <class L, class R> class FadBinaryMul;
45 template <class L, class R> class FadBinaryDiv;
46 
47 class FadSuper {
48 protected :
50  FadSuper(const FadSuper&){};
51  ~FadSuper(){};
52 };
53 
54 template <class T> class Fad : public FadSuper {
55 public:
56  typedef T value_type;
57 
58  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
59  inline void copy(const Fad<R>& rhs)
60  {
61  const Vector<R> &xdx = rhs.dx();
62  dx_.resize(xdx.size());
63  size_t sz = rhs.dx().size();
64  for (size_t i = 0; i < sz; ++i) {
65  dx_[i] = xdx[i];
66  }
67  val_ = rhs.val();
68  }
69 
70 protected:
71  T val_;
73 
74 public:
75 
77 
78  Fad() : val_( T(0.f)), dx_(), defaultVal(T(0)) {;}
79 
80  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
81  Fad(const R & x) : val_(x), dx_(), defaultVal(T(0)) {;}
82  Fad(const int sz, const T & x) : val_(x), dx_(sz,T(0)), defaultVal(T(0)) {;}
83  Fad(const int sz, const int i, const T & x) : val_(x), dx_(sz,T(0)), defaultVal(T(0))
84  {dx_[i]=1.;}
85  Fad(const int sz, const T & x, const T & dx) : val_(x), dx_(sz, dx), defaultVal(T(0)) {;}
86  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
87  Fad(const Fad<R> & rhs) : defaultVal(T(0))
88  {
89  copy(rhs);
90  }
91  //template <class ExprT, typename enable_if<is_convertible<typename ExprT::value_type,T>::value,int>::type * = nullptr>
92  template <class ExprT>
93  inline Fad(const FadExpr<ExprT>& fadexpr) :
94  val_(fadexpr.val()),
95  dx_(fadexpr.size()),
96  defaultVal(T(0))
97  {
98  int sz = fadexpr.size();
99 
100  if ( sz ) {
101  for(int i=0; i<sz; ++i)
102  dx_[i] = fadexpr.dx(i);
103  }
104  }
105 
106  ~Fad(){;}
107 
108  void diff(const int ith, const int n);
109 
110  const Vector<T>& dx() const { return dx_;}
111 
112  const T& val() const { return val_;}
113  T& val() { return val_;}
114 
115  bool hasFastAccess() const { return dx_.size()!=0;}
116 
117  T& fastAccessDx(int i) { return dx_[i];}
118  const T& fastAccessDx(int i) const { return dx_[i];}
119  const T& d(int i) const { return dx_[i];}
120 /*
121  const T dx(int i) const { T tmp= dx_.size()? dx_[i]:T(0); return tmp;}
122  */
123 
124  const T& dx(int i) const { return dx_.size() ? dx_[i] : defaultVal;}
125  T dx(int i) { T tmp= dx_.size()? dx_[i]:defaultVal; return tmp;}
126 
127  int size() const { return dx_.size();}
128 
129  template <class ExprT> Fad<T> & operator=(const FadExpr<ExprT>& fadexpr);
130 
133 
134  Fad<T>& operator+= (const T& x);
135  Fad<T>& operator-= (const T& x);
136  Fad<T>& operator*= (const T& x);
137  Fad<T>& operator/= (const T& x);
138 
139  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
140  inline Fad<T>& operator+= (const Fad<R>& x){
141  int xsz = x.size(), sz = dx_.size();
142 
143  if (xsz) {
144  R* xdx = x.dx().begin();
145  if (sz) {
146  T* RESTRICT dxp = dx_.begin();
147  for (int i=0; i<sz; ++i)
148  dxp[i] += xdx[i];
149  }
150  else {
151  dx_.resize(xsz);
152  T* RESTRICT dxp = dx_.begin();
153  for (int i=0; i<xsz; ++i)
154  dxp[i] = xdx[i];
155  }
156  }
157 
158  val_ += x.val();
159 
160  return *this;
161  }
162 
163  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
164  inline Fad<T>& operator-= (const Fad<R>& x){
165  int xsz = x.size(), sz = dx_.size();
166 
167  if (xsz) {
168  R* RESTRICT xdx = x.dx().begin();
169  if (sz) {
170  T* RESTRICT dxp = dx_.begin();
171  for (int i=0; i<sz; ++i)
172  dxp[i] -= xdx[i];
173  }
174  else {
175  dx_.resize(xsz);
176  T* RESTRICT dxp = dx_.begin();
177  for (int i=0; i<xsz; ++i)
178  dxp[i] = - xdx[i];
179  }
180  }
181 
182  val_ -= x.val();
183 
184  return *this;
185  }
186 
187  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
188  inline Fad<T>& operator*= (const Fad<R>& x){
189  int xsz = x.size(), sz = dx_.size();
190  R xval = x.val();
191 
192  if (xsz) {
193  R* RESTRICT xdx = x.dx().begin();
194  if (sz) {
195  T* RESTRICT dxp = dx_.begin();
196  for (int i=0; i<sz; ++i)
197  dxp[i] = val_ * xdx[i] + dxp[i] * xval;
198  }
199  else {
200  dx_.resize(xsz);
201  T* RESTRICT dxp = dx_.begin();
202  for (int i=0; i<xsz; ++i)
203  dxp[i] = val_ * xdx[i];
204  }
205  }
206  else {
207  if (sz) {
208  T* RESTRICT dxp = dx_.begin();
209  for (int i=0; i<sz; ++i)
210  dxp[i] *= xval;
211  }
212  }
213 
214  val_ *= xval;
215 
216  return *this;
217  }
218 
219  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
220  inline Fad<T>& operator/= (const Fad<R>& x){
221  int xsz = x.size(), sz = dx_.size();
222  R xval = x.val();
223 
224  if (xsz) {
225  R* RESTRICT xdx = x.dx().begin();
226  if (sz) {
227  T* RESTRICT dxp = dx_.begin();
228  for (int i=0; i<sz; ++i)
229  dxp[i] = (dxp[i]*xval - val_*xdx[i])/ (xval*xval);
230  }
231  else {
232  dx_.resize(xsz);
233  T* RESTRICT dxp = dx_.begin();
234  for (int i=0; i<xsz; ++i)
235  dxp[i] = -val_ * xdx[i] / (xval*xval);
236  }
237  }
238  else {
239  if (sz) {
240  T* RESTRICT dxp = dx_.begin();
241  for (int i=0; i<sz; ++i)
242  dxp[i] /= xval;
243  }
244  }
245 
246  val_ /= x.val();
247 
248  return *this;
249  }
250 
251  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
252  inline Fad<T> &operator=(const R& val)
253  {
254  val_ = val;
255 
256  if ( dx_.size() ) dx_ = T(0.);
257 
258  return *this;
259  }
260 
261  template<typename R, typename enable_if<is_convertible<R,T>::value,int>::type * = nullptr>
262  inline Fad<T> &operator=(const Fad<R>& rhs)
263  {
264  if ( this != (Fad<T>*)(&rhs) ) copy(rhs);
265 
266  return *this;
267  }
268 
269  int ClassId() const;
270 
271  template <class ExprT> Fad<T>& operator*= (const FadExpr<ExprT>& fadexpr);
272  template <class ExprT> Fad<T>& operator/= (const FadExpr<ExprT>& fadexpr);
273  template <class ExprT> Fad<T>& operator+= (const FadExpr<ExprT>& fadexpr);
274  template <class ExprT> Fad<T>& operator-= (const FadExpr<ExprT>& fadexpr);
275 
276  friend ostream& operator<< (ostream& stream, const Fad<T>& x)
277  {
278  const int VAL_WIDTH = 8;
279  stream << std::setw(VAL_WIDTH)<<std::right<<x.val()<<" dx: ";
280  for (int i=0; i<x.dx_.size(); i++) {
281  stream << std::setw(VAL_WIDTH)<<std::right<< x.dx_[i] << " ";
282  }
283  return stream;
284  }
285 
286  friend istream& operator>> (istream& stream, Fad<T>& x)
287  {
288  return stream >> x.val();
289  }
290 
291 };
292 
293 template<class T> inline
294 T fabs(const Fad<T> &val)
295 {
296  return fabs(val.val());
297 }
298 
299 //template<class T> inline
300 //double Norm(const Fad<T> &val)
301 //{
302 // DebugStop();
303 //}
304 
305 
306 template <class T> inline void Fad<T>::diff(const int ith, const int n)
307 {
308  if ( dx_.empty() ) dx_.resize(n);
309 
310  dx_ = T(0.);
311  dx_[ith] = T(1.);
312 
313 }
314 
315 template <class T> template <class ExprT> inline Fad<T> & Fad<T>::operator=(const FadExpr<ExprT>& fadexpr)
316 {
317  int sz = fadexpr.size();
318 
319  if ( sz != dx_.size() ) dx_.resize(sz);
320 
321  if ( sz ) {
322  T* RESTRICT dxp = dx_.begin();
323  if (fadexpr.hasFastAccess())
324  for(int i=0; i<sz; ++i)
325  dxp[i] = fadexpr.fastAccessDx(i);
326  else
327  for(int i=0; i<sz; ++i)
328  dxp[i] = fadexpr.dx(i);
329  }
330 
331  val_ = fadexpr.val();
332 
333  return *this;
334 }
335 
336 template <class T> inline FadExpr< FadUnaryPlus< Fad<T> > >
338 {
339  return FadExpr< FadUnaryPlus< Fad<T> > >(*this);
340 }
341 
342 template <class T> inline FadExpr< FadUnaryMin< Fad<T> > >
344 {
345  return FadExpr< FadUnaryMin< Fad<T> > >(*this);
346 }
347 
348 
349 template <class T> inline Fad<T> & Fad<T>::operator+= (const T& val)
350 {
351  val_ += val;
352 
353  return *this;
354 }
355 
356 template <class T> inline Fad<T> & Fad<T>::operator-= (const T& val)
357 {
358  val_ -= val;
359 
360  return *this;
361 }
362 
363 template <class T> inline Fad<T> & Fad<T>::operator*= (const T& val)
364 {
365  val_ *= val;
366 
367  int sz = dx_.size();
368  if ( sz ) {
369  T* RESTRICT dxp = dx_.begin();
370  for (int i=0; i<sz;++i)
371  dxp[i] *= val;
372  }
373 
374  return *this;
375 }
376 
377 template <class T> inline Fad<T> & Fad<T>::operator/= (const T& val)
378 {
379  val_ /= val;
380 
381  int sz = dx_.size();
382  if ( sz ) {
383  T* RESTRICT dxp = dx_.begin();
384  for (int i=0; i<sz;++i)
385  dxp[i] /= val;
386  }
387 
388  return *this;
389 }
390 
391 
392 
393 template <class T> template <class ExprT> inline Fad<T> & Fad<T>::operator+= (const FadExpr<ExprT>& x)
394 {
395  int xsz = x.size(), sz = dx_.size();
396 
397  if (xsz) {
398  if (sz) {
399  T* RESTRICT dxp = dx_.begin();
400  if (x.hasFastAccess())
401  for (int i=0; i<sz; ++i)
402  dxp[i] += x.fastAccessDx(i);
403  else
404  for (int i=0; i<sz; ++i)
405  dxp[i] += x.dx(i);
406  }
407  else {
408  dx_.resize(xsz);
409  T* RESTRICT dxp = dx_.begin();
410  if (x.hasFastAccess())
411  for (int i=0; i<xsz; ++i)
412  dxp[i] = x.fastAccessDx(i);
413  else
414  for (int i=0; i<xsz; ++i)
415  dxp[i] = x.dx(i);
416  }
417  }
418 
419  val_ += x.val();
420 
421  return *this;
422 }
423 
424 template <class T> template <class ExprT> inline Fad<T> & Fad<T>::operator-= (const FadExpr<ExprT>& x)
425 {
426  int xsz = x.size(), sz = dx_.size();
427 
428  if (xsz) {
429  if (sz) {
430  T* RESTRICT dxp = dx_.begin();
431  if (x.hasFastAccess())
432  for(int i=0; i<sz; ++i)
433  dxp[i] -= x.fastAccessDx(i);
434  else
435  for (int i=0; i<sz; ++i)
436  dxp[i] -= x.dx(i);
437  }
438  else {
439  dx_.resize(xsz);
440  T* RESTRICT dxp = dx_.begin();
441  if (x.hasFastAccess())
442  for(int i=0; i<xsz; ++i)
443  dxp[i] = -x.fastAccessDx(i);
444  else
445  for (int i=0; i<xsz; ++i)
446  dxp[i] = -x.dx(i);
447  }
448  }
449 
450  val_ -= x.val();
451 
452 
453  return *this;
454 }
455 
456 template <class T> template <class ExprT> inline Fad<T> & Fad<T>::operator*= (const FadExpr<ExprT>& x)
457 {
458  int xsz = x.size(), sz = dx_.size();
459  T xval = x.val();
460 
461  if (xsz) {
462  if (sz) {
463  T* RESTRICT dxp = dx_.begin();
464  if (x.hasFastAccess())
465  for(int i=0; i<sz; ++i)
466  dxp[i] = val_ * x.fastAccessDx(i) + dxp[i] * xval;
467  else
468  for (int i=0; i<sz; ++i)
469  dxp[i] = val_ * x.dx(i) + dxp[i] * xval;
470  }
471  else {
472  dx_.resize(xsz);
473  T* RESTRICT dxp = dx_.begin();
474  if (x.hasFastAccess())
475  for(int i=0; i<xsz; ++i)
476  dxp[i] = val_ * x.fastAccessDx(i);
477  else
478  for (int i=0; i<xsz; ++i)
479  dxp[i] = val_ * x.dx(i);
480  }
481  }
482  else {
483  if (sz) {
484  T* RESTRICT dxp = dx_.begin();
485  for (int i=0; i<sz; ++i)
486  dxp[i] *= xval;
487  }
488  }
489 
490  val_ *= xval;
491 
492  return *this;
493 }
494 
495 template <class T> template <class ExprT> inline Fad<T> & Fad<T>::operator/= (const FadExpr<ExprT>& x)
496 {
497  int xsz = x.size(), sz = dx_.size();
498  T xval = x.val();
499 
500  if (xsz) {
501  if (sz) {
502  T* RESTRICT dxp = dx_.begin();
503  if (x.hasFastAccess())
504  for(int i=0; i<sz; ++i)
505  dxp[i] = ( dxp[i]*xval - val_*x.fastAccessDx(i) )/ (xval*xval);
506  else
507  for (int i=0; i<sz; ++i)
508  dxp[i] = ( dxp[i]*xval - val_*x.dx(i) )/ (xval*xval);
509  }
510  else {
511  dx_.resize(xsz);
512  T* RESTRICT dxp = dx_.begin();
513  if (x.hasFastAccess())
514  for(int i=0; i<xsz; ++i)
515  dxp[i] = - val_*x.fastAccessDx(i) / (xval*xval);
516  else
517  for (int i=0; i<xsz; ++i)
518  dxp[i] = -val_ * x.dx(i) / (xval*xval);
519  }
520  }
521  else {
522  if (sz) {
523  T* RESTRICT dxp = dx_.begin();
524  for (int i=0; i<sz; ++i)
525  dxp[i] /= xval;
526  }
527  }
528 
529  val_ /= xval;
530 
531  return *this;
532 }
533 
534 
535 
536 
537 //------------------------------- Fad ostream operator ------------------------------------------
538 template <class T> inline ostream& operator << (ostream& os, const Fad<T>& a)
539 {
540  os.setf(ios::fixed,ios::floatfield);
541  os.width(12);
542  os << a.val() << " [";
543 
544 
545  for (int i=0; i< a.dx().size(); i++) {
546  os.width(12);
547  os << a.dx(i);
548  }
549 
550  os << "]\n";
551  return os;
552 }
553 
554 //------------------------------- Fad expression ------------------------------------------
555 template < class T > class FadExpr : public FadSuper {
556 public:
557  typedef typename T::value_type value_type;
558 
559 protected:
560  FadExpr() {}
561 
563 
564 public:
565  explicit FadExpr(const T& fadexpr) : fadexpr_(fadexpr) {;}
566 
567  value_type val() const { return fadexpr_.val();}
568  value_type dx(int i) const { return fadexpr_.dx(i);}
569  int size() const {return fadexpr_.size();}
570 
571  bool hasFastAccess() const { return fadexpr_.hasFastAccess();}
572  value_type fastAccessDx(int i) const { return fadexpr_.fastAccessDx(i);}
573 };
574 
575 //------------------------------- Fad constant ------------------------------------------
576 template <class T> class FadCst : public FadSuper {
577 public:
578  typedef T value_type;
579 
580 protected:
581  FadCst() {}
582 
583  const T constant_;
584  const T defaultVal;
585 
586 public:
587  explicit FadCst(const T &value) : constant_(value), defaultVal(T(0)) {}
588 
589  const value_type &val() const { return constant_; }
590  const value_type dx(int i) const { return defaultVal; }
591  int size() const { return 0; }
592 
593  bool hasFastAccess() const { return 1; }
594  const value_type &fastAccessDx(int i) const {
595  return defaultVal;
596  } // any i-th derivative of a constant is zero (i>0)
597 };
598 
599 //------------------------------- Fad unary + ------------------------------------------
600 template < class T > class FadUnaryPlus {
601 public:
602  typedef typename T::value_type value_type;
603 
604 protected:
606 
607  const T& expr_;
608 
609 public:
610  FadUnaryPlus(const T& value) : expr_(value) {;}
611 
612  const value_type val() const { return expr_.val();}
613  const value_type dx(int i) const { return expr_.dx(i);}
614  int size() const {return expr_.size();}
615 
616  bool hasFastAccess() const { return expr_.hasFastAccess();}
617  value_type fastAccessDx(int i) const { return expr_.fastAccessDx(i);}
618 };
619 
620 //------------------------------- Fad unary - ------------------------------------------
621 template < class T > class FadUnaryMin {
622 public:
623  typedef typename T::value_type value_type;
624 
625 protected:
627 
628  const T& expr_;
629 
630 public:
631  FadUnaryMin(const T& value) : expr_(value) {;}
632 
633  const value_type val() const { return - expr_.val();}
634  const value_type dx(int i) const { return - expr_.dx(i);}
635  int size() const {return expr_.size();}
636 
637  bool hasFastAccess() const { return expr_.hasFastAccess();}
638  value_type fastAccessDx(int i) const { return - expr_.fastAccessDx(i);}
639 };
640 
641 template <class T> inline
644 {
645  typedef FadUnaryPlus< FadExpr<T> > expr_t;
646 
647  return FadExpr< expr_t >( expr_t(expr) );
648 }
649 
650 template <class T> inline
653 {
654  typedef FadUnaryMin< FadExpr<T> > expr_t;
655 
656  return FadExpr< expr_t >( expr_t(expr) );
657 }
658 
659 template <class T>
660 int Fad<T>::ClassId() const{
661  return Hash("Fad") ^ (ClassIdOrHash<T>()<<1);
662 }
663 
664 
665 #include <Fad/fadlog.h>
666 #include <Fad/fadop.h>
667 #include <Fad/fadfunc.h>
668 
669 #endif
Fad(const int sz, const T &x)
Definition: fad.h:82
bool hasFastAccess() const
Definition: fad.h:571
int size() const
Definition: fad.h:569
FadUnaryMin(const T &value)
Definition: fad.h:631
const value_type val() const
Definition: fad.h:612
T defaultVal
Definition: fad.h:76
const value_type & val() const
Definition: fad.h:589
#define RESTRICT
Definition: vectors.h:34
value_type val() const
Definition: fad.h:567
FadExpr< FadUnaryPlus< FadExpr< T > > > operator+(const FadExpr< T > &expr)
Definition: fad.h:643
const T constant_
Definition: fad.h:583
int size() const
Definition: fad.h:127
bool hasFastAccess() const
Definition: fad.h:593
Definition: fad.h:36
value_type fastAccessDx(int i) const
Definition: fad.h:617
Fad(const FadExpr< ExprT > &fadexpr)
Definition: fad.h:93
const T & fastAccessDx(int i) const
Definition: fad.h:118
FadExpr< FadUnaryMin< Fad< T > > > operator-() const
Definition: fad.h:343
const T defaultVal
Definition: fad.h:584
const value_type dx(int i) const
Definition: fad.h:590
TPZVec< T > & operator-=(TPZVec< T > &a, const TPZVec< T > &b)
substracts two vectors
Definition: pzvec_extras.h:80
FadUnaryPlus(const T &value)
Definition: fad.h:610
int size() const
Definition: vectors.h:132
T & fastAccessDx(int i)
Definition: fad.h:117
Definition: fad.h:54
value_type fastAccessDx(int i) const
Definition: fad.h:572
bool hasFastAccess() const
Definition: fad.h:616
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
Fad(const int sz, const int i, const T &x)
Definition: fad.h:83
AutoPointerMutexArrayInit tmp
value_type fastAccessDx(int i) const
Definition: fad.h:638
std::istream & operator>>(std::istream &out, TPZFlopCounter &val)
Implements to read (input) only the floating point value.
Definition: pzreal.h:625
bool hasFastAccess() const
Definition: fad.h:637
T value_type
Definition: fad.h:578
const value_type & fastAccessDx(int i) const
Definition: fad.h:594
T & val()
Definition: fad.h:113
Fad< T > & operator=(const FadExpr< ExprT > &fadexpr)
Definition: fad.h:315
FadCst()
Definition: fad.h:581
int size() const
Definition: fad.h:635
const T & expr_
Definition: fad.h:628
f
Definition: test.py:287
expr_ dx(i) *cos(expr_.val())
T * begin() const
Definition: vectors.h:370
~FadSuper()
Definition: fad.h:51
Fad< T > & operator-=(const T &x)
Definition: fad.h:356
T::value_type value_type
Definition: fad.h:602
void resize(int)
Definition: vectors.h:339
Fad(const Fad< R > &rhs)
Definition: fad.h:87
Vector< T > dx_
Definition: fad.h:72
T dx(int i)
Definition: fad.h:125
FadSuper(const FadSuper &)
Definition: fad.h:50
T::value_type value_type
Definition: fad.h:623
int ClassId() const
Definition: fad.h:660
int size() const
Definition: fad.h:591
value_type dx(int i) const
Definition: fad.h:568
int size() const
Definition: fad.h:614
const value_type dx(int i) const
Definition: fad.h:634
const T & d(int i) const
Definition: fad.h:119
FadExpr< FadUnaryPlus< Fad< T > > > operator+() const
Definition: fad.h:337
void diff(const int ith, const int n)
Definition: fad.h:306
Fad< T > & operator/=(const T &x)
Definition: fad.h:377
Fad< T > & operator=(const Fad< R > &rhs)
Definition: fad.h:262
const T & val() const
Definition: fad.h:112
Definition: fad.h:47
Fad(const int sz, const T &x, const T &dx)
Definition: fad.h:85
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
T value_type
Definition: fad.h:56
Fad< T > & operator=(const R &val)
Definition: fad.h:252
Fad()
Definition: fad.h:78
const T & expr_
Definition: fad.h:607
void copy(const Fad< R > &rhs)
Definition: fad.h:59
T val_
Definition: fad.h:71
Fad< T > & operator+=(const T &x)
Definition: fad.h:349
const T & dx(int i) const
Definition: fad.h:124
Fad(const R &x)
Definition: fad.h:81
const value_type val() const
Definition: fad.h:633
FadUnaryMin()
Definition: fad.h:626
Fad< T > & operator*=(const T &x)
Definition: fad.h:363
FadExpr(const T &fadexpr)
Definition: fad.h:565
FadExpr< FadUnaryMin< FadExpr< T > > > operator-(const FadExpr< T > &expr)
Definition: fad.h:652
Definition: vectors.h:81
~Fad()
Definition: fad.h:106
FadExpr()
Definition: fad.h:560
const value_type dx(int i) const
Definition: fad.h:613
T fadexpr_
Definition: fad.h:562
bool hasFastAccess() const
Definition: fad.h:115
FadUnaryPlus()
Definition: fad.h:605
T fabs(const Fad< T > &val)
Definition: fad.h:294
FadCst(const T &value)
Definition: fad.h:587
const Vector< T > & dx() const
Definition: fad.h:110
FadSuper()
Definition: fad.h:49
T::value_type value_type
Definition: fad.h:557
Definition: fad.h:37