Debian Codegraph @

packages/sacado/Fad/TinyFad/Specializations/tinyfadsix.h

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