TRIQS/triqs_ctint 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
vertex.cpp
1// Copyright (c) 2017--present, The Simons Foundation
2// This file is part of TRIQS/ctint and is licensed under the terms of GPLv3 or later.
3// SPDX-License-Identifier: GPL-3.0-or-later
4// See LICENSE in the root of this distribution for details.
5
6#include "./vertex.hpp"
7
8namespace triqs_ctint {
9
10 double tau_t::beta = 0.0;
11
12 // Note: The subtration of unsigned integers is inherently cyclic
13 std::pair<double, double> cyclic_difference(tau_t const &tau1, tau_t const &tau2) {
14 // Assume tau1 > tau2 for the equal time case
15 double sign = tau2 > tau1 ? -1.0 : 1.0;
16 double value = double(tau_t{tau1.n - tau2.n});
17 return std::make_pair(sign, value);
18 }
19
20 std::pair<double, double> cyclic_difference(double tau1, double tau2) {
21 // Assume tau1 > tau2 for the equal time case
22 double dtau = tau1 - tau2;
23 int nshifts = static_cast<int>(std::floor(dtau / tau_t::beta));
24 double sign = (nshifts % 2 == 0) ? 1.0 : -1.0;
25 double value = dtau - nshifts * tau_t::beta;
26 return std::make_pair(sign, value);
27 }
28
29 tau_t make_tau_t(double tau) {
30#ifdef DEBUG_CTINT
31 if (tau < 0.0 or tau_t::beta < tau) TRIQS_RUNTIME_ERROR << " Tau-value outside [0,beta) interval not allowed in make_tau_t\n";
32#endif
33 return tau_t{uint32_t(tau_t::n_max / tau_t::beta * tau)};
34 }
35
36 std::ostream &operator<<(std::ostream &os, vertex_idx_t const &v) {
37 os << "vertex_idx_t{"
38 << "b1,u1=" << v.b1 << "," << v.u1 << ", "
39 << "b2,u2=" << v.b2 << "," << v.u2 << ", "
40 << "b3,u3=" << v.b3 << "," << v.u2 << ", "
41 << "b4,u4=" << v.b4 << "," << v.u2 << "}";
42 return os;
43 }
44
45 std::ostream &operator<<(std::ostream &os, vertex_t const &v) {
46 os << "vertex_t{"
47 << "idx=" << v.idx << ", "
48 << "tau1=" << v.tau1 << ", "
49 << "tau2=" << v.tau2 << ", "
50 << "tau3=" << v.tau3 << ", "
51 << "tau4=" << v.tau4 << ", "
52 << "amplitude=" << v.amplitude << ", "
53 << "proposition_proba=" << v.proposition_proba << ", "
54 << "vertex_label=" << v.vertex_label << ", "
55 << "s=" << v.s << "}";
56 return os;
57 }
58
59} // namespace triqs_ctint
static constexpr uint32_t n_max
Maximum value that can be stored inside a uint32_t.
Definition vertex.hpp:20
static double beta
Inverse temperature associated with all $\tau$ points.
Definition vertex.hpp:23