ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df33fun1.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <df1b2fun.h>
12 #include "df33fun.h"
13 
14 #ifndef OPT_LIB
15  #include <cassert>
16  #include <climits>
17 #endif
18 
19 void ad_read_pass2_dvdvdv(void);
20 
26  const df1b2variable * _py,const df1b2variable * pw,
27  const df1b2variable * pz,
28  double df_x, double df_y, double df_z,
29  double df_xx, double df_xy,double df_xz,double df_yy,
30  double df_yz,double df_zz,
31  double df_xxx,
32  double df_xxy,
33  double df_xxz,
34  double df_xyy,
35  double df_xyz,
36  double df_xzz,
37  double df_yyy,
38  double df_yyz,
39  double df_yzz,
40  double df_zzz)
41  {
44  ncount++;
45 #if defined(CHECK_COUNT)
46  if (ncount >= ncount_check)
47  ncount_checker(ncount,ncount_check);
48 #endif
49  size_t nvar=df1b2variable::nvar;
50 
51  size_t total_bytes=4*sizeof(df1b2_header)+sizeof(char*)
52  +(3*nvar+22)*sizeof(double);
53 
54 // string identifier debug stuff
55 #if defined(SAFE_ALL)
56  char ids[]="U8";
57  int slen=strlen(ids);
58  total_bytes+=slen;
59 #endif
60 
61  list.check_buffer_size(total_bytes);
62 
63  void * tmpptr=list.bptr;
64 #if defined(SAFE_ALL)
65  memcpy(list,ids,slen);
66 #endif
67 // end of string identifier debug stuff
68 
69  memcpy(list,(df1b2_header*)(px),sizeof(df1b2_header));
70  memcpy(list,(df1b2_header*)(py),sizeof(df1b2_header));
71  memcpy(list,(df1b2_header*)(pw),sizeof(df1b2_header));
72  memcpy(list,(df1b2_header*)(pz),sizeof(df1b2_header));
73  //memcpy(list,&pf,sizeof(char *));
74  //*(char**)(list.bptr)=(char*)pf;
75 
76  /*
77  memcpy(list,&df_x,sizeof(double));
78  memcpy(list,&df_y,sizeof(double));
79  memcpy(list,&df_xx,sizeof(double));
80  memcpy(list,&df_xy,sizeof(double));
81  memcpy(list,&df_yy,sizeof(double));
82  memcpy(list,&df_xxx,sizeof(double));
83  memcpy(list,&df_xxy,sizeof(double));
84  memcpy(list,&df_xyy,sizeof(double));
85  memcpy(list,&df_yyy,sizeof(double));
86  */
87  size_t sizeofdouble = sizeof(double);
88  memcpy(list,&df_x,sizeofdouble);
89  memcpy(list,&df_y,sizeofdouble);
90  memcpy(list,&df_z,sizeofdouble);
91  memcpy(list,&df_xx,sizeofdouble);
92  memcpy(list,&df_xy,sizeofdouble);
93  memcpy(list,&df_xz,sizeofdouble);
94  memcpy(list,&df_yy,sizeofdouble);
95  memcpy(list,&df_yz,sizeofdouble);
96  memcpy(list,&df_zz,sizeofdouble);
97  memcpy(list,&df_xxx,sizeofdouble);
98  memcpy(list,&df_xxy,sizeofdouble);
99  memcpy(list,&df_xxz,sizeofdouble);
100  memcpy(list,&df_xyy,sizeofdouble);
101  memcpy(list,&df_xyz,sizeofdouble);
102  memcpy(list,&df_xzz,sizeofdouble);
103  memcpy(list,&df_yyy,sizeofdouble);
104  memcpy(list,&df_yyz,sizeofdouble);
105  memcpy(list,&df_yzz,sizeofdouble);
106  memcpy(list,&df_zzz,sizeofdouble);
107 
108  memcpy(list,px->get_u(),sizeofdouble);
109  memcpy(list,py->get_u(),sizeofdouble);
110  memcpy(list,pw->get_u(),sizeofdouble);
111  memcpy(list,px->get_u_dot(),nvar*sizeofdouble);
112  memcpy(list,py->get_u_dot(),nvar*sizeofdouble);
113  memcpy(list,pw->get_u_dot(),nvar*sizeofdouble);
114  // ***** write record size
117  ++nlist;
118  return 0;
119  }
120 
121 
122 void read_pass2_1_dvdvdv(void);
123 void read_pass2_2_dvdvdv(void);
124 void read_pass2_3_dvdvdv(void);
125 
131 {
133  {
134  case 1:
136  break;
137  case 2:
139  break;
140  case 3:
142  break;
143  default:
144  cerr << "illegal value for df1b2variable::pass = "
146  ad_exit(1);
147  }
148 }
149 
155 {
156  // We are going backword for bptr and nbptr
157  // and forward for bptr2 and nbptr2
158  // the current entry+2 in bptr is the size of the record i.e
159  // points to the next record
160  //char * bptr=f1b2gradlist->bptr;
161  //char * bptr2=f1b2gradlist2->bptr;
162  size_t nvar = df1b2variable::nvar;
164  //f1b2gradlist->nlist-=sizeof(int);
165  int num_bytes=f1b2gradlist->nlist.bptr->numbytes;
166  list-=num_bytes;
167  list.saveposition(); // save pointer to beginning of record;
168  double xu,yu,wu;
169  //ad_dstar xdot,ydot;
170  //df1b2function2 * pf;
171 
172  // get info from tape1
173 #if defined(SAFE_ARRAYS)
175 #endif
176  char * bptr=f1b2gradlist->list.bptr;
177  df1b2_header * px=(df1b2_header *) bptr;
178  bptr+=sizeof(df1b2_header);
179  df1b2_header * py=(df1b2_header *) bptr;
180  bptr+=sizeof(df1b2_header);
181  df1b2_header * pw=(df1b2_header *) bptr;
182  bptr+=sizeof(df1b2_header);
183  df1b2_header * pz=(df1b2_header *) bptr;
184  bptr+=sizeof(df1b2_header);
185  //pf=*(df1b2function2 **) bptr;
186  //bptr+=sizeof(char*);
187 
188  double df1=*(double*) bptr;
189  bptr+=sizeof(double);
190 
191  double df2=*(double*) bptr;
192  bptr+=sizeof(double);
193 
194  double df3=*(double*) bptr;
195  bptr+=sizeof(double);
196 
197  double d2f11=*(double*) bptr;
198  bptr+=sizeof(double);
199 
200  double d2f12=*(double*) bptr;
201  bptr+=sizeof(double);
202 
203  double d2f13=*(double*) bptr;
204  bptr+=sizeof(double);
205 
206  double d2f22=*(double*) bptr;
207  bptr+=sizeof(double);
208 
209  double d2f23=*(double*) bptr;
210  bptr+=sizeof(double);
211 
212  double d2f33=*(double*) bptr;
213  bptr+=sizeof(double);
214 
215 #if defined(PRINT_DERS)
216  double d3f111=*(double*) bptr;
217 #endif
218  bptr+=sizeof(double);
219 
220 #if defined(PRINT_DERS)
221  double d3f112=*(double*) bptr;
222 #endif
223  bptr+=sizeof(double);
224 
225 #if defined(PRINT_DERS)
226  double d3f113=*(double*) bptr;
227 #endif
228  bptr+=sizeof(double);
229 
230 #if defined(PRINT_DERS)
231  double d3f122=*(double*) bptr;
232 #endif
233  bptr+=sizeof(double);
234 
235 #if defined(PRINT_DERS)
236  double d3f123=*(double*) bptr;
237 #endif
238  bptr+=sizeof(double);
239 
240 #if defined(PRINT_DERS)
241  double d3f133=*(double*) bptr;
242 #endif
243  bptr+=sizeof(double);
244 
245 #if defined(PRINT_DERS)
246  double d3f222=*(double*) bptr;
247 #endif
248  bptr+=sizeof(double);
249 
250 #if defined(PRINT_DERS)
251  double d3f223=*(double*) bptr;
252 #endif
253  bptr+=sizeof(double);
254 
255 #if defined(PRINT_DERS)
256  double d3f233=*(double*) bptr;
257 #endif
258  bptr+=sizeof(double);
259 
260 #if defined(PRINT_DERS)
261  double d3f333=*(double*) bptr;
262 #endif
263  bptr+=sizeof(double);
264 
265  memcpy(&xu,bptr,sizeof(double));
266  bptr+=sizeof(double);
267  memcpy(&yu,bptr,sizeof(double));
268  bptr+=sizeof(double);
269  memcpy(&wu,bptr,sizeof(double));
270  bptr+=sizeof(double);
271  double * xdot=(double*)bptr;
272  bptr+=nvar*sizeof(double);
273  double * ydot=(double*)bptr;
274  bptr+=nvar*sizeof(double);
275  double * wdot=(double*)bptr;
276 
277  list.restoreposition(); // save pointer to beginning of record;
278 
279  // ****************************************************************
280  // turn this off if no third derivatives are calculated
281  // if (!no_third_derivatives)
282  // {
283  // save for second reverse pass
284  // save identifier 1
285  test_smartlist & list2 = f1b2gradlist->list2;
286 
287 
288  size_t total_bytes=2*nvar*sizeof(double);
289 // string identifier debug stuff
290 #if defined(SAFE_ALL)
291  char ids[]="FX";
292  int slen=strlen(ids);
293  total_bytes+=slen;
294 #endif
295 
296  list2.check_buffer_size(total_bytes);
297  void * tmpptr=list2.bptr;
298 #if defined(SAFE_ALL)
299  memcpy(list2,ids,slen);
300 #endif
301 
303  size_t sizeofdouble = sizeof(double);
304  memcpy(list2,pz->get_u_bar(),nvar*sizeofdouble);
305  memcpy(list2,pz->get_u_dot_bar(),nvar*sizeofdouble);
306  *nlist2.bptr=adptr_diff(list2.bptr,tmpptr);
307  ++nlist2;
308  // }
309  //
310  // ****************************************************************
311 #if defined(PRINT_DERS)
312  print_derivatives(funname,(f),(df1),
313  (df2),(d2f11),(d2f12),(d2f22),
314  (d3f111),(d3f112),(d3f122),
315  (d3f222),1);
316  print_derivatives(pz,"z");
317  print_derivatives(px,"x");
318  print_derivatives(py,"y");
319 #endif
320 #if defined(__DERCHECK__)
321  if (derchecker)
322  if (derchecker->node_number)
323  {
324  if (derchecker->counter == derchecker->node_number)
325  {
326  switch (derchecker->pass_number) // increment the variable of interest
327  {
328  case 2:
329  switch(derchecker->vartype)
330  {
331  case 1:
332  if (!derchecker->dotflag)
333  px->u_bar[derchecker->index-1]+=derchecker->delta;
334  else
335  px->u_dot_bar[derchecker->index-1]+=derchecker->delta;
336  break;
337  case 2:
338  if (!derchecker->dotflag)
339  py->u_bar[derchecker->index-1]+=derchecker->delta;
340  else
341  py->u_dot_bar[derchecker->index-1]+=derchecker->delta;
342  break;
343  case 3:
344  if (!derchecker->dotflag)
345  pz->u_bar[derchecker->index-1]+=derchecker->delta;
346  else
347  pz->u_dot_bar[derchecker->index-1]+=derchecker->delta;
348  break;
349  default:
350  cerr << "Invalid index value for dercheck_index was "
351  << derchecker->index << endl;
352  break;
353  }
354  break;
355  case 3:
356  switch(derchecker->vartype)
357  {
358  case 1:
359  if (!derchecker->dotflag)
360  px->u_bar[derchecker->index-1]-=derchecker->delta;
361  else
362  px->u_dot_bar[derchecker->index-1]-=derchecker->delta;
363  break;
364  case 2:
365  if (!derchecker->dotflag)
366  py->u_bar[derchecker->index-1]-=derchecker->delta;
367  else
368  py->u_dot_bar[derchecker->index-1]-=derchecker->delta;
369  break;
370  case 3:
371  if (!derchecker->dotflag)
372  pz->u_bar[derchecker->index-1]-=derchecker->delta;
373  else
374  pz->u_dot_bar[derchecker->index-1]-=derchecker->delta;
375  break;
376  default:
377  cerr << "Invalid index value for dercheck_index was "
378  << derchecker->index << endl;
379  break;
380  }
381  break;
382  }
383  }
384  }
385 #endif
386 
387  // Do first reverse pass calculations
388  for (size_t i=0;i<nvar;i++)
389  {
390  px->u_bar[i]+=(df1)*pz->u_bar[i];
391  }
392  for (size_t i=0;i<nvar;i++)
393  {
394  py->u_bar[i]+=(df2)*pz->u_bar[i];
395  }
396  for (size_t i=0;i<nvar;i++)
397  {
398  pw->u_bar[i]+=(df3)*pz->u_bar[i];
399  }
400  for (size_t i=0;i<nvar;i++)
401  {
402  px->u_bar[i]+=(d2f11)*xdot[i]*pz->u_dot_bar[i];
403  px->u_bar[i]+=(d2f12)*ydot[i]*pz->u_dot_bar[i];
404  px->u_bar[i]+=(d2f13)*wdot[i]*pz->u_dot_bar[i];
405  }
406  for (size_t i=0;i<nvar;i++)
407  {
408  py->u_bar[i]+=(d2f12)*xdot[i]*pz->u_dot_bar[i];
409  py->u_bar[i]+=(d2f22)*ydot[i]*pz->u_dot_bar[i];
410  //py->u_bar[i]+=(d2f13)*wdot[i]*pz->u_dot_bar[i];
411  py->u_bar[i]+=(d2f23)*wdot[i]*pz->u_dot_bar[i];
412  }
413  for (size_t i=0;i<nvar;i++)
414  {
415  pw->u_bar[i]+=(d2f13)*xdot[i]*pz->u_dot_bar[i];
416  pw->u_bar[i]+=(d2f23)*ydot[i]*pz->u_dot_bar[i];
417  pw->u_bar[i]+=(d2f33)*wdot[i]*pz->u_dot_bar[i];
418  }
419  for (size_t i=0;i<nvar;i++)
420  {
421  px->u_dot_bar[i]+=(df1)*pz->u_dot_bar[i];
422  }
423  for (size_t i=0;i<nvar;i++)
424  {
425  py->u_dot_bar[i]+=(df2)*pz->u_dot_bar[i];
426  }
427  for (size_t i=0;i<nvar;i++)
428  {
429  pw->u_dot_bar[i]+=(df3)*pz->u_dot_bar[i];
430  }
431 
432  for (size_t i=0;i<nvar;i++)
433  {
434  pz->u_bar[i]=0;
435  }
436  for (size_t i=0;i<nvar;i++)
437  {
438  pz->u_dot_bar[i]=0;
439  }
440 }
441 
447 {
448  //const int nlist_record_size=sizeof(int)+sizeof(char*);
449  // We are going forward for bptr and backword for bptr2
450  //
451  // list 1
452  //
453  unsigned int nvar=df1b2variable::nvar;
455 
456  size_t total_bytes=3*sizeof(df1b2_header)+sizeof(char*)
457  +2*(nvar+1)*sizeof(double);
458 // string identifier debug stuff
459 #if defined(SAFE_ALL)
460  char ids[]="U8";
461  int slen=strlen(ids);
462  total_bytes+=slen;
463 #endif
464 
465  list.check_buffer_size(total_bytes);
466 // end of string identifier debug stuff
467 
468  list.saveposition(); // save pointer to beginning of record;
470  // nlist-=sizeof(int);
471  // get record size
472  int num_bytes=nlist.bptr->numbytes;
473  // nlist+=nlist_record_size;
474  //
475  // list 2
476  //
479  // get record size
480  int num_bytes2=*nlist2.bptr;
481  --nlist2;
482  // backup the size of the record
483  list2-=num_bytes2;
484  list2.saveposition(); // save pointer to beginning of record;
485  // save the pointer to the beginning of the record
486  // bptr and bptr2 now both point to the beginning of their records
487 
488  double xu,yu,wu;
489  //df1b2_header x,z;
490  //df1b2function2 * pf;
491 
492  // get info from tape1
493  // get info from tape1
494 #if defined(SAFE_ARRAYS)
495  checkidentiferstring("U8",list);
496  checkidentiferstring("FX",list2);
497 #endif
498  /*
499  df1b2_header * px=(df1b2_header *) list.bptr;
500  list.bptr+=sizeof(df1b2_header);
501  df1b2_header * py=(df1b2_header *) list.bptr;
502  list.bptr+=sizeof(df1b2_header);
503  df1b2_header * pz=(df1b2_header *) list.bptr;
504  list.bptr+=sizeof(df1b2_header);
505  pf=*(df1b2function2 **) list.bptr;
506  list.bptr+=sizeof(char*);
507  memcpy(&xu,list.bptr,sizeof(double));
508  list.bptr+=sizeof(double);
509  memcpy(&yu,list.bptr,sizeof(double));
510  list.bptr+=sizeof(double);
511  xdot=(double*)list.bptr;
512  list.bptr+=nvar*sizeof(double);
513  ydot=(double*)list.bptr;
514  */
515  //char * bptr=f1b2gradlist->list.bptr;
516  df1b2_header * px=(df1b2_header *) list.bptr;
517  list.bptr+=sizeof(df1b2_header);
518  df1b2_header * py=(df1b2_header *) list.bptr;
519  list.bptr+=sizeof(df1b2_header);
520  df1b2_header * pw=(df1b2_header *) list.bptr;
521  list.bptr+=sizeof(df1b2_header);
522  df1b2_header * pz=(df1b2_header *) list.bptr;
523  list.bptr+=sizeof(df1b2_header);
524 
525  double df1=*(double*) list.bptr;
526  list.bptr+=sizeof(double);
527 
528  double df2=*(double*) list.bptr;
529  list.bptr+=sizeof(double);
530 
531  double df3=*(double*) list.bptr;
532  list.bptr+=sizeof(double);
533 
534  double d2f11=*(double*) list.bptr;
535  list.bptr+=sizeof(double);
536 
537  double d2f12=*(double*) list.bptr;
538  list.bptr+=sizeof(double);
539 
540  double d2f13=*(double*) list.bptr;
541  list.bptr+=sizeof(double);
542 
543  double d2f22=*(double*) list.bptr;
544  list.bptr+=sizeof(double);
545 
546  double d2f23=*(double*) list.bptr;
547  list.bptr+=sizeof(double);
548 
549  double d2f33=*(double*) list.bptr;
550  list.bptr+=sizeof(double);
551 
552  double d3f111=*(double*) list.bptr;
553  list.bptr+=sizeof(double);
554 
555  double d3f112=*(double*) list.bptr;
556  list.bptr+=sizeof(double);
557 
558  double d3f113=*(double*) list.bptr;
559  list.bptr+=sizeof(double);
560 
561  double d3f122=*(double*) list.bptr;
562  list.bptr+=sizeof(double);
563 
564  double d3f123=*(double*) list.bptr;
565  list.bptr+=sizeof(double);
566 
567  double d3f133=*(double*) list.bptr;
568  list.bptr+=sizeof(double);
569 
570  double d3f222=*(double*) list.bptr;
571  list.bptr+=sizeof(double);
572 
573  double d3f223=*(double*) list.bptr;
574  list.bptr+=sizeof(double);
575 
576  double d3f233=*(double*) list.bptr;
577  list.bptr+=sizeof(double);
578 
579  double d3f333=*(double*) list.bptr;
580  list.bptr+=sizeof(double);
581 
582  memcpy(&xu,list.bptr,sizeof(double));
583  list.bptr+=sizeof(double);
584  memcpy(&yu,list.bptr,sizeof(double));
585  list.bptr+=sizeof(double);
586  memcpy(&wu,list.bptr,sizeof(double));
587  list.bptr+=sizeof(double);
588  double * xdot=(double*)list.bptr;
589  list.bptr+=nvar*sizeof(double);
590  double * ydot=(double*)list.bptr;
591  list.bptr+=nvar*sizeof(double);
592  double * wdot=(double*)list.bptr;
593 
594  list.restoreposition(num_bytes); // save pointer to beginning of record;
595 
596  double * zbar;
597  double * zdotbar;
598 
599 
600  zbar=(double*)list2.bptr;
601  zdotbar=(double*)(list2.bptr+nvar*sizeof(double));
602  list2.restoreposition(); // save pointer to beginning of record;
603 
604  double * x_tilde=px->get_u_tilde();
605  double * x_dot_tilde=px->get_u_dot_tilde();
606  double * x_bar_tilde=px->get_u_bar_tilde();
607  double * x_dot_bar_tilde=px->get_u_dot_bar_tilde();
608  double * y_tilde=py->get_u_tilde();
609  double * y_dot_tilde=py->get_u_dot_tilde();
610  double * y_bar_tilde=py->get_u_bar_tilde();
611  double * y_dot_bar_tilde=py->get_u_dot_bar_tilde();
612  double * w_tilde=pw->get_u_tilde();
613  double * w_dot_tilde=pw->get_u_dot_tilde();
614  double * w_bar_tilde=pw->get_u_bar_tilde();
615  double * w_dot_bar_tilde=pw->get_u_dot_bar_tilde();
616  double * z_bar_tilde=pz->get_u_bar_tilde();
617  double * z_dot_bar_tilde=pz->get_u_dot_bar_tilde();
618  // Do second "reverse-reverse" pass calculations
619 #if defined(PRINT_DERS)
620  print_derivatives(funname,(f),(df1),
621  (df2),(d2f11),(d2f12),(d2f22),
622  (d3f111),(d3f112),(d3f122),
623  (d3f222),1);
624  print_derivatives(pz,"z");
625  print_derivatives(px,"x");
626  print_derivatives(pw,"x");
627  print_derivatives(py,"y");
628 #endif
629 
630  for (size_t i=0;i<nvar;i++)
631  {
632  z_bar_tilde[i]=0;
633  z_dot_bar_tilde[i]=0;
634  }
635 
636  for (size_t i=0;i<nvar;i++)
637  {
638  *x_tilde+=(d2f11)*zbar[i]*x_bar_tilde[i];
639  *y_tilde+=(d2f12)*zbar[i]*x_bar_tilde[i];
640  *w_tilde+=(d2f13)*zbar[i]*x_bar_tilde[i];
641 
642  *x_tilde+=(d2f12)*zbar[i]*y_bar_tilde[i];
643  *y_tilde+=(d2f22)*zbar[i]*y_bar_tilde[i];
644  *w_tilde+=(d2f23)*zbar[i]*y_bar_tilde[i];
645 
646  *x_tilde+=(d2f13)*zbar[i]*w_bar_tilde[i];
647  *y_tilde+=(d2f23)*zbar[i]*w_bar_tilde[i];
648  *w_tilde+=(d2f33)*zbar[i]*w_bar_tilde[i];
649  }
650 
651  for (size_t i=0;i<nvar;i++)
652  {
653  *x_tilde+=(d2f11)*zdotbar[i]*x_dot_bar_tilde[i];
654  *y_tilde+=(d2f12)*zdotbar[i]*x_dot_bar_tilde[i];
655  *w_tilde+=(d2f13)*zdotbar[i]*x_dot_bar_tilde[i];
656 
657  *x_tilde+=(d2f12)*zdotbar[i]*y_dot_bar_tilde[i];
658  *y_tilde+=(d2f22)*zdotbar[i]*y_dot_bar_tilde[i];
659  *w_tilde+=(d2f23)*zdotbar[i]*y_dot_bar_tilde[i];
660 
661  *x_tilde+=(d2f13)*zdotbar[i]*w_dot_bar_tilde[i];
662  *y_tilde+=(d2f23)*zdotbar[i]*w_dot_bar_tilde[i];
663  *w_tilde+=(d2f33)*zdotbar[i]*w_dot_bar_tilde[i];
664  }
665 
666  for (size_t i=0;i<nvar;i++)
667  {
668  *x_tilde+=(d3f111)*xdot[i]*zdotbar[i]*x_bar_tilde[i];
669  *y_tilde+=(d3f112)*xdot[i]*zdotbar[i]*x_bar_tilde[i];
670  *w_tilde+=(d3f113)*xdot[i]*zdotbar[i]*x_bar_tilde[i];
671 
672  *x_tilde+=(d3f112)*xdot[i]*zdotbar[i]*y_bar_tilde[i];
673  *y_tilde+=(d3f122)*xdot[i]*zdotbar[i]*y_bar_tilde[i];
674  *w_tilde+=(d3f123)*xdot[i]*zdotbar[i]*y_bar_tilde[i];
675 
676  *x_tilde+=(d3f113)*xdot[i]*zdotbar[i]*w_bar_tilde[i];
677  *y_tilde+=(d3f123)*xdot[i]*zdotbar[i]*w_bar_tilde[i];
678  *w_tilde+=(d3f133)*xdot[i]*zdotbar[i]*w_bar_tilde[i];
679 
680  *x_tilde+=(d3f112)*ydot[i]*zdotbar[i]*x_bar_tilde[i];
681  *y_tilde+=(d3f122)*ydot[i]*zdotbar[i]*x_bar_tilde[i];
682  *w_tilde+=(d3f123)*ydot[i]*zdotbar[i]*x_bar_tilde[i];
683 
684  *x_tilde+=(d3f122)*ydot[i]*zdotbar[i]*y_bar_tilde[i];
685  *y_tilde+=(d3f222)*ydot[i]*zdotbar[i]*y_bar_tilde[i];
686  *w_tilde+=(d3f223)*ydot[i]*zdotbar[i]*y_bar_tilde[i];
687 
688  *x_tilde+=(d3f123)*ydot[i]*zdotbar[i]*w_bar_tilde[i];
689  *y_tilde+=(d3f223)*ydot[i]*zdotbar[i]*w_bar_tilde[i];
690  *w_tilde+=(d3f233)*ydot[i]*zdotbar[i]*w_bar_tilde[i];
691 
692  *x_tilde+=(d3f113)*wdot[i]*zdotbar[i]*x_bar_tilde[i];
693  *y_tilde+=(d3f123)*wdot[i]*zdotbar[i]*x_bar_tilde[i];
694  *w_tilde+=(d3f133)*wdot[i]*zdotbar[i]*x_bar_tilde[i];
695 
696  *x_tilde+=(d3f123)*wdot[i]*zdotbar[i]*y_bar_tilde[i];
697  *y_tilde+=(d3f223)*wdot[i]*zdotbar[i]*y_bar_tilde[i];
698  *w_tilde+=(d3f233)*wdot[i]*zdotbar[i]*y_bar_tilde[i];
699 
700  *x_tilde+=(d3f133)*wdot[i]*zdotbar[i]*w_bar_tilde[i];
701  *y_tilde+=(d3f233)*wdot[i]*zdotbar[i]*w_bar_tilde[i];
702  *w_tilde+=(d3f333)*wdot[i]*zdotbar[i]*w_bar_tilde[i];
703  }
704 
705  for (size_t i=0;i<nvar;i++)
706  {
707  z_bar_tilde[i]+=(df1)*x_bar_tilde[i];
708  z_bar_tilde[i]+=(df2)*y_bar_tilde[i];
709  z_bar_tilde[i]+=(df3)*w_bar_tilde[i];
710  }
711 
712  for (size_t i=0;i<nvar;i++)
713  {
714  z_dot_bar_tilde[i]+=(df1)*x_dot_bar_tilde[i];
715  z_dot_bar_tilde[i]+=(df2)*y_dot_bar_tilde[i];
716  z_dot_bar_tilde[i]+=(df3)*w_dot_bar_tilde[i];
717  }
718 
719  for (size_t i=0;i<nvar;i++)
720  {
721  x_dot_tilde[i]+=(d2f11)*zdotbar[i]*x_bar_tilde[i];
722  y_dot_tilde[i]+=(d2f12)*zdotbar[i]*x_bar_tilde[i];
723  w_dot_tilde[i]+=(d2f13)*zdotbar[i]*x_bar_tilde[i];
724 
725  x_dot_tilde[i]+=(d2f12)*zdotbar[i]*y_bar_tilde[i];
726  y_dot_tilde[i]+=(d2f22)*zdotbar[i]*y_bar_tilde[i];
727  w_dot_tilde[i]+=(d2f23)*zdotbar[i]*y_bar_tilde[i];
728 
729  x_dot_tilde[i]+=(d2f13)*zdotbar[i]*w_bar_tilde[i];
730  y_dot_tilde[i]+=(d2f23)*zdotbar[i]*w_bar_tilde[i];
731  w_dot_tilde[i]+=(d2f33)*zdotbar[i]*w_bar_tilde[i];
732  }
733 
734  for (size_t i=0;i<nvar;i++)
735  {
736  z_dot_bar_tilde[i]+=(d2f11)*xdot[i]*x_bar_tilde[i];
737  z_dot_bar_tilde[i]+=(d2f12)*xdot[i]*y_bar_tilde[i];
738  z_dot_bar_tilde[i]+=(d2f13)*xdot[i]*w_bar_tilde[i];
739 
740  z_dot_bar_tilde[i]+=(d2f12)*ydot[i]*x_bar_tilde[i];
741  z_dot_bar_tilde[i]+=(d2f22)*ydot[i]*y_bar_tilde[i];
742  z_dot_bar_tilde[i]+=(d2f23)*ydot[i]*w_bar_tilde[i];
743 
744  z_dot_bar_tilde[i]+=(d2f13)*wdot[i]*x_bar_tilde[i];
745  z_dot_bar_tilde[i]+=(d2f23)*wdot[i]*y_bar_tilde[i];
746  z_dot_bar_tilde[i]+=(d2f33)*wdot[i]*w_bar_tilde[i];
747  }
748 
749 
750 #if defined(__DERCHECK__)
751  if (derchecker->node_number)
752  {
753  if (derchecker->counter == derchecker->node_number)
754  {
755  if (derchecker->pass_number==1) // increment the variable of interest
756  {
757  switch(derchecker->vartype)
758  {
759  case 1:
760  if (!derchecker->dotflag)
761  derchecker->der_value=
762  px->u_bar_tilde[derchecker->index-1];
763  else
764  derchecker->der_value=
765  px->u_dot_bar_tilde[derchecker->index-1];
766  break;
767  case 2:
768  if (!derchecker->dotflag)
769  derchecker->der_value=
770  py->u_bar_tilde[derchecker->index-1];
771  else
772  derchecker->der_value=
773  py->u_dot_bar_tilde[derchecker->index-1];
774  break;
775  case 3:
776  if (!derchecker->dotflag)
777  derchecker->der_value=
778  pz->u_bar_tilde[derchecker->index-1];
779  else
780  derchecker->der_value=
781  pz->u_dot_bar_tilde[derchecker->index-1];
782  break;
783  default:
784  cerr << "Invalid index value for dercheck_index was "
785  << derchecker->index << endl;
786  }
787  }
788  }
789  }
790 #endif
791 #if defined(PRINT_DERS)
792  print_derivatives(pz,"z");
793  print_derivatives(px,"x");
794  print_derivatives(py,"y");
795 #endif
796 }
797 
803 {
804  // We are going backword for bptr and forward for bptr2
805  // the current entry+2 in bptr is the size of the record i.e
806  // points to the next record
807  unsigned int nvar=df1b2variable::nvar;
810  // nlist-=sizeof(int);
811  // get record size
812  int num_bytes=nlist.bptr->numbytes;
813  // backup the size of the record
814  list-=num_bytes;
815  list.saveposition(); // save pointer to beginning of record;
816  // save the pointer to the beginning of the record
817  double xu;
818  double yu;
819  double wu;
820  //df1b2_header x,z;
821  //df1b2function2 * pf;
822 
823  // get info from tape1
824  // get info from tape1
825 #if defined(SAFE_ARRAYS)
826  checkidentiferstring("U8",list);
827 #endif
828 
829  df1b2_header * px=(df1b2_header *) list.bptr;
830  list.bptr+=sizeof(df1b2_header);
831  df1b2_header * py=(df1b2_header *) list.bptr;
832  list.bptr+=sizeof(df1b2_header);
833  df1b2_header * pw=(df1b2_header *) list.bptr;
834  list.bptr+=sizeof(df1b2_header);
835  df1b2_header * pz=(df1b2_header *) list.bptr;
836  list.bptr+=sizeof(df1b2_header);
837 
838  double df1=*(double*) list.bptr;
839  list.bptr+=sizeof(double);
840 
841  double df2=*(double*) list.bptr;
842  list.bptr+=sizeof(double);
843 
844  double df3=*(double*) list.bptr;
845  list.bptr+=sizeof(double);
846 
847  double d2f11=*(double*) list.bptr;
848  list.bptr+=sizeof(double);
849 
850  double d2f12=*(double*) list.bptr;
851  list.bptr+=sizeof(double);
852 
853  double d2f13=*(double*) list.bptr;
854  list.bptr+=sizeof(double);
855 
856  double d2f22=*(double*) list.bptr;
857  list.bptr+=sizeof(double);
858 
859  double d2f23=*(double*) list.bptr;
860  list.bptr+=sizeof(double);
861 
862  double d2f33=*(double*) list.bptr;
863  list.bptr+=sizeof(double);
864 
865 #if defined(PRINT_DERS)
866  double d3f111=*(double*) list.bptr;
867 #endif
868  list.bptr+=sizeof(double);
869 
870 #if defined(PRINT_DERS)
871  double d3f112=*(double*) list.bptr;
872 #endif
873  list.bptr+=sizeof(double);
874 
875 #if defined(PRINT_DERS)
876  double d3f113=*(double*) list.bptr;
877 #endif
878  list.bptr+=sizeof(double);
879 
880 #if defined(PRINT_DERS)
881  double d3f122=*(double*) list.bptr;
882 #endif
883  list.bptr+=sizeof(double);
884 
885 #if defined(PRINT_DERS)
886  double d3f123=*(double*) list.bptr;
887 #endif
888  list.bptr+=sizeof(double);
889 
890 #if defined(PRINT_DERS)
891  double d3f133=*(double*) list.bptr;
892 #endif
893  list.bptr+=sizeof(double);
894 
895 #if defined(PRINT_DERS)
896  double d3f222=*(double*) list.bptr;
897 #endif
898  list.bptr+=sizeof(double);
899 
900 #if defined(PRINT_DERS)
901  double d3f223=*(double*) list.bptr;
902 #endif
903  list.bptr+=sizeof(double);
904 
905 #if defined(PRINT_DERS)
906  double d3f233=*(double*) list.bptr;
907 #endif
908  list.bptr+=sizeof(double);
909 
910 #if defined(PRINT_DERS)
911  double d3f333=*(double*) list.bptr;
912 #endif
913  list.bptr+=sizeof(double);
914 
915  memcpy(&xu,list.bptr,sizeof(double));
916  list.bptr+=sizeof(double);
917  memcpy(&yu,list.bptr,sizeof(double));
918  list.bptr+=sizeof(double);
919  memcpy(&wu,list.bptr,sizeof(double));
920  list.bptr+=sizeof(double);
921  double * xdot=(double*)list.bptr;
922  list.bptr+=nvar*sizeof(double);
923  double * ydot=(double*)list.bptr;
924  list.bptr+=nvar*sizeof(double);
925  double * wdot=(double*)list.bptr;
926 
927  list.restoreposition(); // save pointer to beginning of record;
928 #if defined(PRINT_DERS)
929  print_derivatives(funname,(f),(df1),
930  (df2),(d2f11),(d2f12),(d2f22),
931  (d3f111),(d3f112),(d3f122),
932  (d3f222),1);
933  print_derivatives(pz,"z");
934  print_derivatives(px,"x");
935  print_derivatives(py,"y");
936  print_derivatives(pw,"y");
937 #endif
938 
939  *(px->u_tilde)+=(df1)* *(pz->u_tilde);
940  *(py->u_tilde)+=(df2)* *(pz->u_tilde);
941  *(pw->u_tilde)+=(df3)* *(pz->u_tilde);
942 
943  for (size_t i=0;i<nvar;i++)
944  {
945  *(px->u_tilde)+=(d2f11)*xdot[i]*pz->u_dot_tilde[i];
946  *(py->u_tilde)+=(d2f12)*xdot[i]*pz->u_dot_tilde[i];
947  *(pw->u_tilde)+=(d2f13)*xdot[i]*pz->u_dot_tilde[i];
948 
949  *(px->u_tilde)+=(d2f12)*ydot[i]*pz->u_dot_tilde[i];
950  *(py->u_tilde)+=(d2f22)*ydot[i]*pz->u_dot_tilde[i];
951  *(pw->u_tilde)+=(d2f23)*ydot[i]*pz->u_dot_tilde[i];
952 
953  *(px->u_tilde)+=(d2f13)*wdot[i]*pz->u_dot_tilde[i];
954  *(py->u_tilde)+=(d2f23)*wdot[i]*pz->u_dot_tilde[i];
955  *(pw->u_tilde)+=(d2f33)*wdot[i]*pz->u_dot_tilde[i];
956  }
957  for (size_t i=0;i<nvar;i++)
958  {
959  px->u_dot_tilde[i]+=(df1)*pz->u_dot_tilde[i];
960  py->u_dot_tilde[i]+=(df2)*pz->u_dot_tilde[i];
961  pw->u_dot_tilde[i]+=(df3)*pz->u_dot_tilde[i];
962  }
963  *(pz->u_tilde)=0;
964  for (size_t i=0;i<nvar;i++)
965  {
966  pz->u_dot_tilde[i]=0;
967  }
968 
969 
970 #if defined(PRINT_DERS)
971  print_derivatives(pz,"z");
972  print_derivatives(px,"x");
973  print_derivatives(py,"y");
974  print_derivatives(pw,"y");
975 #endif
976 }
char * bptr
Definition: df1b2fun.h:543
double * get_u_bar_tilde() const
Definition: df1b2fun.h:234
void check_buffer_size(const size_t)
Description not yet available.
Definition: df1b2f10.cpp:185
df1b2_gradlist * f1b2gradlist
Definition: df1b2glo.cpp:49
void memcpy(test_smartlist &dest, void *source, const size_t nsize)
memcpy for test_smartlist
Definition: df1b2f10.cpp:367
double * u_bar_tilde
Definition: df1b2fun.h:201
double * u_bar
Definition: df1b2fun.h:197
Description not yet available.
double * get_u() const
Definition: df1b2fun.h:228
void read_pass2_1_dvdvdv(void)
Description not yet available.
Definition: df33fun1.cpp:154
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
void read_pass2_3_dvdvdv(void)
Description not yet available.
Definition: df33fun1.cpp:802
static int passnumber
Definition: df1b2fun.h:289
double * get_u_dot_tilde() const
Definition: df1b2fun.h:233
int adptr_diff(void *x, void *y)
Definition: df1b2fn2.cpp:110
exitptr ad_exit
Definition: gradstrc.cpp:53
void ncount_checker(int ncount, int ncount_check)
double * u_tilde
Definition: df1b2fun.h:199
void read_pass2_2_dvdvdv(void)
Description not yet available.
Definition: df33fun1.cpp:446
void restoreposition(void)
Definition: df1b2fun.h:560
Description not yet available.
Definition: df1b2fun.h:266
Description not yet available.
Definition: df1b2fun.h:669
fixed_smartlist nlist
Definition: df1b2fun.h:754
double * get_u_dot() const
Definition: df1b2fun.h:229
double * u_dot_bar_tilde
Definition: df1b2fun.h:202
Description not yet available.
Definition: df1b2fun.h:602
prnstream & endl(prnstream &)
double * u_dot_bar
Definition: df1b2fun.h:198
test_smartlist list
Definition: df1b2fun.h:753
void print_derivatives(const adstring &s, double f, double df, double d2f, double d3f, int bflag)
Description not yet available.
Definition: df1b2fn3.cpp:27
ADrfptr pf
Definition: df1b2fun.h:595
fixed_smartlist2 nlist2
Definition: df1b2fun.h:756
Description not yet available.
Definition: df1b2fun.h:527
double * get_u_dot_bar() const
Definition: df1b2fun.h:231
double * get_u_tilde() const
Definition: df1b2fun.h:232
int write_pass1(const df1b2variable *px, const df1b2variable *py, df1b2variable *pz, df1b2function2 *pf)
Description not yet available.
Definition: df1b2f12.cpp:17
double * get_u_dot_bar_tilde() const
Definition: df1b2fun.h:235
static unsigned int nvar
Definition: df1b2fun.h:290
void(* ADrfptr)(void)
Definition: df1b2fun.cpp:139
double * u_dot_tilde
Definition: df1b2fun.h:200
Base class for df1b2variable.
Definition: df1b2fun.h:191
Description not yet available.
fixed_list_entry * bptr
Definition: df1b2fun.h:626
void checkidentiferstring(const char *ids, test_smartlist &list)
Description not yet available.
Definition: df1b2fn5.cpp:256
double * get_u_bar() const
Definition: df1b2fun.h:230
int numbytes
Definition: df1b2fun.h:594
void saveposition(void)
Definition: df1b2fun.h:552
void ad_read_pass2_dvdvdv(void)
Description not yet available.
Definition: df33fun1.cpp:130
test_smartlist list2
Definition: df1b2fun.h:755