00001
00002
00003
00004
00005
00006
00011 #include <df1b2fun.h>
00012
00017 df1b2variable pow(const df1b2variable& x,const df1b2variable& y)
00018 {
00019 df1b2variable z;
00020 double xu=*x.get_u();
00021 double yu=*y.get_u();
00022 double xpy3=::pow(xu,yu-3.0);
00023 double xpy2=xu*xpy3;
00024 double xpy1=xu*xpy2;
00025 *z.get_u()=xu*xpy1;
00026 double zu=*z.get_u();
00027 double logx=log(xu);
00028 double y1=yu-1.0;
00029 double y2=yu-2.0;
00030 double yy1=yu*y1;
00031
00032 double dfx= yu*xpy1;
00033 double dfy= zu*logx;
00034 double dfxx=yy1*xpy2;
00035 double dfxy=xpy1*(1.0+yu*logx);
00036 double dfyy=dfy*logx;
00037 double dfxxx=yy1*y2*xpy3;
00038 double dfxxy=xpy2*(yy1*logx+2.0*yu-1.0);
00039 double dfxyy=xpy1*logx*(yu*logx*logx+2.0);
00040 double dfyyy=dfyy*logx;
00041
00042 double * xd=x.get_u_dot();
00043 double * yd=y.get_u_dot();
00044 double * zd=z.get_u_dot();
00045
00046 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00047 {
00048 *zd++ = dfx * *xd++ + dfy * *yd++;
00049 }
00050
00051 f1b2gradlist->write_pass1(&x,&y,&z,
00052 dfx,
00053 dfy,
00054 dfxx,dfxy,dfyy,
00055 dfxxx,dfxxy,dfxyy,dfyyy);
00056 return z;
00057 }
00058
00063 df1b2variable pow(double x,const df1b2variable& y)
00064 {
00065 df1b2variable z;
00066 double yu=*y.get_u();
00067 double zu=::pow(x,yu);
00068 *z.get_u()=zu;
00069 double logx=log(x);
00070
00071 double dfy= zu*logx;
00072 double dfyy=dfy*logx;
00073 double dfyyy=dfyy*logx;
00074
00075 double * yd=y.get_u_dot();
00076 double * zd=z.get_u_dot();
00077
00078 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00079 {
00080 *zd++ = dfy * *yd++;
00081 }
00082
00083 f1b2gradlist->write_pass1(&y,&z,
00084 dfy,
00085 dfyy,
00086 dfyyy);
00087 return z;
00088 }
00089
00094 df1b2variable operator / (const df1b2variable& x,const df1b2variable& y)
00095 {
00096 df1b2variable z;
00097 double xu=*x.get_u();
00098 double yu=*y.get_u();
00099 double yinv=1.0/yu;
00100 *z.get_u()=xu*yinv;
00101
00102 double yinv2=yinv*yinv;
00103 double yinv3=yinv2*yinv;
00104
00105 double dfx= yinv;
00106 double dfy= -xu*yinv2;
00107 double dfxx= 0.0;
00108 double dfxy=-yinv2;
00109 double dfyy=2.0*xu*yinv3;
00110 double dfxxx= 0.0;
00111 double dfxxy= 0.0;
00112 double dfxyy=2.0*yinv3;
00113 double dfyyy=-6.0*xu*yinv3*yinv;
00114
00115 double * xd=x.get_u_dot();
00116 double * yd=y.get_u_dot();
00117 double * zd=z.get_u_dot();
00118
00119 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00120 {
00121 *zd++ = dfx * *xd++ + dfy * *yd++;
00122 }
00123
00124 f1b2gradlist->write_pass1(&x,&y,&z,
00125 dfx,
00126 dfy,
00127 dfxx,dfxy,dfyy,
00128 dfxxx,dfxxy,dfxyy,dfyyy);
00129 return z;
00130 }
00131
00136 df1b2variable operator / (double x,const df1b2variable& y)
00137 {
00138 df1b2variable z;
00139 double yu=*y.get_u();
00140 double yinv=1.0/yu;
00141 *z.get_u()=x*yinv;
00142 double zu=*z.get_u();
00143
00144
00145
00146
00147
00148
00149 double dfy=-zu*yinv;
00150 double dfyy=-2.0*dfy*yinv;
00151 double dfyyy=-3.0*dfyy*yinv;
00152
00153 double * yd=y.get_u_dot();
00154 double * zd=z.get_u_dot();
00155
00156 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00157 {
00158 *zd++ = dfy * *yd++;
00159 }
00160
00161 f1b2gradlist->write_pass1(&y,&z,
00162 dfy,
00163 dfyy,
00164 dfyyy);
00165 return z;
00166 }
00167
00172 df1b2variable pow(const df1b2variable& x,double y)
00173 {
00174 df1b2variable z;
00175 double xu=*x.get_u();
00176 *z.get_u()=::pow(xu,y);
00177
00178
00179 double dfx= y*::pow(xu,y-1.0);
00180 double dfxx= y*(y-1.0)*::pow(xu,y-2.0);
00181 double dfxxx= y*(y-1.0)*(y-2.0)*::pow(xu,y-3.0);
00182 double * xd=x.get_u_dot();
00183 double * zd=z.get_u_dot();
00184
00185 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00186 {
00187 *zd++ = dfx * *xd++ ;
00188 }
00189
00190 f1b2gradlist->write_pass1(&x,&z,
00191 dfx,
00192 dfxx,
00193 dfxxx);
00194 return z;
00195 }
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222