Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00011 #include <df1b2fun.h>
00012 void read_pass1_minus_eq_1(void);
00013 void read_pass1_minus_eq_2(void);
00014 void read_pass1_minus_eq_3(void);
00015
00016 #if defined(ADDEBUG_PRINT)
00017 extern int addebug_count;
00018 #endif
00019
00020
00025 df1b2variable& df1b2variable::operator -= (const df1b2variable& _x)
00026 {
00027 ADUNCONST(df1b2variable,x)
00028 double * xd=x.get_u_dot();
00029 double * zd=get_u_dot();
00030 *get_u()-=*x.get_u();
00031 for (unsigned int i=0;i<df1b2variable::nvar;i++)
00032 {
00033 *zd++ -= *xd++;
00034 }
00035
00036
00037
00038
00039
00040 if (!df1b2_gradlist::no_derivatives)
00041 f1b2gradlist->write_pass1_minuseq(&x,this);
00042 return *this;
00043 }
00044
00045 void ad_read_pass1_minus_eq(void);
00046
00051 int df1b2_gradlist::write_pass1_minuseq(const df1b2variable * _px,
00052 df1b2variable * pz)
00053 {
00054 ncount++;
00055 #if defined(CHECK_COUNT)
00056 if (ncount >= ncount_check)
00057 ncount_checker(ncount,ncount_check);
00058 #endif
00059
00060 ADUNCONST(df1b2variable*,px)
00061 fixed_smartlist & nlist=f1b2gradlist->nlist;
00062 test_smartlist& list=f1b2gradlist->list;
00063
00064 size_t total_bytes=sizeof(df1b2_header)+sizeof(df1b2_header);
00065 #if defined(SAFE_ALL)
00066 char ids[]="LC";
00067 int slen=strlen(ids);
00068 total_bytes+=slen;
00069 #endif
00070 list.check_buffer_size(total_bytes);
00071 void * tmpptr=list.bptr;
00072 #if defined(SAFE_ALL)
00073 memcpy(list,ids,slen);
00074 #endif
00075
00076 memcpy(list,(df1b2_header*)(px),sizeof(df1b2_header));
00077 memcpy(list,(df1b2_header*)(pz),sizeof(df1b2_header));
00078
00079
00080 nlist.bptr->numbytes=adptr_diff(list.bptr,tmpptr);
00081 nlist.bptr->pf=(ADrfptr)(&ad_read_pass1_minus_eq);
00082 ++nlist;
00083 return 0;
00084 }
00085
00090 void ad_read_pass1_minus_eq(void)
00091 {
00092 switch(df1b2variable::passnumber)
00093 {
00094 case 1:
00095 read_pass1_minus_eq_1();
00096 break;
00097 case 2:
00098 read_pass1_minus_eq_2();
00099 break;
00100 case 3:
00101 read_pass1_minus_eq_3();
00102 break;
00103 default:
00104 cerr << "illegal value for df1b2variable::pass = "
00105 << df1b2variable::passnumber << endl;
00106 exit(1);
00107 }
00108 }
00109
00114 void read_pass1_minus_eq_1(void)
00115 {
00116
00117
00118
00119 unsigned int nvar=df1b2variable::nvar;
00120 fixed_smartlist & nlist=f1b2gradlist->nlist;
00121 test_smartlist& list=f1b2gradlist->list;
00122
00123
00124 int num_bytes=nlist.bptr->numbytes;
00125
00126 list-=num_bytes;
00127 list.saveposition();
00128
00129 #if defined(SAFE_ALL)
00130 checkidentiferstring("LC",list);
00131 #endif
00132
00133
00134 df1b2_header * px=(df1b2_header *) list.bptr;
00135 list.bptr+=sizeof(df1b2_header);
00136 df1b2_header * pz=(df1b2_header *) list.bptr;
00137
00138 list.restoreposition();
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #if defined(SAFE_ALL)
00152
00153
00154
00155 #endif
00156
00157
00158 #if defined(SAFE_ALL)
00159
00160 #endif
00161
00162
00163
00164
00165
00166
00167
00168
00169 for (unsigned int i=0;i<nvar;i++)
00170 {
00171 px->u_bar[i]-=pz->u_bar[i];
00172 }
00173 for (unsigned int i=0;i<nvar;i++)
00174 {
00175 px->u_dot_bar[i]-=pz->u_dot_bar[i];
00176 }
00177 #if defined(PRINT_DERS)
00178 print_derivatives(px,"x");
00179 print_derivatives(pz,"z");
00180 #endif
00181 }
00182
00187 void read_pass1_minus_eq_2(void)
00188 {
00189
00190
00191
00192
00193
00194 unsigned int nvar=df1b2variable::nvar;
00195 test_smartlist & list=f1b2gradlist->list;
00196
00197 size_t total_bytes=sizeof(df1b2_header)+sizeof(df1b2_header);
00198 #if defined(SAFE_ALL)
00199 char ids[]="LC";
00200 int slen=strlen(ids);
00201 total_bytes+=slen;
00202 #endif
00203 list.check_buffer_size(total_bytes);
00204
00205 list.saveposition();
00206 fixed_smartlist & nlist=f1b2gradlist->nlist;
00207
00208
00209 int num_bytes=nlist.bptr->numbytes;
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 #if defined(SAFE_ALL)
00225 checkidentiferstring("LC",list);
00226
00227 #endif
00228
00229
00230
00231 df1b2_header * px=(df1b2_header *) list.bptr;
00232 list.bptr+=sizeof(df1b2_header);
00233 df1b2_header * pz=(df1b2_header *) list.bptr;
00234
00235 list.restoreposition(num_bytes);
00236
00237
00238
00239
00240
00241 double * x_bar_tilde=px->get_u_bar_tilde();
00242 double * x_dot_bar_tilde=px->get_u_dot_bar_tilde();
00243 double * z_bar_tilde=pz->get_u_bar_tilde();
00244 double * z_dot_bar_tilde=pz->get_u_dot_bar_tilde();
00245
00246 for (unsigned int i=0;i<nvar;i++)
00247 {
00248 z_bar_tilde[i]-=x_bar_tilde[i];
00249 }
00250
00251 for (unsigned int i=0;i<nvar;i++)
00252 {
00253 z_dot_bar_tilde[i]-=x_dot_bar_tilde[i];
00254 }
00255
00256 #if defined(PRINT_DERS)
00257 print_derivatives(px,"x");
00258 print_derivatives(pz,"z");
00259 #endif
00260 }
00261
00266 void read_pass1_minus_eq_3(void)
00267 {
00268
00269
00270
00271 unsigned int nvar=df1b2variable::nvar;
00272 fixed_smartlist & nlist=f1b2gradlist->nlist;
00273 test_smartlist& list=f1b2gradlist->list;
00274
00275
00276 int num_bytes=nlist.bptr->numbytes;
00277
00278 list-=num_bytes;
00279 list.saveposition();
00280
00281
00282 #if defined(SAFE_ALL)
00283 checkidentiferstring("LC",list);
00284 #endif
00285
00286 df1b2_header * px=(df1b2_header *) list.bptr;
00287 list.bptr+=sizeof(df1b2_header);
00288 df1b2_header * pz=(df1b2_header *) list.bptr;
00289
00290 list.restoreposition();
00291
00292
00293
00294 *(px->u_tilde)-=*pz->u_tilde;
00295 for (unsigned int i=0;i<nvar;i++)
00296 {
00297 px->u_dot_tilde[i]-=pz->u_dot_tilde[i];
00298 }
00299 #if defined(PRINT_DERS)
00300 print_derivatives(px,"x");
00301 print_derivatives(pz,"z");
00302 #endif
00303 }