1 #ifndef _tinyfadfifteen_h_ 2 #define _tinyfadfifteen_h_ 9 template <
class T>
class TinyFad<15,T> {
36 void diff(
const size_t ith,
const size_t sz){
55 case 0 : dx0_ = T(1.);
break;
56 case 1 : dx1_ = T(1.);
break;
57 case 2 : dx2_ = T(1.);
break;
58 case 3 : dx3_ = T(1.);
break;
59 case 4 : dx4_ = T(1.);
break;
60 case 5 : dx5_ = T(1.);
break;
61 case 6 : dx6_ = T(1.);
break;
62 case 7 : dx7_ = T(1.);
break;
63 case 8 : dx8_ = T(1.);
break;
64 case 9 : dx9_ = T(1.);
break;
65 case 10 : dx10_ = T(1.);
break;
66 case 11 : dx11_ = T(1.);
break;
67 case 12 : dx12_ = T(1.);
break;
68 case 13 : dx13_ = T(1.);
break;
69 case 14 : dx14_ = T(1.);
break;
70 default : cout <<
"ith = " << ith <<
" out of definition set" << endl;exit(1);
74 TinyFad(
const T& ind,
const int ini) : n(ini+1), val_(ind) {
92 case 0 : dx0_ = T(1.);
break;
93 case 1 : dx1_ = T(1.);
break;
94 case 2 : dx2_ = T(1.);
break;
95 case 3 : dx3_ = T(1.);
break;
96 case 4 : dx4_ = T(1.);
break;
97 case 5 : dx5_ = T(1.);
break;
98 case 6 : dx6_ = T(1.);
break;
99 case 7 : dx7_ = T(1.);
break;
100 case 8 : dx8_ = T(1.);
break;
101 case 9 : dx9_ = T(1.);
break;
102 case 10 : dx10_ = T(1.);
break;
103 case 11 : dx11_ = T(1.);
break;
104 case 12 : dx12_ = T(1.);
break;
105 case 13 : dx13_ = T(1.);
break;
106 case 14 : dx14_ = T(1.);
break;
107 default : cout <<
"ini = " << ini <<
" out of definition set" << endl;exit(1);
165 int N()
const {
return n-1;}
170 const T&
d0()
const {
return dx0_;}
171 T&
d0() {
return dx0_;}
173 const T&
d1()
const {
return dx1_;}
174 T&
d1() {
return dx1_;}
176 const T&
d2()
const {
return dx2_;}
177 T&
d2() {
return dx2_;}
179 const T&
d3()
const {
return dx3_;}
180 T&
d3() {
return dx3_;}
182 const T&
d4()
const {
return dx4_;}
183 T&
d4() {
return dx4_;}
185 const T&
d5()
const {
return dx5_;}
186 T&
d5() {
return dx5_;}
188 const T&
d6()
const {
return dx6_;}
189 T&
d6() {
return dx6_;}
191 const T&
d7()
const {
return dx7_;}
192 T&
d7() {
return dx7_;}
194 const T&
d8()
const {
return dx8_;}
195 T&
d8() {
return dx8_;}
197 const T&
d9()
const {
return dx9_;}
198 T&
d9() {
return dx9_;}
200 const T&
d10()
const {
return dx10_;}
203 const T&
d11()
const {
return dx11_;}
206 const T&
d12()
const {
return dx12_;}
209 const T&
d13()
const {
return dx13_;}
212 const T&
d14()
const {
return dx14_;}
217 case 0 :
return dx0_;
218 case 1 :
return dx1_;
219 case 2 :
return dx2_;
220 case 3 :
return dx3_;
221 case 4 :
return dx4_;
222 case 5 :
return dx5_;
223 case 6 :
return dx6_;
224 case 7 :
return dx7_;
225 case 8 :
return dx8_;
226 case 9 :
return dx9_;
227 case 10 :
return dx10_;
228 case 11 :
return dx11_;
229 case 12 :
return dx12_;
230 case 13 :
return dx13_;
231 case 14 :
return dx14_;
232 default : cout <<
"i out of bounds" << endl;exit(1);
235 const T&
dx(
int i)
const {
237 case 0 :
return dx0_;
238 case 1 :
return dx1_;
239 case 2 :
return dx2_;
240 case 3 :
return dx3_;
241 case 4 :
return dx4_;
242 case 5 :
return dx5_;
243 case 6 :
return dx6_;
244 case 7 :
return dx7_;
245 case 8 :
return dx8_;
246 case 9 :
return dx9_;
247 case 10 :
return dx10_;
248 case 11 :
return dx11_;
249 case 12 :
return dx12_;
250 case 13 :
return dx13_;
251 case 14 :
return dx14_;
252 default : cout <<
"i out of bounds" << endl;exit(1);
257 case 0 :
return dx0_;
258 case 1 :
return dx1_;
259 case 2 :
return dx2_;
260 case 3 :
return dx3_;
261 case 4 :
return dx4_;
262 case 5 :
return dx5_;
263 case 6 :
return dx6_;
264 case 7 :
return dx7_;
265 case 8 :
return dx8_;
266 case 9 :
return dx9_;
267 case 10 :
return dx10_;
268 case 11 :
return dx11_;
269 case 12 :
return dx12_;
270 case 13 :
return dx13_;
271 case 14 :
return dx14_;
272 default : cout <<
"i out of bounds" << endl;exit(1);
275 const T&
d(
int i)
const {
277 case 0 :
return dx0_;
278 case 1 :
return dx1_;
279 case 2 :
return dx2_;
280 case 3 :
return dx3_;
281 case 4 :
return dx4_;
282 case 5 :
return dx5_;
283 case 6 :
return dx6_;
284 case 7 :
return dx7_;
285 case 8 :
return dx8_;
286 case 9 :
return dx9_;
287 case 10 :
return dx10_;
288 case 11 :
return dx11_;
289 case 12 :
return dx12_;
290 case 13 :
return dx13_;
291 case 14 :
return dx14_;
292 default : cout <<
"i out of bounds" << endl;exit(1);
382 dx0_ = dx0_ * in.
val_ + val_ * in.
dx0_;
383 dx1_ = dx1_ * in.
val_ + val_ * in.
dx1_;
384 dx2_ = dx2_ * in.
val_ + val_ * in.
dx2_;
385 dx3_ = dx3_ * in.
val_ + val_ * in.
dx3_;
386 dx4_ = dx4_ * in.
val_ + val_ * in.
dx4_;
387 dx5_ = dx5_ * in.
val_ + val_ * in.
dx5_;
388 dx6_ = dx6_ * in.
val_ + val_ * in.
dx6_;
389 dx7_ = dx7_ * in.
val_ + val_ * in.
dx7_;
390 dx8_ = dx8_ * in.
val_ + val_ * in.
dx8_;
391 dx9_ = dx9_ * in.
val_ + val_ * in.
dx9_;
392 dx10_ = dx10_ * in.
val_ + val_ * in.
dx10_;
393 dx11_ = dx11_ * in.
val_ + val_ * in.
dx11_;
394 dx12_ = dx12_ * in.
val_ + val_ * in.
dx12_;
395 dx13_ = dx13_ * in.
val_ + val_ * in.
dx13_;
396 dx14_ = dx14_ * in.
val_ + val_ * in.
dx14_;
402 if (in.
val_ == 0.)
error(
"TinyFad & TinyFad::operator /= (const TinyFad & in), dividing by 0");
453 if ( in == T(0.) )
error(
"TinyFad & TinyFad::operator /= (const T & in), dividing by 0");
506 template <
class L,
class R>
inline 515 tmp.d0() = un.d0() + deux.d0();
517 tmp.d1() = un.d1() + deux.d1();
519 tmp.d2() = un.d2() + deux.d2();
521 tmp.d3() = un.d3() + deux.d3();
523 tmp.d4() = un.d4() + deux.d4();
525 tmp.d5() = un.d5() + deux.d5();
527 tmp.d6() = un.d6() + deux.d6();
529 tmp.d7() = un.d7() + deux.d7();
531 tmp.d8() = un.d8() + deux.d8();
533 tmp.d9() = un.d9() + deux.d9();
535 tmp.d10() = un.d10() + deux.d10();
537 tmp.d11() = un.d11() + deux.d11();
539 tmp.d12() = un.d12() + deux.d12();
541 tmp.d13() = un.d13() + deux.d13();
543 tmp.d14() = un.d14() + deux.d14();
550 template <
class L,
class R>
inline 579 tmp.d10() = un.d10();
581 tmp.d11() = un.d11();
583 tmp.d12() = un.d12();
585 tmp.d13() = un.d13();
587 tmp.d14() = un.d14();
589 tmp.
val() = un.
val() + deux;
594 template <
class L,
class R>
inline 600 template <
class L,
class R>
inline 609 tmp.d0() = un.d0()*deux.
val() + un.
val() * deux.d0();
611 tmp.d1() = un.d1()*deux.
val() + un.
val() * deux.d1();
613 tmp.d2() = un.d2()*deux.
val() + un.
val() * deux.d2();
615 tmp.d3() = un.d3()*deux.
val() + un.
val() * deux.d3();
617 tmp.d4() = un.d4()*deux.
val() + un.
val() * deux.d4();
619 tmp.d5() = un.d5()*deux.
val() + un.
val() * deux.d5();
621 tmp.d6() = un.d6()*deux.
val() + un.
val() * deux.d6();
623 tmp.d7() = un.d7()*deux.
val() + un.
val() * deux.d7();
625 tmp.d8() = un.d8()*deux.
val() + un.
val() * deux.d8();
627 tmp.d9() = un.d9()*deux.
val() + un.
val() * deux.d9();
629 tmp.d10() = un.d10()*deux.
val() + un.
val() * deux.d10();
631 tmp.d11() = un.d11()*deux.
val() + un.
val() * deux.d11();
633 tmp.d12() = un.d12()*deux.
val() + un.
val() * deux.d12();
635 tmp.d13() = un.d13()*deux.
val() + un.
val() * deux.d13();
637 tmp.d14() = un.d14()*deux.
val() + un.
val() * deux.d14();
644 template <
class L,
class R>
inline 653 tmp.d0() = un.d0()*deux;
655 tmp.d1() = un.d1()*deux;
657 tmp.d2() = un.d2()*deux;
659 tmp.d3() = un.d3()*deux;
661 tmp.d4() = un.d4()*deux;
663 tmp.d5() = un.d5()*deux;
665 tmp.d6() = un.d6()*deux;
667 tmp.d7() = un.d7()*deux;
669 tmp.d8() = un.d8()*deux;
671 tmp.d9() = un.d9()*deux;
673 tmp.d10() = un.d10()*deux;
675 tmp.d11() = un.d11()*deux;
677 tmp.d12() = un.d12()*deux;
679 tmp.d13() = un.d13()*deux;
681 tmp.d14() = un.d14()*deux;
683 tmp.
val() = un.
val() * deux;
688 template <
class L,
class R>
inline 696 template <
class L,
class R>
inline 705 tmp.d0() = un.d0() - deux.d0();
707 tmp.d1() = un.d1() - deux.d1();
709 tmp.d2() = un.d2() - deux.d2();
711 tmp.d3() = un.d3() - deux.d3();
713 tmp.d4() = un.d4() - deux.d4();
715 tmp.d5() = un.d5() - deux.d5();
717 tmp.d6() = un.d6() - deux.d6();
719 tmp.d7() = un.d7() - deux.d7();
721 tmp.d8() = un.d8() - deux.d8();
723 tmp.d9() = un.d9() - deux.d9();
725 tmp.d10() = un.d10() - deux.d10();
727 tmp.d11() = un.d11() - deux.d11();
729 tmp.d12() = un.d12() - deux.d12();
731 tmp.d13() = un.d13() - deux.d13();
733 tmp.d14() = un.d14() - deux.d14();
740 template <
class L,
class R>
inline 749 tmp.d0() -= deux.d0();
751 tmp.d1() -= deux.d1();
753 tmp.d2() -= deux.d2();
755 tmp.d3() -= deux.d3();
757 tmp.d4() -= deux.d4();
759 tmp.d5() -= deux.d5();
761 tmp.d6() -= deux.d6();
763 tmp.d7() -= deux.d7();
765 tmp.d8() -= deux.d8();
767 tmp.d9() -= deux.d9();
769 tmp.d10() -= deux.d10();
771 tmp.d11() -= deux.d11();
773 tmp.d12() -= deux.d12();
775 tmp.d13() -= deux.d13();
777 tmp.d14() -= deux.d14();
779 tmp.
val() = un - deux.
val();
784 template <
class L,
class R>
inline 812 tmp.d10() = un.d10();
814 tmp.d11() = un.d11();
816 tmp.d12() = un.d12();
818 tmp.d13() = un.d13();
820 tmp.d14() = un.d14();
822 tmp.
val() = un.
val() - deux;
827 template <
class L,
class R>
inline 833 if (deux.
val() == 0.)
error(
"TinyFad & TinyFad::operator /(const TinyFad<15,L> & un, const TinyFad<15,R> & deux), dividing by 0");
837 value_type dval = deux.
val();
839 tmp.d0() = ( un.d0()* deux.
val() - un.
val() * deux.d0() ) / dval / dval ;
841 tmp.d1() = ( un.d1()* deux.
val() - un.
val() * deux.d1() ) / dval / dval ;
843 tmp.d2() = ( un.d2()* deux.
val() - un.
val() * deux.d2() ) / dval / dval ;
845 tmp.d3() = ( un.d3()* deux.
val() - un.
val() * deux.d3() ) / dval / dval ;
847 tmp.d4() = ( un.d4()* deux.
val() - un.
val() * deux.d4() ) / dval / dval ;
849 tmp.d5() = ( un.d5()* deux.
val() - un.
val() * deux.d5() ) / dval / dval ;
851 tmp.d6() = ( un.d6()* deux.
val() - un.
val() * deux.d6() ) / dval / dval ;
853 tmp.d7() = ( un.d7()* deux.
val() - un.
val() * deux.d7() ) / dval / dval ;
855 tmp.d8() = ( un.d8()* deux.
val() - un.
val() * deux.d8() ) / dval / dval ;
857 tmp.d9() = ( un.d9()* deux.
val() - un.
val() * deux.d9() ) / dval / dval ;
859 tmp.d10() = ( un.d10()* deux.
val() - un.
val() * deux.d10() ) / dval / dval ;
861 tmp.d11() = ( un.d11()* deux.
val() - un.
val() * deux.d11() ) / dval / dval ;
863 tmp.d12() = ( un.d12()* deux.
val() - un.
val() * deux.d12() ) / dval / dval ;
865 tmp.d13() = ( un.d13()* deux.
val() - un.
val() * deux.d13() ) / dval / dval ;
867 tmp.d14() = ( un.d14()* deux.
val() - un.
val() * deux.d14() ) / dval / dval ;
869 tmp.
val() = un.
val() / dval;
874 template <
class L,
class R>
inline 880 if (deux.
val() == 0.)
error(
"TinyFad & TinyFad::operator /(const L & un, const TinyFad<15,R> & deux), dividing by 0");
884 value_type dval = deux.
val();
886 tmp.d0() = - un * deux.d0() / dval / dval ;
888 tmp.d1() = - un * deux.d1() / dval / dval ;
890 tmp.d2() = - un * deux.d2() / dval / dval ;
892 tmp.d3() = - un * deux.d3() / dval / dval ;
894 tmp.d4() = - un * deux.d4() / dval / dval ;
896 tmp.d5() = - un * deux.d5() / dval / dval ;
898 tmp.d6() = - un * deux.d6() / dval / dval ;
900 tmp.d7() = - un * deux.d7() / dval / dval ;
902 tmp.d8() = - un * deux.d8() / dval / dval ;
904 tmp.d9() = - un * deux.d9() / dval / dval ;
906 tmp.d10() = - un * deux.d10() / dval / dval ;
908 tmp.d11() = - un * deux.d11() / dval / dval ;
910 tmp.d12() = - un * deux.d12() / dval / dval ;
912 tmp.d13() = - un * deux.d13() / dval / dval ;
914 tmp.d14() = - un * deux.d14() / dval / dval ;
916 tmp.
val() = un / dval;
921 template <
class L,
class R>
inline 927 if (deux == 0.)
error(
"TinyFad & TinyFad::operator /(const TinyFad<15,L> & un, const R & deux), dividing by 0");
932 tmp.d0() = un.d0() / deux;
934 tmp.d1() = un.d1() / deux;
936 tmp.d2() = un.d2() / deux;
938 tmp.d3() = un.d3() / deux;
940 tmp.d4() = un.d4() / deux;
942 tmp.d5() = un.d5() / deux;
944 tmp.d6() = un.d6() / deux;
946 tmp.d7() = un.d7() / deux;
948 tmp.d8() = un.d8() / deux;
950 tmp.d9() = un.d9() / deux;
952 tmp.d10() = un.d10() / deux;
954 tmp.d11() = un.d11() / deux;
956 tmp.d12() = un.d12() / deux;
958 tmp.d13() = un.d13() / deux;
960 tmp.d14() = un.d14() / deux;
962 tmp.
val() = un.
val() / deux;
992 if ( in.
val() <= 0)
error(
"TinyFad log (const TinyFad& in) : zero or negative value");
1000 tmp.
d5() = in.
d5() / in.
val();
1001 tmp.
d6() = in.
d6() / in.
val();
1002 tmp.
d7() = in.
d7() / in.
val();
1003 tmp.
d8() = in.
d8() / in.
val();
1004 tmp.
d9() = in.
d9() / in.
val();
1016 if ( in.
val() < 0. )
error(
"TinyFad<15,T> sqrt (const TinyFad& in) : negative value");
1020 if ( in.
val() == T(0.) ){
1021 if ( in.
d0() != T(0.) ) test =
false;
1023 if ( in.
d1() != T(0.) ) test =
false;
1025 if ( in.
d2() != T(0.) ) test =
false;
1027 if ( in.
d3() != T(0.) ) test =
false;
1029 if ( in.
d4() != T(0.) ) test =
false;
1031 if ( in.
d5() != T(0.) ) test =
false;
1033 if ( in.
d6() != T(0.) ) test =
false;
1035 if ( in.
d7() != T(0.) ) test =
false;
1037 if ( in.
d8() != T(0.) ) test =
false;
1039 if ( in.
d9() != T(0.) ) test =
false;
1041 if ( in.
d10() != T(0.) ) test =
false;
1043 if ( in.
d11() != T(0.) ) test =
false;
1045 if ( in.
d12() != T(0.) ) test =
false;
1047 if ( in.
d13() != T(0.) ) test =
false;
1049 if ( in.
d14() != T(0.) ) test =
false;
1052 error(
"TinyFad<15,T> sqrt (const TinyFad& in) : null value");
1123 if ( in.
val() == 0)
error(
"TinyFad tan (const TinyFad& in) undiefined in 0.");
1126 T cosinus =
cos(in.
val());
1127 tmp.
d0() = in.
d0() / cosinus / cosinus;
1128 tmp.
d1() = in.
d1() / cosinus / cosinus;
1129 tmp.
d2() = in.
d2() / cosinus / cosinus;
1130 tmp.
d3() = in.
d3() / cosinus / cosinus;
1131 tmp.
d4() = in.
d4() / cosinus / cosinus;
1132 tmp.
d5() = in.
d5() / cosinus / cosinus;
1133 tmp.
d6() = in.
d6() / cosinus / cosinus;
1134 tmp.
d7() = in.
d7() / cosinus / cosinus;
1135 tmp.
d8() = in.
d8() / cosinus / cosinus;
1136 tmp.
d9() = in.
d9() / cosinus / cosinus;
1137 tmp.
d10() = in.
d10() / cosinus / cosinus;
1138 tmp.
d11() = in.
d11() / cosinus / cosinus;
1139 tmp.
d12() = in.
d12() / cosinus / cosinus;
1140 tmp.
d13() = in.
d13() / cosinus / cosinus;
1141 tmp.
d14() = in.
d14() / cosinus / cosinus;
1171 if (un.
val() == 0)
error(
"TinyFad pow (const TinyFad& un, const TinyFad& deux), un = 0. ");
1212 tmp.d0() = e*in.
d0()*
pow((
double)in.
val(), (double)e-1);
1213 tmp.d1() = e*in.
d1()*
pow((
double)in.
val(), (double)e-1);
1214 tmp.d2() = e*in.
d2()*
pow((
double)in.
val(), (double)e-1);
1215 tmp.d3() = e*in.
d3()*
pow((
double)in.
val(), (double)e-1);
1216 tmp.d4() = e*in.
d4()*
pow((
double)in.
val(), (double)e-1);
1217 tmp.d5() = e*in.
d5()*
pow((
double)in.
val(), (double)e-1);
1218 tmp.d6() = e*in.
d6()*
pow((
double)in.
val(), (double)e-1);
1219 tmp.d7() = e*in.
d7()*
pow((
double)in.
val(), (double)e-1);
1220 tmp.d8() = e*in.
d8()*
pow((
double)in.
val(), (double)e-1);
1221 tmp.d9() = e*in.
d9()*
pow((
double)in.
val(), (double)e-1);
1222 tmp.d10() = e*in.
d10()*
pow((
double)in.
val(), (double)e-1);
1223 tmp.d11() = e*in.
d11()*
pow((
double)in.
val(), (double)e-1);
1224 tmp.d12() = e*in.
d12()*
pow((
double)in.
val(), (double)e-1);
1225 tmp.d13() = e*in.
d13()*
pow((
double)in.
val(), (double)e-1);
1226 tmp.d14() = e*in.
d14()*
pow((
double)in.
val(), (double)e-1);
1233 int sign = in.
val() > 0? 1:0;
1235 if (sign)
return in;
1239 template <
class T> std::ostream& operator << (std::ostream& os, const TinyFad<15,T>& a)
1241 os.setf(std::ios::fixed,std::ios::scientific);
1243 os << a.
val() <<
" [";
TinyFad< 15, T > log(const TinyFad< 15, T > &in)
TinyFad< 15, T > & operator++()
TinyFad< Num, T > & operator-=(const TinyFad< Num, T > &in)
TinyFad< 15, T > operator-(const TinyFad< 15, T > &in)
TinyFad< 15, T > operator++(int)
TinyFad< 15, T > abs(const TinyFad< 15, T > &in)
TinyFad< 15, T > operator+(const TinyFad< 15, T > &in)
AutoPointerMutexArrayInit tmp
TinyFad< 15, T > sqrt(const TinyFad< 15, T > &in)
TinyFad< 15, T > pow(const TinyFad< 15, T > &in, double e)
TinyFad< Num, T > & operator=(const TinyFad< Num, T > &in)
TinyFad(const No_Initialization &)
TinyFad< 15, T > exp(const TinyFad< 15, T > &in)
TinyFad< Num, T > & operator+=(const TinyFad< Num, T > &in)
TinyFad< Num, T > & operator*=(const TinyFad< Num, T > &in)
TinyFad< 15, T > sin(const TinyFad< 15, T > &in)
TinyFad< 15, T > cos(const TinyFad< 15, T > &in)
TinyFad< Num, T > & operator/=(const TinyFad< Num, T > &in)
TinyFad< 15, T > & operator--()
TinyFad(const T &ind, const int ini)
TinyFad(const TinyFad< 15, T > &in)
TinyFad< 15, T > tan(const TinyFad< 15, T > &in)
void diff(const size_t ith, const size_t sz)
const T & dx(int i) const
TinyFad< 15, typename NumericalTraits< L, R >::promote > operator*(const TinyFad< 15, L > &un, const TinyFad< 15, R > &deux)
TinyFad< 15, T > operator--(int)
TinyFad< 15, typename NumericalTraits< L, R >::promote > operator/(const TinyFad< 15, L > &un, const TinyFad< 15, R > &deux)