1 /* 2 * BinaryOPNode.h 3 * 4 * Created on: 6 Nov 2013 5 * Author: s0965328 6 */ 7 8 #ifndef BINARYOPNODE_H_ 9 #define BINARYOPNODE_H_ 10 11 #include "OPNode.h" 12 13 namespace AutoDiff { 14 15 class EdgeSet; 16 17 class BinaryOPNode: public OPNode { 18 public: 19 20 static OPNode* createBinaryOpNode(OPCODE op, Node* left, Node* right); 21 virtual ~BinaryOPNode(); 22 23 void collect_vnodes(boost::unordered_set<Node*>& nodes,unsigned int& total); 24 void eval_function(); 25 26 void grad_reverse_0(); 27 void grad_reverse_1(); 28 29 void hess_forward(unsigned int len, double** ret_vec); 30 31 unsigned int hess_reverse_0(); 32 void hess_reverse_0_init_n_in_arcs(); 33 void hess_reverse_0_get_values(unsigned int,double&, double&, double&, double&); 34 void hess_reverse_1(unsigned int i); 35 void hess_reverse_1_init_x_bar(unsigned int); 36 void update_x_bar(unsigned int,double); 37 void update_w_bar(unsigned int,double); 38 void hess_reverse_1_get_xw(unsigned int, double&,double&); 39 void hess_reverse_get_x(unsigned int,double& x); 40 void hess_reverse_1_clear_index(); 41 42 void nonlinearEdges(EdgeSet& a); 43 44 void inorder_visit(int level,ostream& oss); 45 string toString(int level); 46 47 Node* right; 48 49 private: 50 BinaryOPNode(OPCODE op, Node* left, Node* right); 51 void calc_eval_function(); 52 void calc_grad_reverse_0(); 53 void hess_forward_calc0(unsigned int& len, double* lvec, double* rvec,double* ret_vec); 54 }; 55 56 } /* namespace AutoDiff */ 57 #endif /* BINARYOPNODE_H_ */ 58