Node.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Node.h
  3. *
  4. * Created on: 8 Apr 2013
  5. * Author: s0965328
  6. */
  7. #ifndef NODE_H_
  8. #define NODE_H_
  9. #include <boost/unordered_set.hpp>
  10. #include "auto_diff_types.h"
  11. using namespace std;
  12. namespace AutoDiff {
  13. class EdgeSet;
  14. class Node {
  15. public:
  16. Node();
  17. virtual ~Node();
  18. virtual void eval_function() = 0;
  19. virtual void grad_reverse_0() = 0;
  20. virtual void grad_reverse_1_init_adj() = 0;
  21. virtual void grad_reverse_1() = 0;
  22. virtual void update_adj(double& v) = 0;
  23. virtual unsigned int hess_reverse_0() = 0;
  24. virtual void hess_reverse_0_init_n_in_arcs();
  25. virtual void hess_reverse_0_get_values(unsigned int,double&, double&,double&, double&) = 0;
  26. virtual void hess_reverse_1(unsigned int i) = 0;
  27. virtual void hess_reverse_1_init_x_bar(unsigned int) = 0;
  28. virtual void update_x_bar(unsigned int,double) = 0;
  29. virtual void update_w_bar(unsigned int,double) = 0;
  30. virtual void hess_reverse_1_get_xw(unsigned int, double&,double&) = 0;
  31. virtual void hess_reverse_get_x(unsigned int,double& x)=0;
  32. virtual void hess_reverse_1_clear_index();
  33. //routing for checking non-zero structures
  34. virtual void collect_vnodes(boost::unordered_set<Node*>& nodes,unsigned int& total) = 0;
  35. virtual void nonlinearEdges(EdgeSet&) = 0;
  36. #if FORWARD_ENABLED
  37. virtual void hess_forward(unsigned int len, double** ret_vec) = 0;
  38. #endif
  39. //other utility methods
  40. virtual void inorder_visit( int level,ostream& oss) = 0;
  41. virtual string toString(int levl) = 0;
  42. virtual TYPE getType() = 0;
  43. //! index on the tape
  44. unsigned int index;
  45. //! number of incoming arcs
  46. //! n_in_arcs in root node equals 1 before evaluation and 0 after evaluation
  47. unsigned int n_in_arcs;
  48. static unsigned int DEFAULT_INDEX;
  49. };
  50. } // end namespace foo
  51. #endif /* NODE_H_ */