NeoPZ
tinyfadseven.h
Go to the documentation of this file.
1 #ifndef _tinyfadseven_h_
2 #define _tinyfadseven_h_
3 
4 //*********************************************************
5 // This file is generated by generate.cc.
6 // Use this file for any modification
7 //*********************************************************
8 
9 template <class T> class TinyFad<7,T> {
10 public:
11  typedef T value_type;
12  typedef T grad_type;
13 protected:
14 
15  int n;
16  T val_;
17 
18  T dx0_;
19  T dx1_;
20  T dx2_;
21  T dx3_;
22  T dx4_;
23  T dx5_;
24  T dx6_;
25 
26 
27 public:
28  void diff(const size_t ith, const size_t sz){
29  n = ith+1;
30  dx0_ = T(0.);
31  dx1_ = T(0.);
32  dx2_ = T(0.);
33  dx3_ = T(0.);
34  dx4_ = T(0.);
35  dx5_ = T(0.);
36  dx6_ = T(0.);
37 
38  switch(ith){
39  case 0 : dx0_ = T(1.);break;
40  case 1 : dx1_ = T(1.);break;
41  case 2 : dx2_ = T(1.);break;
42  case 3 : dx3_ = T(1.);break;
43  case 4 : dx4_ = T(1.);break;
44  case 5 : dx5_ = T(1.);break;
45  case 6 : dx6_ = T(1.);break;
46  default : cout << "ith = " << ith << " out of definition set" << endl;exit(1);
47  }
48  }
49 
50  TinyFad(const T& ind, const int ini) : n(ini+1), val_(ind) {
51  dx0_ = T(0.);
52  dx1_ = T(0.);
53  dx2_ = T(0.);
54  dx3_ = T(0.);
55  dx4_ = T(0.);
56  dx5_ = T(0.);
57  dx6_ = T(0.);
58 
59  switch(ini){
60  case 0 : dx0_ = T(1.);break;
61  case 1 : dx1_ = T(1.);break;
62  case 2 : dx2_ = T(1.);break;
63  case 3 : dx3_ = T(1.);break;
64  case 4 : dx4_ = T(1.);break;
65  case 5 : dx5_ = T(1.);break;
66  case 6 : dx6_ = T(1.);break;
67  default : cout << "ini = " << ini << " out of definition set" << endl;exit(1);
68  }
69  }
70  TinyFad() : n(0), val_(0.) {
71  dx0_ = T(0.);
72  dx1_ = T(0.);
73  dx2_ = T(0.);
74  dx3_ = T(0.);
75  dx4_ = T(0.);
76  dx5_ = T(0.);
77  dx6_ = T(0.);
78  }
79  TinyFad(const No_Initialization &): n(0) {}
80  TinyFad(const T& in) : n(0), val_(in) {
81  dx0_ = T(0.);
82  dx1_ = T(0.);
83  dx2_ = T(0.);
84  dx3_ = T(0.);
85  dx4_ = T(0.);
86  dx5_ = T(0.);
87  dx6_ = T(0.);
88  }
89  TinyFad(const TinyFad<7,T> & in) : n(0), val_(in.val_) {
90  dx0_ = in.dx0_;
91  dx1_ = in.dx1_;
92  dx2_ = in.dx2_;
93  dx3_ = in.dx3_;
94  dx4_ = in.dx4_;
95  dx5_ = in.dx5_;
96  dx6_ = in.dx6_;
97  }
98 
99  ~TinyFad() {}
100 
101  int N() const {return n-1;}
102 
103  const T& val() const { return val_;}
104  T& val() { return val_;}
105 
106  const T& d0() const { return dx0_;}
107  T& d0() { return dx0_;}
108 
109  const T& d1() const { return dx1_;}
110  T& d1() { return dx1_;}
111 
112  const T& d2() const { return dx2_;}
113  T& d2() { return dx2_;}
114 
115  const T& d3() const { return dx3_;}
116  T& d3() { return dx3_;}
117 
118  const T& d4() const { return dx4_;}
119  T& d4() { return dx4_;}
120 
121  const T& d5() const { return dx5_;}
122  T& d5() { return dx5_;}
123 
124  const T& d6() const { return dx6_;}
125  T& d6() { return dx6_;}
126 
127  T& dx(int i){
128  switch(i){
129  case 0 : return dx0_;
130  case 1 : return dx1_;
131  case 2 : return dx2_;
132  case 3 : return dx3_;
133  case 4 : return dx4_;
134  case 5 : return dx5_;
135  case 6 : return dx6_;
136  default : cout << "i out of bounds" << endl;exit(1);
137  }
138  }
139  const T& dx(int i) const {
140  switch(i){
141  case 0 : return dx0_;
142  case 1 : return dx1_;
143  case 2 : return dx2_;
144  case 3 : return dx3_;
145  case 4 : return dx4_;
146  case 5 : return dx5_;
147  case 6 : return dx6_;
148  default : cout << "i out of bounds" << endl;exit(1);
149  }
150  }
151  T& d(int i){
152  switch(i){
153  case 0 : return dx0_;
154  case 1 : return dx1_;
155  case 2 : return dx2_;
156  case 3 : return dx3_;
157  case 4 : return dx4_;
158  case 5 : return dx5_;
159  case 6 : return dx6_;
160  default : cout << "i out of bounds" << endl;exit(1);
161  }
162  }
163  const T& d(int i) const {
164  switch(i){
165  case 0 : return dx0_;
166  case 1 : return dx1_;
167  case 2 : return dx2_;
168  case 3 : return dx3_;
169  case 4 : return dx4_;
170  case 5 : return dx5_;
171  case 6 : return dx6_;
172  default : cout << "i out of bounds" << endl;exit(1);
173  }
174  }
175 
177  val_ = in.val_;
178 
179  dx0_ = in.dx0_;
180  dx1_ = in.dx1_;
181  dx2_ = in.dx2_;
182  dx3_ = in.dx3_;
183  dx4_ = in.dx4_;
184  dx5_ = in.dx5_;
185  dx6_ = in.dx6_;
186 
187  return *this;
188  }
189 
190  TinyFad<7,T> & operator = (const T & in){
191  val_ = in;
192 
193  dx0_ = T(0.);
194  dx1_ = T(0.);
195  dx2_ = T(0.);
196  dx3_ = T(0.);
197  dx4_ = T(0.);
198  dx5_ = T(0.);
199  dx6_ = T(0.);
200 
201  return *this;
202  }
203 
205  dx0_ += in.dx0_;
206  dx1_ += in.dx1_;
207  dx2_ += in.dx2_;
208  dx3_ += in.dx3_;
209  dx4_ += in.dx4_;
210  dx5_ += in.dx5_;
211  dx6_ += in.dx6_;
212  val_ += in.val_;
213 
214 
215  return *this;
216  }
218  dx0_ -= in.dx0_;
219  dx1_ -= in.dx1_;
220  dx2_ -= in.dx2_;
221  dx3_ -= in.dx3_;
222  dx4_ -= in.dx4_;
223  dx5_ -= in.dx5_;
224  dx6_ -= in.dx6_;
225  val_ -= in.val_;
226 
227  return *this;
228  }
230  dx0_ = dx0_ * in.val_ + val_ * in.dx0_;
231  dx1_ = dx1_ * in.val_ + val_ * in.dx1_;
232  dx2_ = dx2_ * in.val_ + val_ * in.dx2_;
233  dx3_ = dx3_ * in.val_ + val_ * in.dx3_;
234  dx4_ = dx4_ * in.val_ + val_ * in.dx4_;
235  dx5_ = dx5_ * in.val_ + val_ * in.dx5_;
236  dx6_ = dx6_ * in.val_ + val_ * in.dx6_;
237  val_ *= in.val_;
238 
239  return *this;
240  }
242  if (in.val_ == 0.) error("TinyFad & TinyFad::operator /= (const TinyFad & in), dividing by 0");
243  dx0_ = ( dx0_ * in.val_ - val_ * in.dx0_ ) / in.val_ / in.val_ ;
244  dx1_ = ( dx1_ * in.val_ - val_ * in.dx1_ ) / in.val_ / in.val_ ;
245  dx2_ = ( dx2_ * in.val_ - val_ * in.dx2_ ) / in.val_ / in.val_ ;
246  dx3_ = ( dx3_ * in.val_ - val_ * in.dx3_ ) / in.val_ / in.val_ ;
247  dx4_ = ( dx4_ * in.val_ - val_ * in.dx4_ ) / in.val_ / in.val_ ;
248  dx5_ = ( dx5_ * in.val_ - val_ * in.dx5_ ) / in.val_ / in.val_ ;
249  dx6_ = ( dx6_ * in.val_ - val_ * in.dx6_ ) / in.val_ / in.val_ ;
250  val_ /= in.val_;
251 
252  return *this;
253  }
254 
255  TinyFad<7,T> & operator += (const T & in){ val_ += in;
256 
257  return *this;
258  }
259  TinyFad<7,T> & operator -= (const T & in){ val_ -= in;
260 
261  return *this;
262  }
263  TinyFad<7,T> & operator *= (const T & in){
264  val_ *= in;
265 
266  dx0_ *= in;
267  dx1_ *= in;
268  dx2_ *= in;
269  dx3_ *= in;
270  dx4_ *= in;
271  dx5_ *= in;
272  dx6_ *= in;
273 
274  return *this;
275  }
276  TinyFad<7,T> & operator /= (const T & in){
277  if ( in == T(0.) ) error("TinyFad & TinyFad::operator /= (const T & in), dividing by 0");
278  val_ /= in;
279 
280  dx0_ /= in;
281  dx1_ /= in;
282  dx2_ /= in;
283  dx3_ /= in;
284  dx4_ /= in;
285  dx5_ /= in;
286  dx6_ /= in;
287 
288  return *this;
289  }
290 
292  TinyFad<7,T> tmp(*this);
293  tmp.val_++;
294  return tmp;
295  };
297  TinyFad<7,T> tmp(*this);
298  tmp.val_--;
299  return tmp;
300  };
302  return *this;
303  }
305  return *this;
306  }
307 };
308 
309 
310 template <class T> inline TinyFad<7,T> operator + (const TinyFad<7,T>& in)
311 {
312  return TinyFad<7,T>(in);
313 }
314 
315 template <class T> inline TinyFad<7,T> operator - (const TinyFad<7,T>& in)
316 {
318  tmp -= in;
319  return tmp;
320 }
321 
322 template <class L, class R> inline
324 operator +(const TinyFad<7,L>& un, const TinyFad<7,R>& deux) {
325 
326  typedef typename NumericalTraits<L,R>::promote value_type;
327 
328  No_Initialization nothing;
329  TinyFad<7,value_type> tmp( nothing );
330 
331  tmp.d0() = un.d0() + deux.d0();
332 
333  tmp.d1() = un.d1() + deux.d1();
334 
335  tmp.d2() = un.d2() + deux.d2();
336 
337  tmp.d3() = un.d3() + deux.d3();
338 
339  tmp.d4() = un.d4() + deux.d4();
340 
341  tmp.d5() = un.d5() + deux.d5();
342 
343  tmp.d6() = un.d6() + deux.d6();
344 
345  tmp.val() = un.val() + deux.val();
346 
347  return tmp;
348 }
349 
350 template <class L, class R> inline
352 operator +(const TinyFad<7,L>& un, const R& deux) {
353 
354  typedef typename NumericalTraits<L,R>::promote value_type;
355 
356  No_Initialization nothing;
357  TinyFad<7,value_type> tmp( nothing );
358 
359  tmp.d0() = un.d0();
360 
361  tmp.d1() = un.d1();
362 
363  tmp.d2() = un.d2();
364 
365  tmp.d3() = un.d3();
366 
367  tmp.d4() = un.d4();
368 
369  tmp.d5() = un.d5();
370 
371  tmp.d6() = un.d6();
372 
373  tmp.val() = un.val() + deux;
374 
375  return tmp;
376 }
377 
378 template <class L, class R> inline
380 operator +(const L& un, const TinyFad<7,R>& deux) {
381  return operator +(deux,un);
382 }
383 
384 template <class L, class R> inline
386 operator *(const TinyFad<7,L>& un, const TinyFad<7,R>& deux) {
387 
388  typedef typename NumericalTraits<L,R>::promote value_type;
389 
390  No_Initialization nothing;
391  TinyFad<7,value_type> tmp( nothing );
392 
393  tmp.d0() = un.d0()*deux.val() + un.val() * deux.d0();
394 
395  tmp.d1() = un.d1()*deux.val() + un.val() * deux.d1();
396 
397  tmp.d2() = un.d2()*deux.val() + un.val() * deux.d2();
398 
399  tmp.d3() = un.d3()*deux.val() + un.val() * deux.d3();
400 
401  tmp.d4() = un.d4()*deux.val() + un.val() * deux.d4();
402 
403  tmp.d5() = un.d5()*deux.val() + un.val() * deux.d5();
404 
405  tmp.d6() = un.d6()*deux.val() + un.val() * deux.d6();
406 
407  tmp.val() = un.val() * deux.val();
408 
409  return tmp;
410 }
411 
412 template <class L, class R> inline
414 operator *(const TinyFad<7,L>& un, const R& deux) {
415 
416  typedef typename NumericalTraits<L,R>::promote value_type;
417 
418  No_Initialization nothing;
419  TinyFad<7,value_type> tmp( nothing );
420 
421  tmp.d0() = un.d0()*deux;
422 
423  tmp.d1() = un.d1()*deux;
424 
425  tmp.d2() = un.d2()*deux;
426 
427  tmp.d3() = un.d3()*deux;
428 
429  tmp.d4() = un.d4()*deux;
430 
431  tmp.d5() = un.d5()*deux;
432 
433  tmp.d6() = un.d6()*deux;
434 
435  tmp.val() = un.val() * deux;
436 
437  return tmp;
438 }
439 
440 template <class L, class R> inline
442 operator *(const L& un, const TinyFad<7,R>& deux) {
443 
444  return operator *(deux,un);
445 }
446 
447 
448 template <class L, class R> inline
450 operator -(const TinyFad<7,L> & un, const TinyFad<7,R> & deux) {
451 
452  typedef typename NumericalTraits<L,R>::promote value_type;
453 
454  No_Initialization nothing;
455  TinyFad<7,value_type> tmp( nothing );
456 
457  tmp.d0() = un.d0() - deux.d0();
458 
459  tmp.d1() = un.d1() - deux.d1();
460 
461  tmp.d2() = un.d2() - deux.d2();
462 
463  tmp.d3() = un.d3() - deux.d3();
464 
465  tmp.d4() = un.d4() - deux.d4();
466 
467  tmp.d5() = un.d5() - deux.d5();
468 
469  tmp.d6() = un.d6() - deux.d6();
470 
471  tmp.val() = un.val() - deux.val();
472 
473  return tmp;
474 }
475 
476 template <class L, class R> inline
478 operator -(const L & un, const TinyFad<7,R> & deux) {
479 
480  typedef typename NumericalTraits<L,R>::promote value_type;
481 
482  No_Initialization nothing;
483  TinyFad<7,value_type> tmp( nothing );
484 
485  tmp.d0() -= deux.d0();
486 
487  tmp.d1() -= deux.d1();
488 
489  tmp.d2() -= deux.d2();
490 
491  tmp.d3() -= deux.d3();
492 
493  tmp.d4() -= deux.d4();
494 
495  tmp.d5() -= deux.d5();
496 
497  tmp.d6() -= deux.d6();
498 
499  tmp.val() = un - deux.val();
500 
501  return tmp;
502 }
503 
504 template <class L, class R> inline
506 operator -(const TinyFad<7,L> & un, const R & deux) {
507  typedef typename NumericalTraits<L,R>::promote value_type;
508 
509  No_Initialization nothing;
510  TinyFad<7,value_type> tmp( nothing );
511 
512  tmp.d0() = un.d0();
513 
514  tmp.d1() = un.d1();
515 
516  tmp.d2() = un.d2();
517 
518  tmp.d3() = un.d3();
519 
520  tmp.d4() = un.d4();
521 
522  tmp.d5() = un.d5();
523 
524  tmp.d6() = un.d6();
525 
526  tmp.val() = un.val() - deux;
527 
528  return tmp;
529 }
530 
531 template <class L, class R> inline
533 operator /(const TinyFad<7,L> & un, const TinyFad<7,R> & deux) {
534 
535  typedef typename NumericalTraits<L,R>::promote value_type;
536 
537  if (deux.val() == 0.) error("TinyFad & TinyFad::operator /(const TinyFad<7,L> & un, const TinyFad<7,R> & deux), dividing by 0");
538 
539  No_Initialization nothing;
540  TinyFad<7,value_type> tmp( nothing );
541  value_type dval = deux.val();
542 
543  tmp.d0() = ( un.d0()* deux.val() - un.val() * deux.d0() ) / dval / dval ;
544 
545  tmp.d1() = ( un.d1()* deux.val() - un.val() * deux.d1() ) / dval / dval ;
546 
547  tmp.d2() = ( un.d2()* deux.val() - un.val() * deux.d2() ) / dval / dval ;
548 
549  tmp.d3() = ( un.d3()* deux.val() - un.val() * deux.d3() ) / dval / dval ;
550 
551  tmp.d4() = ( un.d4()* deux.val() - un.val() * deux.d4() ) / dval / dval ;
552 
553  tmp.d5() = ( un.d5()* deux.val() - un.val() * deux.d5() ) / dval / dval ;
554 
555  tmp.d6() = ( un.d6()* deux.val() - un.val() * deux.d6() ) / dval / dval ;
556 
557  tmp.val() = un.val() / dval;
558 
559  return tmp;
560 }
561 
562 template <class L, class R> inline
564 operator /(const L & un, const TinyFad<7,R> & deux) {
565 
566  typedef typename NumericalTraits<L,R>::promote value_type;
567 
568  if (deux.val() == 0.) error("TinyFad & TinyFad::operator /(const L & un, const TinyFad<7,R> & deux), dividing by 0");
569 
570  No_Initialization nothing;
571  TinyFad<7,value_type> tmp( nothing );
572  value_type dval = deux.val();
573 
574  tmp.d0() = - un * deux.d0() / dval / dval ;
575 
576  tmp.d1() = - un * deux.d1() / dval / dval ;
577 
578  tmp.d2() = - un * deux.d2() / dval / dval ;
579 
580  tmp.d3() = - un * deux.d3() / dval / dval ;
581 
582  tmp.d4() = - un * deux.d4() / dval / dval ;
583 
584  tmp.d5() = - un * deux.d5() / dval / dval ;
585 
586  tmp.d6() = - un * deux.d6() / dval / dval ;
587 
588  tmp.val() = un / dval;
589 
590  return tmp;
591 }
592 
593 template <class L, class R> inline
595 operator /(const TinyFad<7,L> & un, const R & deux) {
596 
597  typedef typename NumericalTraits<L,R>::promote value_type;
598 
599  if (deux == 0.) error("TinyFad & TinyFad::operator /(const TinyFad<7,L> & un, const R & deux), dividing by 0");
600 
601  No_Initialization nothing;
602  TinyFad<7,value_type> tmp( nothing );
603 
604  tmp.d0() = un.d0() / deux;
605 
606  tmp.d1() = un.d1() / deux;
607 
608  tmp.d2() = un.d2() / deux;
609 
610  tmp.d3() = un.d3() / deux;
611 
612  tmp.d4() = un.d4() / deux;
613 
614  tmp.d5() = un.d5() / deux;
615 
616  tmp.d6() = un.d6() / deux;
617 
618  tmp.val() = un.val() / deux;
619 
620  return tmp;
621 }
622 
623 template <class T> TinyFad<7,T> exp (const TinyFad<7,T>& in)
624 {
625  TinyFad<7,T> tmp(exp(in.val()));
626 
627  tmp.d0() = in.d0()*exp(in.val());
628  tmp.d1() = in.d1()*exp(in.val());
629  tmp.d2() = in.d2()*exp(in.val());
630  tmp.d3() = in.d3()*exp(in.val());
631  tmp.d4() = in.d4()*exp(in.val());
632  tmp.d5() = in.d5()*exp(in.val());
633  tmp.d6() = in.d6()*exp(in.val());
634 
635  return tmp;
636 }
637 
638 template <class T> TinyFad<7,T> log (const TinyFad<7,T>& in)
639 {
640  if ( in.val() <= 0) error("TinyFad log (const TinyFad& in) : zero or negative value");
641  TinyFad<7,T> tmp(log(in.val()));
642 
643  tmp.d0() = in.d0() / in.val();
644  tmp.d1() = in.d1() / in.val();
645  tmp.d2() = in.d2() / in.val();
646  tmp.d3() = in.d3() / in.val();
647  tmp.d4() = in.d4() / in.val();
648  tmp.d5() = in.d5() / in.val();
649  tmp.d6() = in.d6() / in.val();
650 
651  return tmp;
652 }
653 
654 template <class T> TinyFad<7,T> sqrt (const TinyFad<7,T>& in)
655 {
656  if ( in.val() < 0. ) error("TinyFad<7,T> sqrt (const TinyFad& in) : negative value");
657  TinyFad<7,T> tmp(sqrt(in.val()));
658 
659  bool test=true;
660  if ( in.val() == T(0.) ){
661  if ( in.d0() != T(0.) ) test = false;
662 
663  if ( in.d1() != T(0.) ) test = false;
664 
665  if ( in.d2() != T(0.) ) test = false;
666 
667  if ( in.d3() != T(0.) ) test = false;
668 
669  if ( in.d4() != T(0.) ) test = false;
670 
671  if ( in.d5() != T(0.) ) test = false;
672 
673  if ( in.d6() != T(0.) ) test = false;
674 
675  if ( !test )
676  error("TinyFad<7,T> sqrt (const TinyFad& in) : null value");
677  }
678  else {
679  tmp.d0() = in.d0() / sqrt(in.val()) / 2.;
680  tmp.d1() = in.d1() / sqrt(in.val()) / 2.;
681  tmp.d2() = in.d2() / sqrt(in.val()) / 2.;
682  tmp.d3() = in.d3() / sqrt(in.val()) / 2.;
683  tmp.d4() = in.d4() / sqrt(in.val()) / 2.;
684  tmp.d5() = in.d5() / sqrt(in.val()) / 2.;
685  tmp.d6() = in.d6() / sqrt(in.val()) / 2.;
686  }
687 
688  return tmp;
689 }
690 
691 template <class T> TinyFad<7,T> sin (const TinyFad<7,T>& in)
692 {
693  TinyFad<7,T> tmp( sin(in.val()) );
694 
695  tmp.d0() = in.d0() * cos( in.val() );
696  tmp.d1() = in.d1() * cos( in.val() );
697  tmp.d2() = in.d2() * cos( in.val() );
698  tmp.d3() = in.d3() * cos( in.val() );
699  tmp.d4() = in.d4() * cos( in.val() );
700  tmp.d5() = in.d5() * cos( in.val() );
701  tmp.d6() = in.d6() * cos( in.val() );
702 
703  return tmp;
704 }
705 
706 template <class T> TinyFad<7,T> cos (const TinyFad<7,T>& in)
707 {
708  TinyFad<7,T> tmp(cos(in.val()));
709 
710  tmp.d0() = - in.d0() * sin( in.val() );
711  tmp.d1() = - in.d1() * sin( in.val() );
712  tmp.d2() = - in.d2() * sin( in.val() );
713  tmp.d3() = - in.d3() * sin( in.val() );
714  tmp.d4() = - in.d4() * sin( in.val() );
715  tmp.d5() = - in.d5() * sin( in.val() );
716  tmp.d6() = - in.d6() * sin( in.val() );
717 
718  return tmp;
719 }
720 
721 template <class T> TinyFad<7,T> tan (const TinyFad<7,T>& in)
722 {
723  if ( in.val() == 0) error("TinyFad tan (const TinyFad& in) undiefined in 0.");
724  TinyFad<7,T> tmp(tan(in.val()));
725 
726  T cosinus = cos(in.val());
727  tmp.d0() = in.d0() / cosinus / cosinus;
728  tmp.d1() = in.d1() / cosinus / cosinus;
729  tmp.d2() = in.d2() / cosinus / cosinus;
730  tmp.d3() = in.d3() / cosinus / cosinus;
731  tmp.d4() = in.d4() / cosinus / cosinus;
732  tmp.d5() = in.d5() / cosinus / cosinus;
733  tmp.d6() = in.d6() / cosinus / cosinus;
734 
735  return tmp;
736 }
737 
738 template <class T> TinyFad<7,T> pow (const TinyFad<7,T>& in, double e)
739 {
740  TinyFad<7,T> tmp(pow(in.val(), e));
741 
742  tmp.d0() = e*in.d0()*pow(in.val(), e-1);
743  tmp.d1() = e*in.d1()*pow(in.val(), e-1);
744  tmp.d2() = e*in.d2()*pow(in.val(), e-1);
745  tmp.d3() = e*in.d3()*pow(in.val(), e-1);
746  tmp.d4() = e*in.d4()*pow(in.val(), e-1);
747  tmp.d5() = e*in.d5()*pow(in.val(), e-1);
748  tmp.d6() = e*in.d6()*pow(in.val(), e-1);
749 
750  return tmp;
751 }
752 
753 template <class T> TinyFad<7,T> pow (const TinyFad<7,T>& un, const TinyFad<7,T>& deux)
754 {
755  if (un.val() == 0) error("TinyFad pow (const TinyFad& un, const TinyFad& deux), un = 0. ");
756  TinyFad<7,T> tmp(pow(un.val(), deux.val()));
757 
758  tmp.d0() = deux.d0() * log(un.val()) * pow(un.val(), deux.val())
759  + deux.val() * un.d0() * pow(un.val(), deux.val()-1);
760  tmp.d1() = deux.d1() * log(un.val()) * pow(un.val(), deux.val())
761  + deux.val() * un.d1() * pow(un.val(), deux.val()-1);
762  tmp.d2() = deux.d2() * log(un.val()) * pow(un.val(), deux.val())
763  + deux.val() * un.d2() * pow(un.val(), deux.val()-1);
764  tmp.d3() = deux.d3() * log(un.val()) * pow(un.val(), deux.val())
765  + deux.val() * un.d3() * pow(un.val(), deux.val()-1);
766  tmp.d4() = deux.d4() * log(un.val()) * pow(un.val(), deux.val())
767  + deux.val() * un.d4() * pow(un.val(), deux.val()-1);
768  tmp.d5() = deux.d5() * log(un.val()) * pow(un.val(), deux.val())
769  + deux.val() * un.d5() * pow(un.val(), deux.val()-1);
770  tmp.d6() = deux.d6() * log(un.val()) * pow(un.val(), deux.val())
771  + deux.val() * un.d6() * pow(un.val(), deux.val()-1);
772 
773  return tmp;
774 }
775 
776 template <class T> TinyFad<7,T> pow (const TinyFad<7,T>& in, const int e)
777 {
778  TinyFad<7,T> tmp( pow((double)in.val(), (double)e) );
779 
780  tmp.d0() = e*in.d0()*pow((double)in.val(), (double)e-1);
781  tmp.d1() = e*in.d1()*pow((double)in.val(), (double)e-1);
782  tmp.d2() = e*in.d2()*pow((double)in.val(), (double)e-1);
783  tmp.d3() = e*in.d3()*pow((double)in.val(), (double)e-1);
784  tmp.d4() = e*in.d4()*pow((double)in.val(), (double)e-1);
785  tmp.d5() = e*in.d5()*pow((double)in.val(), (double)e-1);
786  tmp.d6() = e*in.d6()*pow((double)in.val(), (double)e-1);
787 
788  return tmp;
789 }
790 
791 template <class T> TinyFad<7,T> abs (const TinyFad<7,T>& in)
792 {
793  int sign = in.val() > 0? 1:0;
794 
795  if (sign) return in;
796  else return (-in);
797 }
798 
799 template <class T> std::ostream& operator << (std::ostream& os, const TinyFad<7,T>& a)
800 {
801  os.setf(std::ios::fixed,std::ios::scientific);
802  os.width(12);
803  os << a.val() << " [";
804 
805  os.width(12);
806  os << a.d0();
807  os.width(12);
808  os << a.d1();
809  os.width(12);
810  os << a.d2();
811  os.width(12);
812  os << a.d3();
813  os.width(12);
814  os << a.d4();
815  os.width(12);
816  os << a.d5();
817  os.width(12);
818  os << a.d6();
819 
820  os << "]";
821 
822  return os;
823 }
824 
825 
826 #endif
TinyFad< 7, T > pow(const TinyFad< 7, T > &in, double e)
Definition: tinyfadseven.h:738
const T & d1() const
Definition: tinyfadseven.h:109
TinyFad< 7, T > operator--(int)
Definition: tinyfadseven.h:296
TinyFad< 7, T > operator+(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:310
TinyFad< Num, T > & operator-=(const TinyFad< Num, T > &in)
Definition: tinyfad.h:233
TinyFad(const T &ind, const int ini)
Definition: tinyfadseven.h:50
const T & dx(int i) const
Definition: tinyfadseven.h:139
TinyFad(const No_Initialization &)
Definition: tinyfadseven.h:79
TinyFad< 7, T > operator-(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:315
Definition: test.py:1
TinyFad< 7, typename NumericalTraits< L, R >::promote > operator*(const TinyFad< 7, L > &un, const TinyFad< 7, R > &deux)
Definition: tinyfadseven.h:386
TinyFad< 7, T > sqrt(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:654
const T & d0() const
Definition: tinyfadseven.h:106
TinyFad< 7, T > exp(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:623
AutoPointerMutexArrayInit tmp
T val_
Definition: tinyfad.h:47
TinyFad< 7, T > & operator++()
Definition: tinyfadseven.h:301
const T & d3() const
Definition: tinyfadseven.h:115
void error(char *string)
Definition: testShape.cc:7
TinyFad< 7, T > log(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:638
TinyFad(const T &in)
Definition: tinyfadseven.h:80
TinyFad< 7, T > & operator--()
Definition: tinyfadseven.h:304
TinyFad< 7, T > cos(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:706
T & dx(int i)
Definition: tinyfadseven.h:127
const T & d5() const
Definition: tinyfadseven.h:121
const T & d(int i) const
Definition: tinyfadseven.h:163
TinyFad< Num, T > & operator=(const TinyFad< Num, T > &in)
Definition: tinyfad.h:189
TinyFad< Num, T > & operator+=(const TinyFad< Num, T > &in)
Definition: tinyfad.h:219
T value_type
Definition: tinyfad.h:53
TinyFad< Num, T > & operator*=(const TinyFad< Num, T > &in)
Definition: tinyfad.h:247
TinyFad< 7, T > operator++(int)
Definition: tinyfadseven.h:291
const T & d6() const
Definition: tinyfadseven.h:124
const T & d4() const
Definition: tinyfadseven.h:118
void diff(const size_t ith, const size_t sz)
Definition: tinyfadseven.h:28
T & d(int i)
Definition: tinyfadseven.h:151
TinyFad< Num, T > & operator/=(const TinyFad< Num, T > &in)
Definition: tinyfad.h:261
TinyFad< 7, T > abs(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:791
int N() const
Definition: tinyfadseven.h:101
const T & d2() const
Definition: tinyfadseven.h:112
const T & val() const
Definition: tinyfadseven.h:103
TinyFad< 7, typename NumericalTraits< L, R >::promote > operator/(const TinyFad< 7, L > &un, const TinyFad< 7, R > &deux)
Definition: tinyfadseven.h:533
const T & val() const
Definition: tinyfad.h:72
TinyFad(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:89
TinyFad< 7, T > tan(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:721
TinyFad< 7, T > sin(const TinyFad< 7, T > &in)
Definition: tinyfadseven.h:691