/[ascend]/trunk/ascend/compiler/reverse_ad.c
ViewVC logotype

Diff of /trunk/ascend/compiler/reverse_ad.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2325 by jpye, Wed Dec 15 06:35:43 2010 UTC revision 2326 by jpye, Tue Dec 21 11:35:07 2010 UTC
# Line 3  Line 3 
3      Copyright (C) 1993 Joseph James Zaher      Copyright (C) 1993 Joseph James Zaher
4      Copyright (C) 1993, 1994 Benjamin Andrew Allan, Joseph James Zaher      Copyright (C) 1993, 1994 Benjamin Andrew Allan, Joseph James Zaher
5      Copyright (C) 1996 Benjamin Andrew Allan, Kenneth Tyner      Copyright (C) 1996 Benjamin Andrew Allan, Kenneth Tyner
6      Copyright (C) 2006 Carnegie Mellon University      Copyright (C) 2006, 2010 Carnegie Mellon University
7    
8      This program is free software; you can redistribute it and/or modify      This program is free software; you can redistribute it and/or modify
9      it under the terms of the GNU General Public License as published by      it under the terms of the GNU General Public License as published by
# Line 59  Line 59 
59  /*----------- static function declarations & defines --------------*/  /*----------- static function declarations & defines --------------*/
60  static void TapeList_set_current(TapeList *tapes, unsigned index);  static void TapeList_set_current(TapeList *tapes, unsigned index);
61  static Element *TapeList_get_active_tape(TapeList *tapes);  static Element *TapeList_get_active_tape(TapeList *tapes);
62  static void TapeList_set_element(TapeList *tapes, Element *element);  
63    
64  static Element *TapeList_current_tape_insert(TapeList *tapes);  static Element *TapeList_current_tape_insert(TapeList *tapes);
65  static Element *Element_insert(Element **element);  static Element *Element_insert(Element **element);
66  static Redouble MakeIndepv(double value,unsigned long sindex,Element *tape,enum Expr_enum expr_type);  static Redouble MakeIndepv(double value,unsigned long sindex,Element *tape,enum Expr_enum expr_type);
# Line 67  static int ReturnSweep(Element *trace,in Line 68  static int ReturnSweep(Element *trace,in
68  static int AccumulateAdjoints(Element *trace, double* gradients);  static int AccumulateAdjoints(Element *trace, double* gradients);
69  static int ReturnSweepSafe(Element *trace, int both_sides,enum safe_err *serr);  static int ReturnSweepSafe(Element *trace, int both_sides,enum safe_err *serr);
70  static int AccumulateAdjointsSafe(Element *trace,double *gradients,enum safe_err *serr);  static int AccumulateAdjointsSafe(Element *trace,double *gradients,enum safe_err *serr);
71    
72    #ifdef INCLUDE_UNUSED_FUNCTIONS
73    static void TapeList_set_element(TapeList *tapes, Element *element);
74  static int check_inst_and_res(struct Instance *i, double *res);  static int check_inst_and_res(struct Instance *i, double *res);
75  static void PrintTape(Element *trace);  static void PrintTape(Element *trace);
76  static Element* TapeRewind(Element *trace);  static Element* TapeRewind(Element *trace);
77    #endif
78    
79  static Element* TapeRewindInitFwd(Element *trace,unsigned long var_index);  static Element* TapeRewindInitFwd(Element *trace,unsigned long var_index);
80  static int ReturnSweep2ndDeriv(Element *trace);  static int ReturnSweep2ndDeriv(Element *trace);
81  static int AccumulateDeriv2nd(Element *trace,double *deriv2nd,unsigned long num_var,int hessian_calc);  static int AccumulateDeriv2nd(Element *trace,double *deriv2nd,unsigned long num_var,int hessian_calc);
# Line 633  static Element *TapeList_get_active_tape Line 639  static Element *TapeList_get_active_tape
639      return tapes->tape[tapes->active];      return tapes->tape[tapes->active];
640  }  }
641    
642    #ifdef INCLUDE_UNUSED_FUNCTIONS
643  static void TapeList_set_element(TapeList *tapes, Element *element){  static void TapeList_set_element(TapeList *tapes, Element *element){
644      tapes->tape[tapes->active] = element;      tapes->tape[tapes->active] = element;
645  }  }
646    #endif
647    
648  /**  /**
649      Insert a new element at start of stack, return the new element so that it      Insert a new element at start of stack, return the new element so that it
# Line 935  static int AccumulateAdjointsSafe(Elemen Line 943  static int AccumulateAdjointsSafe(Elemen
943      return 0;      return 0;
944  }  }
945    
946    #ifdef INCLUDE_UNUSED_FUNCTIONS
947  /**  /**
948      Prints the contents of the tape for Debugging Purposes.      Prints the contents of the tape for Debugging Purposes.
949      @param trace is the tape on which the trace has been logged.      @param trace is the tape on which the trace has been logged.
# Line 962  static void PrintTape(Element *trace){ Line 971  static void PrintTape(Element *trace){
971          tracer = tracer->next;          tracer = tracer->next;
972      }      }
973  }  }
974    #endif
975    
976  /**----------------------Second Derivative Routines -----------------------------*/  /**----------------------Second Derivative Routines -----------------------------*/
977    
# Line 1453  static int ReturnSweep2ndDerivSafe(Eleme Line 1463  static int ReturnSweep2ndDerivSafe(Eleme
1463  }  }
1464    
1465  /**------------------------------------------------------------------------------- */  /**------------------------------------------------------------------------------- */
1466    #ifdef INCLUDE_UNUSED_FUNCTIONS
1467  /**  /**
1468      Rewinds the tape      Rewinds the tape
1469      @param trace is the tape on which trace information has been recorded      @param trace is the tape on which trace information has been recorded
# Line 1465  static Element* TapeRewind(Element* trac Line 1476  static Element* TapeRewind(Element* trac
1476      }      }
1477      return head;      return head;
1478  }  }
1479    #endif
1480    
1481  /**  /**
1482      Rewinds the tape & prepares it for a forward sweep by clearing values for      Rewinds the tape & prepares it for a forward sweep by clearing values for
# Line 1574  int RelationEvaluateHessianMtx(CONST str Line 1586  int RelationEvaluateHessianMtx(CONST str
1586                                  unsigned long dimension)                                  unsigned long dimension)
1587  {  {
1588      Element* hess_tape;      Element* hess_tape;
1589      Element* temp_tape;  //  Element* temp_tape;
1590      double residual;      double residual;
1591      double *row_pointer=NULL;      double *row_pointer=NULL;
1592      unsigned long i;      unsigned long i;
# Line 1614  int RelationEvaluateHessianMtxSafe(CONST Line 1626  int RelationEvaluateHessianMtxSafe(CONST
1626                                      enum safe_err *serr)                                      enum safe_err *serr)
1627  {  {
1628      Element* hess_tape;      Element* hess_tape;
1629      Element* temp_tape;  //  Element* temp_tape;
1630      double residual;      double residual;
1631      double *row_pointer;      double *row_pointer;
1632      unsigned long i;      unsigned long i;
# Line 1667  int TapeFree(Element* head){ Line 1679  int TapeFree(Element* head){
1679    
1680  /**---------------------------------------------------------------------------*/  /**---------------------------------------------------------------------------*/
1681  /* extra stuff from relation_util.c, just copied temporarily? -- JP */  /* extra stuff from relation_util.c, just copied temporarily? -- JP */
1682    #ifdef INCLUDE_UNUSED_FUNCTIONS
1683  #ifndef NDEBUG  #ifndef NDEBUG
1684  /**  /**
1685      Utility function to perform debug checking of (input) instance and residual      Utility function to perform debug checking of (input) instance and residual
# Line 1698  static int check_inst_and_res(struct Ins Line 1711  static int check_inst_and_res(struct Ins
1711    return 1;    return 1;
1712      return 1;      return 1;
1713  }  }
   
1714  #endif  #endif
1715    #endif
1716    

Legend:
Removed from v.2325  
changed lines
  Added in v.2326

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22