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