DiFfRG
Loading...
Searching...
No Matches
stack_coordinates.hh
Go to the documentation of this file.
1#pragma once
2
3// standard library
4#include <cmath>
5#include <stdexcept>
6
7// DiFfRG
9
10namespace DiFfRG
11{
12 template <typename Idx> class IndexStack
13 {
14 public:
15 using ctype = Idx;
16 static constexpr uint dim = 1;
17
19 {
20 if (start > stop)
21 throw std::invalid_argument("start must be smaller than stop; start = " + std::to_string(start) +
22 ", stop = " + std::to_string(stop));
23 }
24
25 template <typename Idx2> IndexStack(const LinearCoordinates1D<Idx2> &other) : IndexStack(other.start, other.stop) {}
26
33 Idx __forceinline__ __device__ __host__ forward(const Idx x) const { return x + start; }
34
41 Idx __forceinline__ __device__ __host__ backward(const Idx y) const { return y - start; }
42
43 uint size() const { return m_size; }
44
45 const Idx start, stop;
46
47 private:
48 const uint m_size;
49 };
50
51 template <typename Idx, typename NT> class BosonicMatsubaraValues
52 {
53 public:
54 using ctype = NT;
55 static constexpr uint dim = 1;
56
58 {
59 if (start > stop)
60 throw std::invalid_argument("start must be smaller than stop; start = " + std::to_string(start) +
61 ", stop = " + std::to_string(stop));
62 }
63
64 template <typename Idx2, typename NT2>
69
76 NT __forceinline__ __device__ __host__ forward(const Idx &x) const { return NT(x + start) * 2. * M_PI * T; }
77
84 Idx __forceinline__ __device__ __host__ backward(const NT &y) const
85 {
86 return Idx(std::round(y / (2. * M_PI * T))) - start;
87 }
88
89 uint size() const { return m_size; }
90
91 const Idx start, stop;
92 const NT T;
93
94 private:
95 const uint m_size;
96 };
97
98 template <typename Idx, typename NT> class FermionicMatsubaraValues
99 {
100 public:
101 using ctype = NT;
102 static constexpr uint dim = 1;
103
105 {
106 if (start > stop)
107 throw std::invalid_argument("start must be smaller than stop; start = " + std::to_string(start) +
108 ", stop = " + std::to_string(stop));
109 }
110
111 template <typename Idx2, typename NT2>
116
123 NT __forceinline__ __device__ __host__ forward(const Idx &x) const { return (NT(x + start) + 0.5) * 2. * M_PI * T; }
124
131 Idx __forceinline__ __device__ __host__ backward(const NT &y) const
132 {
133 return Idx(std::round((y - M_PI * T) / (2. * M_PI * T))) - start;
134 }
135
136 uint size() const { return m_size; }
137
138 const Idx start, stop;
139 const NT T;
140
141 private:
143 };
144} // namespace DiFfRG
Definition stack_coordinates.hh:52
NT ctype
Definition stack_coordinates.hh:54
NT __forceinline__ __device__ __host__ forward(const Idx &x) const
Transform from the grid to the physical space.
Definition stack_coordinates.hh:76
uint size() const
Definition stack_coordinates.hh:89
const uint m_size
Definition stack_coordinates.hh:95
const Idx stop
Definition stack_coordinates.hh:91
BosonicMatsubaraValues(const BosonicMatsubaraValues< Idx2, NT2 > &other)
Definition stack_coordinates.hh:65
Idx __forceinline__ __device__ __host__ backward(const NT &y) const
Transform from the physical space to the grid.
Definition stack_coordinates.hh:84
const Idx start
Definition stack_coordinates.hh:91
BosonicMatsubaraValues(Idx start, Idx stop, NT T)
Definition stack_coordinates.hh:57
const NT T
Definition stack_coordinates.hh:92
static constexpr uint dim
Definition stack_coordinates.hh:55
Definition stack_coordinates.hh:99
uint size() const
Definition stack_coordinates.hh:136
Idx __forceinline__ __device__ __host__ backward(const NT &y) const
Transform from the physical space to the grid.
Definition stack_coordinates.hh:131
FermionicMatsubaraValues(Idx start, Idx stop, NT T)
Definition stack_coordinates.hh:104
static constexpr uint dim
Definition stack_coordinates.hh:102
const Idx stop
Definition stack_coordinates.hh:138
NT __forceinline__ __device__ __host__ forward(const Idx &x) const
Transform from the grid to the physical space.
Definition stack_coordinates.hh:123
NT ctype
Definition stack_coordinates.hh:101
const NT T
Definition stack_coordinates.hh:139
const uint m_size
Definition stack_coordinates.hh:142
const Idx start
Definition stack_coordinates.hh:138
FermionicMatsubaraValues(const FermionicMatsubaraValues< Idx2, NT2 > &other)
Definition stack_coordinates.hh:112
Definition stack_coordinates.hh:13
const Idx start
Definition stack_coordinates.hh:45
Idx __forceinline__ __device__ __host__ backward(const Idx y) const
Transform from the physical space to the grid.
Definition stack_coordinates.hh:41
static constexpr uint dim
Definition stack_coordinates.hh:16
Idx ctype
Definition stack_coordinates.hh:15
const uint m_size
Definition stack_coordinates.hh:48
Idx __forceinline__ __device__ __host__ forward(const Idx x) const
Transform from the grid to the physical space.
Definition stack_coordinates.hh:33
IndexStack(const LinearCoordinates1D< Idx2 > &other)
Definition stack_coordinates.hh:25
uint size() const
Definition stack_coordinates.hh:43
const Idx stop
Definition stack_coordinates.hh:45
IndexStack(Idx start, Idx stop)
Definition stack_coordinates.hh:18
Definition coordinates.hh:98
Definition complex_math.hh:14
unsigned int uint
Definition utils.hh:22