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) {
132constexpr inline const char *direction_name(
Direction d) {
133 const char *dirnames[
NDIRS] = {
150inline std::string prettyprint(
Direction d) {
151 return direction_name(d);
157 os << hila::direction_name(d);
166enum class Parity :
unsigned { none = 0, even, odd, all };
185inline const char *parity_name(
Parity p) {
186 const char *parity_name_s[4] = {
"Parity::none",
"EVEN",
"ODD",
"ALL"};
187 return parity_name_s[(int)p];
190inline std::string prettyprint(
Parity p) {
191 return hila::parity_name(p);
198 os << hila::parity_name(p);
203static inline unsigned parity_bits(
Parity p) {
204 return 0x3 &
static_cast<unsigned>(p);
206static inline unsigned parity_bits_inverse(
Parity p) {
207 return 0x3 & ~static_cast<unsigned>(p);
212 unsigned u = parity_bits(p);
213 return static_cast<Parity>(0x3 & ((u << 1) | (u >> 1)));
218 return opp_parity(p);
221static inline bool is_even_odd_parity(
Parity p) {
222 return (p ==
EVEN || p ==
ODD);
231inline int pmod(
const int a,
const int b) {
258 using base_type = hila::arithmetic_type<T>;
259 using argument_type = T;
272 foralldir(d) this->
e(d) = dir_dot_product(d, dir);
283 template <typename S, std::enable_if_t<hila::is_assignable<T &, S>::value,
int> = 0>
285 assert(rhs.size() == NDIM &&
"CoordinateVector initializer list size does not match");
287 for (
auto it = rhs.begin(); it != rhs.end(); it++, i++)
305#pragma hila loop_function
312 template <typename S, std::enable_if_t<hila::is_assignable<T &, S>::value,
int> = 0>
314 assert(rhs.size() == NDIM &&
"Initializer list has a wrong size in assignment");
316 for (
auto it = rhs.begin(); it != rhs.end(); it++, i++) {
326 if (this->
e(d) != rhs.
e(d))
333 T &operator[](
const int i) {
338 return this->
e((
int)d);
341 T operator[](
const int i)
const {
346 return this->
e((
int)d);
370 template <
typename S>
373 for (
int d = 0; d < NDIM; d++)
433 r.
e(d) =
pmod((*
this)[d], m[d]);
468 r.
e(d) = dir_dot_product(d1, d);
469 r.
e(d) += dir_dot_product(d2, d);
477 r.
e(d) = dir_dot_product(d1, d);
478 r.
e(d) -= dir_dot_product(d2, d);
486 foralldir(d) r.
e(d) = i * dir_dot_product(d, dir);
515 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.
Class for coordinate vector useful in indexing lattice.
CoordinateVector_t & operator=(std::nullptr_t z)
Assign from 0.
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.
CoordinateVector_t(std::initializer_list< S > rhs)
CoordinateVector_t & operator=(std::initializer_list< S > rhs)
Assign from initializer list.
T e(const int i, const int j) const
Standard array indexing operation for matrices.
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.
Invert diagonal + const. matrix using Sherman-Morrison formula.
X + coordinate offset, used in f[X+CoordinateVector] or f[X+dir1+dir2] etc.