/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/coordinates/stack_coordinates.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/coordinates/stack_coordinates.hh Source File
DiFfRG
stack_coordinates.hh
Go to the documentation of this file.
1#pragma once
2
3// DiFfRG
5
6namespace DiFfRG
7{
8 template <typename Idx> class IndexStack
9 {
10 public:
11 using ctype = Idx;
12 static constexpr size_t dim = 1;
13
15 {
16 if (start > stop)
17 throw std::invalid_argument("start must be smaller than stop; start = " + std::to_string(start) +
18 ", stop = " + std::to_string(stop));
19 }
20
21 template <typename Idx2> IndexStack(const LinearCoordinates1D<Idx2> &other) : IndexStack(other.start, other.stop) {}
22
29 Idx KOKKOS_FORCEINLINE_FUNCTION forward(const Idx x) const { return x + start; }
30
37 Idx KOKKOS_FORCEINLINE_FUNCTION backward(const Idx y) const { return y - start; }
38
39 size_t size() const { return m_size; }
40
41 const Idx start, stop;
42
43 std::string to_string() const { return "IndexStack(" + std::to_string(start) + ", " + std::to_string(stop) + ")"; }
44
45 private:
46 const size_t m_size;
47 };
48
49 template <typename Idx = int, typename NT = double> class BosonicMatsubaraValues
50 {
51 public:
52 using ctype = NT;
53 static constexpr size_t dim = 1;
54
56 {
57 if (start > stop)
58 throw std::invalid_argument("start must be smaller than stop; start = " + std::to_string(start) +
59 ", stop = " + std::to_string(stop));
60 }
61
62 template <typename Idx2, typename NT2>
67
68 device::array<size_t, 1> KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
69 {
71 }
72
79 NT KOKKOS_FORCEINLINE_FUNCTION forward(const Idx &x) const { return NT(x + start) * 2. * M_PI * T; }
80
81 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
82 {
83 return {forward(x[0])};
84 }
85
92 Idx KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const { return Idx(std::round(y / (2. * M_PI * T))) - start; }
93
94 size_t size() const { return m_size; }
95
96 const Idx start, stop;
97 const NT T;
98
99 std::string to_string() const
100 {
101 return "BosonicMatsubaraValues(" + std::to_string(start) + ", " + std::to_string(stop) + ", " +
102 std::to_string(T) + ")";
103 }
104
105 private:
106 const size_t m_size;
107 };
108
109 template <typename Idx = int, typename NT = double> class FermionicMatsubaraValues
110 {
111 public:
112 using ctype = NT;
113 static constexpr size_t dim = 1;
114
116 {
117 if (start > stop)
118 throw std::invalid_argument("start must be smaller than stop; start = " + std::to_string(start) +
119 ", stop = " + std::to_string(stop));
120 }
121
122 template <typename Idx2, typename NT2>
127
128 device::array<size_t, 1> KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
129 {
130 return device::array<size_t, 1>{i};
131 }
132
139 NT KOKKOS_FORCEINLINE_FUNCTION forward(const Idx &x) const { return (NT(x + start) + 0.5) * 2. * M_PI * T; }
140
141 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
142 {
143 return {forward(x[0])};
144 }
145
152 Idx KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
153 {
154 return Idx(std::round((y - M_PI * T) / (2. * M_PI * T))) - start;
155 }
156
157 size_t size() const { return m_size; }
158
159 const Idx start, stop;
160 const NT T;
161
162 std::string to_string() const
163 {
164 return "FermionicMatsubaraValues(" + std::to_string(start) + ", " + std::to_string(stop) + ", " +
165 std::to_string(T) + ")";
166 }
167
168 private:
169 const size_t m_size;
170 };
171} // namespace DiFfRG
Definition stack_coordinates.hh:50
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
Definition stack_coordinates.hh:68
NT ctype
Definition stack_coordinates.hh:52
NT KOKKOS_FORCEINLINE_FUNCTION forward(const Idx &x) const
Transform from the grid to the physical space.
Definition stack_coordinates.hh:79
const Idx stop
Definition stack_coordinates.hh:96
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
Definition stack_coordinates.hh:81
static constexpr size_t dim
Definition stack_coordinates.hh:53
std::string to_string() const
Definition stack_coordinates.hh:99
BosonicMatsubaraValues(const BosonicMatsubaraValues< Idx2, NT2 > &other)
Definition stack_coordinates.hh:63
size_t size() const
Definition stack_coordinates.hh:94
const size_t m_size
Definition stack_coordinates.hh:106
const Idx start
Definition stack_coordinates.hh:96
Idx KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
Transform from the physical space to the grid.
Definition stack_coordinates.hh:92
BosonicMatsubaraValues(Idx start, Idx stop, NT T)
Definition stack_coordinates.hh:55
const NT T
Definition stack_coordinates.hh:97
Definition stack_coordinates.hh:110
NT KOKKOS_FORCEINLINE_FUNCTION forward(const Idx &x) const
Transform from the grid to the physical space.
Definition stack_coordinates.hh:139
FermionicMatsubaraValues(Idx start, Idx stop, NT T)
Definition stack_coordinates.hh:115
Idx KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
Transform from the physical space to the grid.
Definition stack_coordinates.hh:152
std::string to_string() const
Definition stack_coordinates.hh:162
size_t size() const
Definition stack_coordinates.hh:157
const Idx stop
Definition stack_coordinates.hh:159
NT ctype
Definition stack_coordinates.hh:112
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
Definition stack_coordinates.hh:141
const NT T
Definition stack_coordinates.hh:160
static constexpr size_t dim
Definition stack_coordinates.hh:113
const Idx start
Definition stack_coordinates.hh:159
const size_t m_size
Definition stack_coordinates.hh:169
FermionicMatsubaraValues(const FermionicMatsubaraValues< Idx2, NT2 > &other)
Definition stack_coordinates.hh:123
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
Definition stack_coordinates.hh:128
Definition stack_coordinates.hh:9
Idx KOKKOS_FORCEINLINE_FUNCTION backward(const Idx y) const
Transform from the physical space to the grid.
Definition stack_coordinates.hh:37
const Idx start
Definition stack_coordinates.hh:41
static constexpr size_t dim
Definition stack_coordinates.hh:12
Idx KOKKOS_FORCEINLINE_FUNCTION forward(const Idx x) const
Transform from the grid to the physical space.
Definition stack_coordinates.hh:29
Idx ctype
Definition stack_coordinates.hh:11
const size_t m_size
Definition stack_coordinates.hh:46
std::string to_string() const
Definition stack_coordinates.hh:43
IndexStack(const LinearCoordinates1D< Idx2 > &other)
Definition stack_coordinates.hh:21
size_t size() const
Definition stack_coordinates.hh:39
const Idx stop
Definition stack_coordinates.hh:41
IndexStack(Idx start, Idx stop)
Definition stack_coordinates.hh:14
Definition coordinates.hh:233
std::array< T, N > array
Definition kokkos.hh:133
Definition complex_math.hh:10