Actual source code: adintr_sqrt.c

petsc-3.3-p7 2013-05-11
  1: /*
  2:   macro expansion:
  3:   function_driver -> adintr_sqrt
  4:   exception number -> ADINTR_SQRT
  5:   exceptional code -> 
  6: *fx = ADIntr_Partials[ADINTR_SQRT][ADINTR_FX];
  7: *fxx = ADIntr_Partials[ADINTR_SQRT][ADINTR_FXX];

  9:   */

 11: #include <stdarg.h>
 12: #include <adintrinsics.h>
 13: #include <knr-compat.h>
 14: #if defined(__cplusplus)
 15: extern "C" {
 16: #endif

 18: /* #include "report-once.h" */
 19: void reportonce_accumulate Proto((int,int,int));


 22: void
 23: adintr_sqrt (int deriv_order, int file_number, int line_number,
 24:                  double*fx,...)
 25: {
 26:      /* Hack to make assignments to (*fxx) et alia OK, regardless */
 27:      double scratch;
 28:      double *fxx = &scratch;

 30:      const int exception = ADINTR_SQRT;

 32:      va_list argptr;
 33:      va_start(argptr,fx);

 35:      if (deriv_order == 2)
 36:      {
 37:           fxx = va_arg(argptr, double *);
 38:      }

 40:      /* Here is where exceptional partials should be set. */
 41: *fx = ADIntr_Partials[ADINTR_SQRT][ADINTR_FX];
 42: *fxx = ADIntr_Partials[ADINTR_SQRT][ADINTR_FXX];


 45:      /* Here is where we perform the action appropriate to the current mode. */
 46:      if (ADIntr_Mode == ADINTR_REPORTONCE)
 47:      {
 48:           reportonce_accumulate(file_number, line_number, exception);
 49:      }
 50: 
 51:      va_end(argptr);
 52: }
 53: #if defined(__cplusplus)
 54: }
 55: #endif