9 template <
class T>
class TinyFad<6,T> {
27 void diff(
const size_t ith,
const size_t sz){
37 case 0 : dx0_ = T(1.);
break;
38 case 1 : dx1_ = T(1.);
break;
39 case 2 : dx2_ = T(1.);
break;
40 case 3 : dx3_ = T(1.);
break;
41 case 4 : dx4_ = T(1.);
break;
42 case 5 : dx5_ = T(1.);
break;
43 default : cout <<
"ith = " << ith <<
" out of definition set" << endl;exit(1);
47 TinyFad(
const T& ind,
const int ini) : n(ini+1), val_(ind) {
56 case 0 : dx0_ = T(1.);
break;
57 case 1 : dx1_ = T(1.);
break;
58 case 2 : dx2_ = T(1.);
break;
59 case 3 : dx3_ = T(1.);
break;
60 case 4 : dx4_ = T(1.);
break;
61 case 5 : dx5_ = T(1.);
break;
62 default : cout <<
"ini = " << ini <<
" out of definition set" << endl;exit(1);
93 int N()
const {
return n-1;}
98 const T&
d0()
const {
return dx0_;}
99 T&
d0() {
return dx0_;}
101 const T&
d1()
const {
return dx1_;}
102 T&
d1() {
return dx1_;}
104 const T&
d2()
const {
return dx2_;}
105 T&
d2() {
return dx2_;}
107 const T&
d3()
const {
return dx3_;}
108 T&
d3() {
return dx3_;}
110 const T&
d4()
const {
return dx4_;}
111 T&
d4() {
return dx4_;}
113 const T&
d5()
const {
return dx5_;}
114 T&
d5() {
return dx5_;}
118 case 0 :
return dx0_;
119 case 1 :
return dx1_;
120 case 2 :
return dx2_;
121 case 3 :
return dx3_;
122 case 4 :
return dx4_;
123 case 5 :
return dx5_;
124 default : cout <<
"i out of bounds" << endl;exit(1);
127 const T&
dx(
int i)
const {
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 default : cout <<
"i out of bounds" << endl;exit(1);
140 case 0 :
return dx0_;
141 case 1 :
return dx1_;
142 case 2 :
return dx2_;
143 case 3 :
return dx3_;
144 case 4 :
return dx4_;
145 case 5 :
return dx5_;
146 default : cout <<
"i out of bounds" << endl;exit(1);
149 const T&
d(
int i)
const {
151 case 0 :
return dx0_;
152 case 1 :
return dx1_;
153 case 2 :
return dx2_;
154 case 3 :
return dx3_;
155 case 4 :
return dx4_;
156 case 5 :
return dx5_;
157 default : cout <<
"i out of bounds" << endl;exit(1);
211 dx0_ = dx0_ * in.
val_ + val_ * in.
dx0_;
212 dx1_ = dx1_ * in.
val_ + val_ * in.
dx1_;
213 dx2_ = dx2_ * in.
val_ + val_ * in.
dx2_;
214 dx3_ = dx3_ * in.
val_ + val_ * in.
dx3_;
215 dx4_ = dx4_ * in.
val_ + val_ * in.
dx4_;
216 dx5_ = dx5_ * in.
val_ + val_ * in.
dx5_;
222 if (in.
val_ == 0.)
error(
"TinyFad & TinyFad::operator /= (const TinyFad & in), dividing by 0");
255 if ( in == T(0.) )
error(
"TinyFad & TinyFad::operator /= (const T & in), dividing by 0");
299 template <
class L,
class R>
inline 308 tmp.d0() = un.d0() + deux.d0();
310 tmp.d1() = un.d1() + deux.d1();
312 tmp.d2() = un.d2() + deux.d2();
314 tmp.d3() = un.d3() + deux.d3();
316 tmp.d4() = un.d4() + deux.d4();
318 tmp.d5() = un.d5() + deux.d5();
325 template <
class L,
class R>
inline 346 tmp.
val() = un.
val() + deux;
351 template <
class L,
class R>
inline 357 template <
class L,
class R>
inline 366 tmp.d0() = un.d0()*deux.
val() + un.
val() * deux.d0();
368 tmp.d1() = un.d1()*deux.
val() + un.
val() * deux.d1();
370 tmp.d2() = un.d2()*deux.
val() + un.
val() * deux.d2();
372 tmp.d3() = un.d3()*deux.
val() + un.
val() * deux.d3();
374 tmp.d4() = un.d4()*deux.
val() + un.
val() * deux.d4();
376 tmp.d5() = un.d5()*deux.
val() + un.
val() * deux.d5();
383 template <
class L,
class R>
inline 392 tmp.d0() = un.d0()*deux;
394 tmp.d1() = un.d1()*deux;
396 tmp.d2() = un.d2()*deux;
398 tmp.d3() = un.d3()*deux;
400 tmp.d4() = un.d4()*deux;
402 tmp.d5() = un.d5()*deux;
404 tmp.
val() = un.
val() * deux;
409 template <
class L,
class R>
inline 417 template <
class L,
class R>
inline 426 tmp.d0() = un.d0() - deux.d0();
428 tmp.d1() = un.d1() - deux.d1();
430 tmp.d2() = un.d2() - deux.d2();
432 tmp.d3() = un.d3() - deux.d3();
434 tmp.d4() = un.d4() - deux.d4();
436 tmp.d5() = un.d5() - deux.d5();
443 template <
class L,
class R>
inline 452 tmp.d0() -= deux.d0();
454 tmp.d1() -= deux.d1();
456 tmp.d2() -= deux.d2();
458 tmp.d3() -= deux.d3();
460 tmp.d4() -= deux.d4();
462 tmp.d5() -= deux.d5();
464 tmp.
val() = un - deux.
val();
469 template <
class L,
class R>
inline 489 tmp.
val() = un.
val() - deux;
494 template <
class L,
class R>
inline 500 if (deux.
val() == 0.)
error(
"TinyFad & TinyFad::operator /(const TinyFad<6,L> & un, const TinyFad<6,R> & deux), dividing by 0");
504 value_type dval = deux.
val();
506 tmp.d0() = ( un.d0()* deux.
val() - un.
val() * deux.d0() ) / dval / dval ;
508 tmp.d1() = ( un.d1()* deux.
val() - un.
val() * deux.d1() ) / dval / dval ;
510 tmp.d2() = ( un.d2()* deux.
val() - un.
val() * deux.d2() ) / dval / dval ;
512 tmp.d3() = ( un.d3()* deux.
val() - un.
val() * deux.d3() ) / dval / dval ;
514 tmp.d4() = ( un.d4()* deux.
val() - un.
val() * deux.d4() ) / dval / dval ;
516 tmp.d5() = ( un.d5()* deux.
val() - un.
val() * deux.d5() ) / dval / dval ;
518 tmp.
val() = un.
val() / dval;
523 template <
class L,
class R>
inline 529 if (deux.
val() == 0.)
error(
"TinyFad & TinyFad::operator /(const L & un, const TinyFad<6,R> & deux), dividing by 0");
533 value_type dval = deux.
val();
535 tmp.d0() = - un * deux.d0() / dval / dval ;
537 tmp.d1() = - un * deux.d1() / dval / dval ;
539 tmp.d2() = - un * deux.d2() / dval / dval ;
541 tmp.d3() = - un * deux.d3() / dval / dval ;
543 tmp.d4() = - un * deux.d4() / dval / dval ;
545 tmp.d5() = - un * deux.d5() / dval / dval ;
547 tmp.
val() = un / dval;
552 template <
class L,
class R>
inline 558 if (deux == 0.)
error(
"TinyFad & TinyFad::operator /(const TinyFad<6,L> & un, const R & deux), dividing by 0");
563 tmp.d0() = un.d0() / deux;
565 tmp.d1() = un.d1() / deux;
567 tmp.d2() = un.d2() / deux;
569 tmp.d3() = un.d3() / deux;
571 tmp.d4() = un.d4() / deux;
573 tmp.d5() = un.d5() / deux;
575 tmp.
val() = un.
val() / deux;
596 if ( in.
val() <= 0)
error(
"TinyFad log (const TinyFad& in) : zero or negative value");
611 if ( in.
val() < 0. )
error(
"TinyFad<6,T> sqrt (const TinyFad& in) : negative value");
615 if ( in.
val() == T(0.) ){
616 if ( in.
d0() != T(0.) ) test =
false;
618 if ( in.
d1() != T(0.) ) test =
false;
620 if ( in.
d2() != T(0.) ) test =
false;
622 if ( in.
d3() != T(0.) ) test =
false;
624 if ( in.
d4() != T(0.) ) test =
false;
626 if ( in.
d5() != T(0.) ) test =
false;
629 error(
"TinyFad<6,T> sqrt (const TinyFad& in) : null value");
673 if ( in.
val() == 0)
error(
"TinyFad tan (const TinyFad& in) undiefined in 0.");
676 T cosinus =
cos(in.
val());
677 tmp.
d0() = in.
d0() / cosinus / cosinus;
678 tmp.
d1() = in.
d1() / cosinus / cosinus;
679 tmp.
d2() = in.
d2() / cosinus / cosinus;
680 tmp.
d3() = in.
d3() / cosinus / cosinus;
681 tmp.
d4() = in.
d4() / cosinus / cosinus;
682 tmp.
d5() = in.
d5() / cosinus / cosinus;
703 if (un.
val() == 0)
error(
"TinyFad pow (const TinyFad& un, const TinyFad& deux), un = 0. ");
726 tmp.d0() = e*in.
d0()*
pow((
double)in.
val(), (double)e-1);
727 tmp.d1() = e*in.
d1()*
pow((
double)in.
val(), (double)e-1);
728 tmp.d2() = e*in.
d2()*
pow((
double)in.
val(), (double)e-1);
729 tmp.d3() = e*in.
d3()*
pow((
double)in.
val(), (double)e-1);
730 tmp.d4() = e*in.
d4()*
pow((
double)in.
val(), (double)e-1);
731 tmp.d5() = e*in.
d5()*
pow((
double)in.
val(), (double)e-1);
738 int sign = in.
val() > 0? 1:0;
744 template <
class T> std::ostream& operator << (std::ostream& os, const TinyFad<6,T>& a)
746 os.setf(std::ios::fixed,std::ios::scientific);
748 os << a.
val() <<
" [";
TinyFad< 6, typename NumericalTraits< L, R >::promote > operator/(const TinyFad< 6, L > &un, const TinyFad< 6, R > &deux)
TinyFad< Num, T > & operator-=(const TinyFad< Num, T > &in)
void diff(const size_t ith, const size_t sz)
TinyFad< 6, typename NumericalTraits< L, R >::promote > operator*(const TinyFad< 6, L > &un, const TinyFad< 6, R > &deux)
TinyFad< 6, T > log(const TinyFad< 6, T > &in)
AutoPointerMutexArrayInit tmp
TinyFad< 6, T > & operator++()
TinyFad< 6, T > sqrt(const TinyFad< 6, T > &in)
TinyFad< 6, T > sin(const TinyFad< 6, T > &in)
TinyFad(const TinyFad< 6, T > &in)
TinyFad< 6, T > operator++(int)
TinyFad< 6, T > operator+(const TinyFad< 6, T > &in)
TinyFad< 6, T > cos(const TinyFad< 6, T > &in)
TinyFad< Num, T > & operator=(const TinyFad< Num, T > &in)
const T & dx(int i) const
TinyFad< Num, T > & operator+=(const TinyFad< Num, T > &in)
TinyFad< 6, T > operator--(int)
TinyFad< 6, T > abs(const TinyFad< 6, T > &in)
TinyFad< Num, T > & operator*=(const TinyFad< Num, T > &in)
TinyFad< 6, T > pow(const TinyFad< 6, T > &in, double e)
TinyFad(const No_Initialization &)
TinyFad< Num, T > & operator/=(const TinyFad< Num, T > &in)
TinyFad< 6, T > exp(const TinyFad< 6, T > &in)
TinyFad< 6, T > operator-(const TinyFad< 6, T > &in)
TinyFad< 6, T > tan(const TinyFad< 6, T > &in)
TinyFad< 6, T > & operator--()
TinyFad(const T &ind, const int ini)