39namespace triqs::utility {
62 friend struct time_segment;
75 time_pt(uint64_t n_,
double beta_) : n(n_), beta(beta_), val(beta_ * (static_cast<double>(n_) / static_cast<double>(
Nmax))) {}
104 bool wrapped = ((
Nmax - std::max(tp1.n, tp2.n)) < std::min(tp1.n, tp2.n));
106 return {(tp1.n + tp2.n) %
Nmax, tp1.beta};
108 return {((tp1.n + tp2.n) + 1) %
Nmax, tp1.beta};
119 uint64_t nres = (tp1.n >= tp2.n ? (tp1.n - tp2.n) %
Nmax :
Nmax - (tp2.n - tp1.n));
120 return {nres, tp1.beta};
162 explicit operator double()
const {
return val; }
172 return out << p.val <<
" [time_pt : beta = " << p.beta <<
" n = " << p.n <<
"]";
176 static constexpr uint64_t
Nmax = std::numeric_limits<uint64_t>::max();
179 [[nodiscard]]
static std::string
hdf5_format() {
return "time_pt"; }
189 auto gr = g.create_group(name);
190 write_hdf5_format(gr, tp);
204 auto gr = g.open_group(name);
238 inline double operator OP(time_pt const &x, double y) { return static_cast<double>(x) OP y; } \
239 inline double operator OP(double y, time_pt const &x) { return y OP static_cast<double>(x); }
288 return {rng(tp2.n - tp1.n) + tp1.n,
beta};
316 EXPECTS(0 <= x && x <=
beta);
317 uint64_t n =
static_cast<uint64_t
>(
static_cast<double>(
time_pt::Nmax) * std::min(1.0, (x /
beta)));
Compiler / platform glue and the dcomplex alias (must be included before any Boost header).
double operator*(time_pt const &tp1, time_pt const &tp2)
Multiplication between two time points.
double operator/(time_pt const &tp1, time_pt const &tp2)
Division between two time points.
Common macros used in TRIQS.
A point in imaginary time, , stored on a very fine integer grid.
bool operator==(time_pt const &tp) const
Equal-to operator compares the integer grid positions of two time points.
static constexpr uint64_t Nmax
Largest possible grid position.
friend void h5_write(h5::group g, std::string const &name, time_pt const &tp)
Write a time_pt to HDF5.
time_pt()=default
Default constructor creates the point for .
friend time_pt operator-(time_pt const &tp1, time_pt const &tp2)
Subtraction operator performs cyclic subtraction on .
friend size_t floor_div(time_pt const &tp1, time_pt const &tp2)
Perform floor division between two time points.
static std::string hdf5_format()
Get the HDF5 format tag.
friend void h5_read(h5::group g, std::string const &name, time_pt &tp)
Read a time_pt from HDF5.
friend time_pt mult_by_int(time_pt const &tp, size_t a)
Multiply a time point by an integer.
friend time_pt div_by_int(time_pt const &tp, size_t a)
Divide a time point by an integer.
friend time_pt operator+(time_pt const &tp1, time_pt const &tp2)
Addiditon operator performs cyclic addition on .
friend time_pt operator-(time_pt const &tp)
Unary minus operator performs cyclic negation .
time_pt & operator=(double v)=delete
Assigning a double is deleted to avoid accidental loss of precision.
time_pt(uint64_t n_, double beta_)
Construct a point from an integer grid position and the inverse temperature.
friend std::ostream & operator<<(std::ostream &out, time_pt const &p)
Write a time_pt to an output stream.
auto operator<=>(time_pt const &tp) const
Three-way comparison operator compares the integer grid positions of two time points.
Represents the imaginary-time segment .
time_pt get_lower_pt() const
Get the lower end of the segment.
time_pt get_random_pt(RNG &rng, time_pt tp1, time_pt tp2) const
Draw a uniform random point in .
time_pt get_upper_pt() const
Get the upper end of the segment.
time_pt get_epsilon() const
Get a time point representing one grid step .
time_pt get_random_pt(RNG &rng) const
Draw a uniform random point in .
time_pt make_time_pt(double x) const
Convert a double value to the nearest point on the grid.
time_pt get_random_pt(RNG &rng, time_pt tp) const
Draw a uniform random point in .
time_segment(double beta_)
Construct a segment from an inverse temperature.
double beta
Inverse temperature .