46enum Direction :
unsigned { e_x = 0, e_y, e_z, e_z_down, e_y_down, e_x_down, NDIRECTIONS };
48enum Direction :
unsigned { e_x = 0, e_y, e_y_down, e_x_down, NDIRECTIONS };
50enum Direction :
unsigned { e_x = 0, e_x_down, NDIRECTIONS };
57constexpr unsigned NDIRS = NDIRECTIONS;
63 return static_cast<Direction>(
static_cast<unsigned>(dir) + 1);
66 return dir = next_direction(dir);
78#define foralldir(d) for (Direction d = e_x; d < NDIM; ++d)
98static inline bool is_up_dir(
const Direction d) {
101static inline bool is_up_dir(
const int d) {
134constexpr inline const char *direction_name(
Direction d) {
157 return "ILLEGAL DIRECTION";
161inline std::string prettyprint(
Direction d) {
162 return direction_name(d);
169 os << hila::direction_name(d);
178enum class Parity :
unsigned { none = 0, even, odd, all };
197constexpr inline const char *parity_name(
Parity p) {
206 return "ILLEGAL PARITY";
210inline std::string prettyprint(
Parity p) {
211 return hila::parity_name(p);
218 os << hila::parity_name(p);
223static inline unsigned parity_bits(
Parity p) {
224 return 0x3 &
static_cast<unsigned>(p);
226static inline unsigned parity_bits_inverse(
Parity p) {
227 return 0x3 & ~static_cast<unsigned>(p);
232 unsigned u = parity_bits(p);
233 return static_cast<Parity>(0x3 & ((u << 1) | (u >> 1)));
238 return opp_parity(p);
241static inline bool is_even_odd_parity(
Parity p) {
242 return (p ==
EVEN || p ==
ODD);
251inline int pmod(
const int a,
const int b) {
280 using base_type = hila::arithmetic_type<T>;
281 using argument_type = T;
294 foralldir(d) this->
e(d) = dir_dot_product(d, dir);
305 template <typename S, std::enable_if_t<hila::is_assignable<T &, S>::value,
int> = 0>
307 assert(rhs.size() == NDIM &&
"CoordinateVector initializer list size does not match");
309 for (
auto it = rhs.begin(); it != rhs.end(); it++, i++)
332 template <typename S, std::enable_if_t<hila::is_assignable<T &, S>::value,
int> = 0>
334 assert(rhs.size() == NDIM &&
"Initializer list has a wrong size in assignment");
336 for (
auto it = rhs.begin(); it != rhs.end(); it++, i++) {
345 this->
e(dir) = dir_dot_product(d, dir);
351 template <
typename S>
357 if (this->
e(d) != rhs.
e(d))
364 T &operator[](
const int i) {
369 return this->
e((
int)d);
372 T operator[](
const int i)
const {
377 return this->
e((
int)d);
401 template <
typename S>
404 for (
int d = 0; d < NDIM; d++)
464 r.
e(d) =
pmod((*
this)[d], m[d]);
507 r.
e(d) = dir_dot_product(d1, d);
508 r.
e(d) += dir_dot_product(d2, d);
516 r.
e(d) = dir_dot_product(d1, d);
517 r.
e(d) -= dir_dot_product(d2, d);
525 foralldir(d) r.
e(d) = i * dir_dot_product(d, dir);
554 foralldir(d) cv.
e(d) = dir_dot_product(dir, d) - cv.
e(d);
std::ostream & operator<<(std::ostream &strm, const Array< n, m, T > &A)
Stream operator.
auto operator+(const Array< n, m, A > &a, const Array< n, m, B > &b)
Addition operator.
Class for coordinate vector useful in indexing lattice.
CoordinateVector_t mod(const CoordinateVector_t &m) const
CoordinateVector_t(const Direction dir)
Construct from site index.
CoordinateVector_t(std::nullptr_t z)
Construct from 0, using nullptr_t autocast.
Vector< 4, double > convert_to_k() const
Convert momentum space CoordinateVector to wave number k, where -pi/2 < k_i <= pi_2 Utility function ...
CoordinateVector_t(std::initializer_list< S > rhs)
CoordinateVector_t & operator=(std::initializer_list< S > rhs) &
Assign from initializer list.
CoordinateVector_t & operator=(std::nullptr_t z) &
Assign from 0.
T e(const int i, const int j) const
Standard array indexing operation for matrices and vectors.
Matrix class which defines matrix operations.
X-coordinate type - "dummy" class.
::Parity parity() const
Returns parity of site at index X.
int coordinate(Direction d) const
Returns dth dimension coordinate of X.
const CoordinateVector & coordinates() const
Returns coordinate of site at index X.
T abs(const Complex< T > &a)
Return absolute value of Complex number.
Parity
Parity enum with values EVEN, ODD, ALL; refers to parity of the site. Parity of site (x,...
int pmod(const int a, const int b)
constexpr Parity EVEN
bit pattern: 001
#define foralldir(d)
Macro to loop over (all) Direction(s)
constexpr unsigned NDIRS
Number of directions.
constexpr Parity ODD
bit pattern: 010
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
constexpr Parity ALL
bit pattern: 011
CoordinateVector operator*(const int i, const Direction dir)
Special operators: int*Direction -> CoordinateVector (of type int!)
Direction operator-(const Direction d)
unary + and -
This file defines all includes for HILA.
Definition of Matrix types.
Implement hila::swap for gauge fields.
X + coordinate offset, used in f[X+CoordinateVector] or f[X+dir1+dir2] etc.