1 /* 2 * VNode.h 3 * 4 * Created on: 8 Apr 2013 5 * Author: s0965328 6 */ 7 8 #ifndef VNODE_H_ 9 #define VNODE_H_ 10 11 #include "ActNode.h" 12 13 namespace AutoDiff { 14 class VNode: public ActNode { 15 public: 16 VNode(double v=NaN_Double); 17 virtual ~VNode(); 18 void collect_vnodes(boost::unordered_set<Node*>& nodes,unsigned int& total); 19 void eval_function(); 20 void grad_reverse_0(); 21 void grad_reverse_1(); 22 unsigned int hess_reverse_0(); 23 void hess_reverse_0_get_values(unsigned int i,double& x, double& x_bar, double& w, double& w_bar); 24 void hess_reverse_1(unsigned int i); 25 void hess_reverse_1_init_x_bar(unsigned int); 26 void update_x_bar(unsigned int,double); 27 void update_w_bar(unsigned int,double); 28 void hess_reverse_1_get_xw(unsigned int,double&,double&); 29 void hess_reverse_get_x(unsigned int,double& x); 30 31 void nonlinearEdges(EdgeSet&); 32 33 void inorder_visit(int level,ostream& oss); 34 string toString(int level); 35 TYPE getType(); 36 37 #if FORWARD_ENABLED 38 void hess_forward(unsigned int nvar, double** ret_vec); 39 //! used for only forward hessian 40 //! the id has to be assigned starting from 0 41 int id; 42 static int DEFAULT_ID; 43 #endif 44 double val; 45 double u; 46 47 48 }; 49 50 } // end namespace foo 51 52 #endif /* VNODE_H_ */ 53