NESSi  v1.0.2
The NonEquilibrium Systems Simulation Library
cntr_herm_pseudo_decl.hpp
Go to the documentation of this file.
1 #ifndef CNTR_HERM_PSEUDE_DECL_H
2 #define CNTR_HERM_PSEUDE_DECL_H
3 
5 
6 namespace cntr {
7 
8 template <typename T> class function;
9 template <typename T> class herm_matrix;
10 template <typename T> class herm_matrix_timestep;
11 
12 /*#########################################################################################
13 #
14 # ... a pseudoparticle Greenfunction (herm_pseudo) is identical to a usual
15 # herm_matrix, but one has ret=gtr instead of ret=gtr-les, such that the
16 # conversion from a full_matrix and its timesteps is different
17 #
18 #########################################################################################*/
20 template <typename T> class herm_pseudo {
21  public:
22  typedef std::complex<T> cplx;
23  /* construction, destruction */
24  herm_pseudo();
25  ~herm_pseudo();
26  herm_pseudo(int nt, int ntau, int size1 = 1, int sig = -1);
27  herm_pseudo(const herm_pseudo &g);
28  herm_pseudo &operator=(const herm_pseudo &g);
29  /* resize */
30  void resize_discard(int nt, int ntau, int size1);
31  void resize_nt(int nt);
32  void resize(int nt, int ntau, int size1);
33  void clear(void);
34  /* access size etc ... */
36  int element_size(void) const { return element_size_; }
37  int size1(void) const { return size1_; }
38  int size2(void) const { return size2_; }
39  int ntau(void) const { return ntau_; }
40  int nt(void) const { return nt_; }
41  int sig(void) const { return sig_; }
42  void set_sig(int sig) { sig_ = sig; }
43  /* conversion from other types: pseudoparticle GF,
44  matrix GF with different storage structure etc...*/
45 
46  // herm_pseudo<T> & herm_pseudo(const matrix<T> &g1);
47  // herm_pseudo<T> & herm_pseudo(const scalar<T> &g1);
48 
49  // raw pointer to elements ... to be used with care
50  inline cplx *lesptr(int i, int j);
51  inline cplx *retptr(int i, int j);
52  inline cplx *tvptr(int i, int j);
53  inline cplx *matptr(int i);
54  // reading basic and derived elements to any Matrix type
55  template <class Matrix> void get_les(int i, int j, Matrix &M);
56  template <class Matrix> void get_gtr(int i, int j, Matrix &M);
57  template <class Matrix> void get_ret(int i, int j, Matrix &M);
58  template <class Matrix> void get_vt(int i, int j, Matrix &M);
59  template <class Matrix> void get_tv(int i, int j, Matrix &M);
60  template <class Matrix> void get_mat(int i, Matrix &M);
61  template <class Matrix> void get_matminus(int i, Matrix &M);
62  // reading complex numbers:
63  // these will adress only (0,0) element for dim>1:
64  inline void get_les(int i, int j, cplx &x);
65  inline void get_gtr(int i, int j, cplx &x);
66  inline void get_ret(int i, int j, cplx &x);
67  inline void get_vt(int i, int j, cplx &x);
68  inline void get_tv(int i, int j, cplx &x);
69  inline void get_mat(int i, cplx &x);
70  inline void get_matminus(int i, cplx &x);
71  // writing basic elements:
72  template <class Matrix> void set_les(int i, int j, Matrix &M);
73  template <class Matrix> void set_ret(int i, int j, Matrix &M);
74  template <class Matrix> void set_tv(int i, int j, Matrix &M);
75  template <class Matrix> void set_mat(int i, Matrix &M);
76  inline void set_les(int i, int j, cplx x);
77  inline void set_ret(int i, int j, cplx x);
78  inline void set_tv(int i, int j, cplx x);
79  inline void set_mat(int i, cplx x);
80  // density matrix
81  cplx density_matrix(int i);
82  template <class Matrix> void density_matrix(int tstp, Matrix &M);
83  // INPUT/OUTPUT
84  void print_to_file(const char *file, int precision = 16);
85  void read_from_file(const char *file);
86 // HDF5 I/O
87 #if CNTR_USE_HDF5 == 1
88  void write_to_hdf5(hid_t group_id);
89  void write_to_hdf5(hid_t group_id, const char *groupname);
90  void write_to_hdf5(const char *filename, const char *groupname);
91  void read_from_hdf5(hid_t group_id);
92  void read_from_hdf5(hid_t group_id, const char *groupname);
93  void read_from_hdf5(const char *filename, const char *groupname);
94  // read up to timestep nt1: NO RESIZE
95  void read_from_hdf5(int nt1, hid_t group_id);
96  void read_from_hdf5(int nt1, hid_t group_id, const char *groupname);
97  void read_from_hdf5(int nt1, const char *filename, const char *groupname);
98 #endif
99 
100  // simple operations on the timesteps (n<0: Matsubara)
101  void set_timestep_zero(int tstp);
102  void set_timestep(int tstp, herm_pseudo &g1);
103  void set_timestep(int tstp, herm_matrix_timestep<T> &timestep);
104  void get_timestep(int tstp, herm_matrix_timestep<T> &timestep);
105  void incr_timestep(int tstp, herm_matrix_timestep<T> &timestep, cplx alpha = 1.0);
106  void left_multiply(int tstp, cplx *f0, cplx *ft,
107  T weight = 1.0); // version with function object is safer
108  void right_multiply(int tstp, cplx *f0, cplx *ft,
109  T weight = 1.0); // version with function object is safer
110  void left_multiply(int tstp, function<T> &ft, T weight = 1.0);
111  void right_multiply(int tstp, function<T> &ft, T weight = 1.0);
112  //
113  void smul(int tstp, T alpha);
114  void smul(int tstp, cplx alpha);
115 
116  private:
118  cplx *les_;
120  cplx *ret_;
122  cplx *tv_;
124  cplx *mat_;
126  int nt_;
128  int ntau_;
130  int size1_;
132  int size2_;
134  int element_size_;
136  int sig_; // Bose = +1, Fermi =-1
137 };
138 
139 } // namespace cntr
140 
141 #endif // CNTR_HERM_PSEUDE_DECL_H
void get_mat(const int m, std::complex< T > &G_mat, herm_matrix< T > &G, herm_matrix< T > &Gcc)
void get_timestep(int tstp, std::vector< Matrix > &data)
void get_tv(const int i, const int m, std::complex< T > &G_tv, herm_matrix< T > &G, herm_matrix< T > &Gcc)
std::complex< double > cplx
Definition: fourier.cpp:11
void get_vt(const int m, const int i, std::complex< T > &G_vt, herm_matrix< T > &G, herm_matrix< T > &Gcc)
void get_ret(const int i, const int j, std::complex< T > &G_ret, herm_matrix< T > &G, herm_matrix< T > &Gcc)
void get_les(const int i, const int j, std::complex< T > &G_les, herm_matrix< T > &G, herm_matrix< T > &Gcc)
void get_gtr(const int i, const int j, std::complex< T > &G_gtr, herm_matrix< T > &G, herm_matrix< T > &Gcc)
void set_timestep(int tstp, std::vector< Matrix > &data)