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