timefreq.h Source File

LibRPA: timefreq.h Source File
LibRPA
timefreq.h
Go to the documentation of this file.
1 
5 #ifndef TIMEFREQ_H
6 #define TIMEFREQ_H
7 
8 #include <vector>
9 #include <string>
10 
11 #include "complexmatrix.h"
12 #include "matrix.h"
13 
15 
20 class TFGrids
21 {
22  public:
23  enum GRID_TYPES { GaussLegendre,
24  GaussChebyshevI,
25  GaussChebyshevII,
26  Minimax,
27  EvenSpaced, EvenSpaced_TF,
28  COUNT, // NOTE: always the last
29  };
30  static const string GRID_TYPES_NOTES[GRID_TYPES::COUNT];
31  static const bool SUPPORT_TIME_GRIDS[GRID_TYPES::COUNT];
32  static GRID_TYPES get_grid_type(const string& grid_str);
33  private:
35  GRID_TYPES grid_type;
37  bool _has_time_grids;
38  unsigned n_grids;
39  vector<double> freq_nodes;
40  vector<double> freq_weights;
41  vector<double> time_nodes;
42  vector<double> time_weights;
47  matrix costrans_t2f;
50  matrix costrans_f2t;
52  matrix sintrans_t2f;
55  matrix sintrans_f2t;
57  // ComplexMatrix fourier_t2f;
58  // ComplexMatrix fourier_f2t;
60  void set_freq();
61  void set_time();
63  void unset();
64  public:
65  TFGrids::GRID_TYPES get_grid_type() const { return grid_type; }
66  TFGrids(): n_grids(0) {};
67  TFGrids(unsigned N);
68  // disable copy at present
69  TFGrids(const TFGrids &tfg) {};
70  void reset(unsigned N);
71  void show();
73  size_t get_n_grids() const { return n_grids; }
75  size_t size() const { return n_grids; }
76  const vector<double> get_freq_nodes() const { return freq_nodes; }
77  const vector<double> get_freq_weights() const { return freq_weights; }
78  const vector<double> get_time_nodes() const { return time_nodes; }
79  const vector<double> get_time_weights() const { return time_weights; }
80  // NOTE: use reference for return matrix?
81  const matrix &get_costrans_t2f() const { return costrans_t2f; }
82  const matrix &get_sintrans_t2f() const { return sintrans_t2f; }
83  const matrix &get_costrans_f2t() const { return costrans_f2t; }
84  const matrix &get_sintrans_f2t() const { return sintrans_f2t; }
85  int get_time_index(const double &time) const;
86  int get_freq_index(const double &freq) const;
87  const pair<int, int> get_tf_index(const pair<double, double> &tf) const;
89  // NOTE:(ZMY) attempt to use a map<double, double> to store,
90  // but will lead to a segfault in chi0tauR calculation, not knowing why
91  double find_freq_weight(const double &freq) const;
93  void generate_evenspaced(double emin, double interval);
95  void generate_evenspaced_tf(double emin, double eintv, double tmin, double tintv);
97  void generate_minimax(double emin, double emax);
102  void generate_GaussLegendre();
103  bool has_time_grids() const { return time_nodes.size() > 0; }
104  ~TFGrids();
105 };
106 
107 #endif
Object to handle time/frequency grids for quadrature.
Definition: timefreq.h:21
size_t get_n_grids() const
get the number of grid points
Definition: timefreq.h:73
void generate_GaussChebyshevII()
Generate Gauss-Chebyshev quadrature of second kind on [0, infty)
Definition: timefreq.cpp:229
size_t size() const
alias to get_n_grids
Definition: timefreq.h:75
void generate_evenspaced(double emin, double interval)
Generate the even-spaced frequency grid.
Definition: timefreq.cpp:130
void generate_evenspaced_tf(double emin, double eintv, double tmin, double tintv)
Generate the even-spaced time-frequency grid.
Definition: timefreq.cpp:145
double find_freq_weight(const double &freq) const
obtain the integral weight from the frequency value
Definition: timefreq.cpp:284
void generate_minimax(double emin, double emax)
Generate the minimax time-frequency grid.
Definition: timefreq.cpp:167
void generate_GaussChebyshevI()
Generate Gauss-Chebyshev quadrature of first kind on [0, infty)
Definition: timefreq.cpp:215
Definition: matrix.h:23
utilies to handle square matrix and related operations