NESSi  v1.0.2
The NonEquilibrium Systems Simulation Library
cntr_herm_matrix_timestep_view_decl.hpp
Go to the documentation of this file.
1 #ifndef CNTR_HERM_TIMESTEP_VIEW_DECL_H
2 #define CNTR_HERM_TIMESTEP_VIEW_DECL_H
3 
5 
6 namespace cntr {
7 
8 template <typename T> class herm_matrix_timestep;
9 template <typename T> class herm_matrix;
10 template <typename T> class function;
11 
12 template <typename T>
32 
34 class herm_matrix_timestep_view {
35  public:
36  typedef std::complex<T> cplx;
37  typedef T scalar_type;
43  herm_matrix_timestep_view(int tstp, herm_matrix<T> &g, bool check_assert=true);
44  herm_matrix_timestep_view(int tstp, int ntau, int size1, int size2, int sig);
45  herm_matrix_timestep_view(int tstp, herm_matrix_timestep<T> &g, bool check_assert=true);
48  int size1(void) const { return size1_; }
49  int size2(void) const { return size2_; }
50  int ntau(void) const { return ntau_; }
51  int tstp(void) const { return tstp_; }
52  int sig(void) const { return sig_; }
54  inline std::complex<T> *retptr(int i) { return ret_ + i * element_size_; }
56  inline std::complex<T> *tvptr(int i) { return tv_ + i * element_size_; }
58  inline std::complex<T> *lesptr(int i) {
59  return les_ + i * element_size_;
60  };
62  inline std::complex<T> *matptr(int i) { return mat_ + i * element_size_; }
64  // the following routines set the ponters:
65  void set_to_data(std::complex<T> *data, int tstp, int ntau, int size,
66  int sig);
67  void set_to_data(int tstp, herm_matrix<T> &g);
68  void set_to_data(herm_matrix_timestep<T> &g);
69 // HDF5 I/O
70 #if CNTR_USE_HDF5 == 1
71  void write_to_hdf5(hid_t group_id);
72  void write_to_hdf5(hid_t group_id, const char *groupname);
73  void write_to_hdf5(const char *filename, const char *groupname);
74  // READ: Read only data, no resize!
75  void read_from_hdf5(hid_t group_id, const char *groupname);
76  void read_from_hdf5(hid_t group_id);
77  void read_from_hdf5(const char *filename, const char *groupname);
78 #endif
79 
80  /*//////////////////////////////////////////////////////////////////////////////////
81  OPERATE ON THE DATA POINTED TO BY THE VIEW OBJECT:
82 
83  the argument G can be anything on which one can create a temporary
84  herm_matrix_timestep_view object by
85  herm_matrix_timestep_view<T>(tstp_,G)
86 
88  // ** GET_DATA: copy data into the array pointed to by the view:
89  void get_data(herm_matrix_timestep_view<T> &g);
90  template <class GG>
91  void get_data(GG &g);
92 
94  template <class Matrix> void set_ret(int i, int j, Matrix &M);
96  template <class Matrix> void set_les(int i, int j, Matrix &M);
98  template <class Matrix> void set_tv(int i, int j, Matrix &M);
100  template <class Matrix> void set_mat(int i, Matrix &M);
101 
103  template <class Matrix> void get_les(int i, int j, Matrix &M);
105  template <class Matrix> void get_ret(int i, int j, Matrix &M);
107  template <class Matrix> void get_tv(int i, int j, Matrix &M);
109  template <class Matrix> void get_mat(int i, Matrix &M);
111  template <class Matrix> void get_matminus(int i, Matrix &M);
112 
113 
115  void left_multiply(int tstp, std::complex<T> *f0, std::complex<T> *ft, T weight = 1.0);
116  void left_multiply(int tstp, function<T> &ft, T weight = 1.0);
118  void right_multiply(int tstp, std::complex<T> *f0, std::complex<T> *ft, T weight = 1.0);
119  void right_multiply(int tstp, function<T> &ft, T weight = 1.0);
120  void left_multiply_hermconj(int tstp, function<T> &ft, T weight = 1.0);
121  void right_multiply_hermconj(int tstp, function<T> &ft, T weight = 1.0);
122 
123  void set_timestep_zero(int tstp);
124 
125  void set_timestep(int tstp, herm_matrix<T> &g1);
126  void set_timestep(int tstp, herm_matrix_timestep<T> &g1);
127 
129  std::complex<T> density_matrix(int tstp);
130 
131  void density_matrix(int tstp, std::complex<T> &M);
132  template <class Matrix> void density_matrix(int tstp, Matrix &M);
133 
134 
135  void get_timestep(int tstp,herm_matrix_timestep<T> &timestep);
136  // ** SET MATRIX_ELEMENT: this(i1,i2) <= g(j1,j2)
137  void set_matrixelement(int i1, int i2, herm_matrix_timestep_view<T> &g,
138  int j1, int j2);
139  template <class GG>
140  void set_matrixelement(int i1, int i2, GG &g, int j1, int j2);
141  // ** INCR_TIMESTEP this += alpha * g
142  void incr_timestep(herm_matrix_timestep_view<T> &g,
143  std::complex<T> alpha);
144  void incr_timestep(herm_matrix_timestep_view<T> &g, T alpha);
145  template <class GG>
146  void incr_timestep(GG &g, std::complex<T> alpha);
147  template <class GG>
148  void incr_timestep(GG &g, T alpha);
149  // ** SMUL this *= alpha
150  void smul(T alpha);
151 #if CNTR_USE_MPI == 1
153  void MPI_Reduce(int root);
154  void Reduce_timestep(int tstp, int root);
155  void Bcast_timestep(int tstp, int root);
156  void Send_timestep(int tstp, int dest, int tag);
157  void Recv_timestep(int tstp, int root, int tag);
158 #endif
159 
161  // private:
162  void get_data(std::complex<T> *ret, std::complex<T> *les,
163  std::complex<T> *tv, std::complex<T> *mat);
165 
166  std::complex<T> *ret_;
168 
169  std::complex<T> *les_;
171 
172  std::complex<T> *tv_;
174 
175  std::complex<T> *mat_;
177 
178  int tstp_;
180 
181  int ntau_;
183 
184  int size1_;
186 
187  int size2_;
189 
190  int element_size_;
192 
193  int sig_;
194 };
195 
196 } // namespace cntr
197 
198 #endif // CNTR_HERM_TIMESTEP_VIEW_DECL_H
Class herm_matrix_timestep_view serves for interfacing with class herm_matrix_timestep without copyi...
Class herm_matrix_timestep deals with contour objects at a particular timestep .
herm_matrix_timestep_view & operator=(const herm_matrix_timestep_view &g)
Copy assignment operator for herm_matrix_timestep_view g class.
void read_from_hdf5(hid_t group_id, const char *groupname)
Read herm_matrix_timestep_view from hdf5 group given by group ID group_id and group name groupname...
Class herm_matrix for two-time contour objects with hermitian symmetry.
void write_to_hdf5(hid_t group_id)
Write herm_matrix_timestep_view to hdf5 group given by group_id.
void set_to_data(std::complex< T > *data, int tstp, int ntau, int size, int sig)