Actual source code: ad_grad_daxpy.h

  1: /*
  2: ,
  3:   THIS PROGRAM DISCLOSES MATERIAL PROTECTABLE UNDER COPYRIGHT

  5:   LAWS OF THE UNITED STATES.  FOR LICENSING INFORMATION CONTACT:



  9:   Christian Bischof or Lucas Roh, Mathematics and Computer Science Division,

 11:   Argonne National Laboratory, 9700 S. Cass Avenue, Argonne IL 60439,

 13:   {bischof,roh}@mcs.anl.gov.

 15: */

 17: #if !defined(AD_GRAD_DYN_H)
 18: #define AD_GRAD_DYN_H

 20: #include "../adic/run-alloc.h"


 23: #if defined(__cplusplus)
 25: #endif

 27: #define VALIDATE(px) \
 28:     if (!*px) { \
 29:         *px = (double*)ad_adic_deriv_alloc(); \
 30:     } \

 32: #define INVALIDATE(ppx) \
 33:     if (*ppx) { \
 34:         ad_adic_deriv_free(*ppx); \
 35:         *ppx = (double*)0; \
 36:     } 

 38: #define IS_ZERO(px) \
 39:     !px

 41: #define SET_ZERO_FLAG(flag, px, pos)\
 42:     if (IS_ZERO(px)) {\
 43:         flag |= (1<<pos);\
 44:     }

 46: 
 47: #define DAXPY1(ppz, a, pa) \
 48: {\
 49:     int _i; double*pz;\
 50:     VALIDATE(ppz);\
 51:     pz = *ppz; \
 52:     for (_i = 0; _i < ad_grad_size; _i++) {\
 53:         pz[_i] = a*pa[_i];\
 54:     }\
 55: }

 57: #define DAXPY2(ppz, a, pa, b, pb) \
 58: {\
 59:     int _i; double*pz;\
 60:     VALIDATE(ppz);\
 61:     pz = *ppz;\
 62:     for (_i = 0; _i < ad_grad_size; _i++) {\
 63:         pz[_i] = a*pa[_i] + b*pb[_i];\
 64:     }\
 65: }

 67: #define DAXPY3(ppz, a, pa, b, pb, c, pc) \
 68: {\
 69:     int _i; double*pz;\
 70:     VALIDATE(ppz);\
 71:     pz = *ppz;\
 72:     for (_i = 0; _i < ad_grad_size; _i++) {\
 73:         pz[_i] = a*pa[_i] + b*pb[_i] + c*pc[_i];\
 74:     }\
 75: }
 76: void ad_grad_daxpy_init(void);
 77: void ad_grad_daxpy_final(void);
 78: #define ad_grad_daxpy_free(pz) ad_adic_deriv_free(pz)
 79: void ad_grad_daxpy_0(double** ppz);

 81: void ad_grad_daxpy_copy(double** ppz, double* pa);

 83: void ad_grad_daxpy_1(double** pz, double a, double* pa);

 85: void ad_grad_daxpy_2(double** ppz, double a, double* pa, 
 86:                      double b, double* pb);

 88: void ad_grad_daxpy_3(double** ppz, double a, double* pa, 
 89:                      double b, double* pb, double c, double* pc);

 91: void ad_grad_daxpy_n(int n, double** ppz, ...);
 92: void ad_grad_daxpy_4(double** ppz, double ca, double* pa, double cb, double* pb, double cc, double* pc, double cd, double* pd);
 93: void ad_grad_daxpy_5(double** ppz, double ca, double* pa, double cb, double* pb, double cc, double* pc, double cd, double* pd, double ce, double* pe);

 95: #if defined(__cplusplus)
 96: }
 97: #endif
 98: #endif /*AD_GRAD_DYN_H*/