Greens-code
A modular quantum transport code
iterators.hpp
1 #ifndef ITERATOR_OVER_GEOMETRY_H
2 #define ITERATOR_OVER_GEOMETRY_H
3 #include <memory>
4 
5 #include "exceptions.hpp"
6 #include "hamiltonian.hpp"
7 
8 class Rectangle;
9 class Matrix;
10 
11 class geometry_Iterator;
12 
14  size_t pos;
15  mutable size_t layer_;
16  STD_TR1::shared_ptr<const Rectangle> my_t;
17  std::unique_ptr<geometry_const_Iterator> down;
18 
19  size_t index() const;
20  void step_down(bool backward = false);
21  bool increased_down();
22  bool decreased_down();
23  bool finished();
24 
25  bool trycreateHI(Matrix&) const;
26  bool trycreateHIt(Matrix&) const;
27 
28 public:
29 
30  static const size_t npos = 4294967295U;
31 
32  geometry_const_Iterator(STD_TR1::shared_ptr<const Rectangle>,
33  size_t = 0,
34  bool at_end = false);
37 
39 
40  geometry_const_Iterator& operator++();
41  geometry_const_Iterator& operator--();
42 
43  void reset_to(const geometry_const_Iterator&);
44 
45  void next_rect();
46  void first_rect_slice();
47  void last_rect_slice();
48 
49  bool operator==(const geometry_const_Iterator&) const;
50  bool operator!=(const geometry_const_Iterator& p) const {return ! operator==(p);};
51 
52  Hamiltonian::const_ref get_H() const;
53  STD_TR1::shared_ptr<const Rectangle> get_leaf_Rect() const;
54  STD_TR1::shared_ptr<const Rectangle> get_lower_Rect() const;
55  STD_TR1::shared_ptr<const Rectangle> get_top_Rect() const;
56 
57  geometry_const_Iterator into_lower_Rect() const;
58 
59  size_t nx() const;
60  size_t ix() const;
61  size_t layer() const { return layer_;};
62  void set_layer(size_t l) const { layer_ = l;};
63 
64  size_t nx(STD_TR1::shared_ptr<const Rectangle>) const;
65  size_t ix(STD_TR1::shared_ptr<const Rectangle>) const;
66  size_t block_number(const STD_TR1::shared_ptr<const Rectangle>&) const;
67 
68  inline int ny() const;
69  inline int ny_layer() const;
70  inline point_Positions::ref rxy() const;
71  double dx() const;
72  double dy() const;
73  double dphi() const;
74  inline double width() const;
75 
76  inline void createH0(Matrix&) const;
77  void createHI(Matrix&) const;
78  void createHIt(Matrix&) const;
79 
80  void createH(Matrix&, size_t nx) const;
81 };
82 
84 
85  friend class geometry_const_Iterator;
86 
87  size_t pos;
88  mutable size_t layer_;
89  STD_TR1::shared_ptr<Rectangle> my_t;
90  std::unique_ptr<geometry_Iterator> down;
91 
92  size_t index() const;
93  void step_down(bool backward = false);
94  bool increased_down();
95  bool decreased_down();
96  bool finished();
97 
98  bool trycreateHI(Matrix&) const;
99  bool trycreateHIt(Matrix&) const;
100 
101 public:
102 
103  static const size_t npos = 4294967295U;
104 
105  geometry_Iterator(STD_TR1::shared_ptr<Rectangle>,
106  size_t = 0,
107  bool at_end = false);
110 
111  geometry_Iterator& operator++();
112  geometry_Iterator& operator--();
113 
114  void next_rect();
115  void first_rect_slice();
116  void last_rect_slice();
117 
118  bool operator==(const geometry_Iterator&) const;
119  bool operator==(const geometry_const_Iterator&) const;
120 
121  bool operator!=(const geometry_Iterator& p) const {return ! operator==(p);};
122  bool operator!=(const geometry_const_Iterator& p) const {return ! operator==(p);};
123 
124  Hamiltonian::ref get_H() const;
125  STD_TR1::shared_ptr<Rectangle> get_leaf_Rect() const;
126  STD_TR1::shared_ptr<Rectangle> get_lower_Rect() const;
127  STD_TR1::shared_ptr<Rectangle> get_top_Rect() const;
128 
129  size_t nx() const;
130  size_t ix() const;
131 
132  size_t layer() const { return layer_;};
133  void set_layer(size_t l) { layer_ = l;};
134 
135  size_t nx(STD_TR1::shared_ptr<const Rectangle>) const;
136  size_t ix(STD_TR1::shared_ptr<const Rectangle>) const;
137  size_t block_number(const STD_TR1::shared_ptr<const Rectangle> &) const;
138 
139  inline int ny() const;
140  inline int ny_layer() const;
141  inline point_Positions::ref rxy() const;
142  double dx() const;
143  double dy() const;
144  double dphi() const;
145  inline double width() const;
146 
147  inline void createH0(Matrix&) const;
148  void createHI(Matrix&) const;
149  void createHIt(Matrix&) const;
150 
151  void createH(Matrix&, size_t nx) const;
152 };
153 
154 int geometry_const_Iterator::ny() const{ return get_H()->ny(*this);}
155 int geometry_const_Iterator::ny_layer() const{ return get_H()->ny_layer(*this);}
156 double geometry_const_Iterator::width() const{ return get_H()->width(*this);}
157 point_Positions::ref geometry_const_Iterator::rxy() const{ return get_H()->rxy(*this);}
158 void geometry_const_Iterator::createH0(Matrix& m) const { return get_H()->create_H0(m,*this);}
159 
160 int geometry_Iterator::ny() const{ return get_H()->ny(*this);}
161 int geometry_Iterator::ny_layer() const{ return get_H()->ny_layer(*this);}
162 double geometry_Iterator::width() const{ return get_H()->width(*this);}
163 point_Positions::ref geometry_Iterator::rxy() const{ return get_H()->rxy(*this);}
164 void geometry_Iterator::createH0(Matrix& m) const { return get_H()->create_H0(m,*this);}
165 
166 #endif
Definition: iterators.hpp:83
Definition: iterators.hpp:13
Abstract class that defines a geomeetry.
Definition: rectangle.hpp:31
Base Matrix class for access to 2D number grids.
Definition: matrix.hpp:82
Definitions of abstract Hamiltonian base class.