20#define MSB ((MyIntPosType)(~((MyIntPosType)(~((MyIntPosType)0)) >> ((MyIntPosType)1))))
22#if defined(LONG_X_BITS)
23#define HBITS_X ((MyIntPosType)(~((MyIntPosType)(~((MyIntPosType)0)) >> ((MyIntPosType)LONG_X_BITS))))
26#if defined(LONG_Y_BITS)
27#define HBITS_Y ((MyIntPosType)(~((MyIntPosType)(~((MyIntPosType)0)) >> ((MyIntPosType)LONG_Y_BITS))))
30#if defined(LONG_Z_BITS)
31#define HBITS_Z ((MyIntPosType)(~((MyIntPosType)(~((MyIntPosType)0)) >> ((MyIntPosType)LONG_Z_BITS))))
46#ifdef RANDOMIZE_DOMAINCENTER
50#ifdef EXPLICIT_VECTORIZATION
54#if defined(GRAVITY_TALLBOX) || defined(LONG_X_BITS) || defined(LONG_Y_BITS) || defined(LONG_Z_BITS)
55 Terminate(
"not working in this combination");
58 Vec4MyIntPosType delta = a - Vec4MyIntPosType(b0, b1, b2, b3);
60 Vec4MySignedIntPosType intpos = (Vec4MySignedIntPosType)delta;
62 Vec4d pos = to_double(intpos);
72#if defined(LONG_X_BITS)
73 pos[0] = (pos[0] << LONG_X_BITS) >> LONG_X_BITS;
76#if defined(LONG_Y_BITS)
77 pos[1] = (pos[1] << LONG_Y_BITS) >> LONG_Y_BITS;
80#if defined(LONG_Z_BITS)
81 pos[2] = (pos[2] << LONG_Z_BITS) >> LONG_Z_BITS;
109#if defined(LONG_X_BITS)
110 MyIntPosType delta = (a << LONG_X_BITS) - (b << LONG_X_BITS);
114 delta >>= LONG_X_BITS;
118 delta >>= LONG_X_BITS;
128#if defined(LONG_Y_BITS)
129 MyIntPosType delta = (a << LONG_Y_BITS) - (b << LONG_Y_BITS);
133 delta >>= LONG_Y_BITS;
137 delta >>= LONG_Y_BITS;
147#if defined(LONG_Z_BITS)
148 MyIntPosType delta = (a << LONG_Z_BITS) - (b << LONG_Z_BITS);
152 delta >>= LONG_Z_BITS;
156 delta >>= LONG_Z_BITS;
165 template <
typename T>
174#if defined(GRAVITY_TALLBOX) && (GRAVITY_TALLBOX == 0)
177 delta[0] = a[0] - b[0];
182 delta[0] = b[0] - a[0];
187#if defined(LONG_X_BITS)
188 delta[0] = (a[0] << LONG_X_BITS) - (b[0] << LONG_X_BITS);
192 delta[0] >>= LONG_X_BITS;
196 delta[0] >>= LONG_X_BITS;
198 delta[0] = a[0] - b[0];
206#if defined(GRAVITY_TALLBOX) && (GRAVITY_TALLBOX == 1)
209 delta[1] = a[1] - b[1];
214 delta[1] = b[1] - a[1];
219#if defined(LONG_Y_BITS)
220 delta[1] = (a[1] << LONG_Y_BITS) - (b[1] << LONG_Y_BITS);
224 delta[1] >>= LONG_Y_BITS;
228 delta[1] >>= LONG_Y_BITS;
230 delta[1] = a[1] - b[1];
238#if defined(GRAVITY_TALLBOX) && (GRAVITY_TALLBOX == 2)
241 delta[2] = a[2] - b[2];
246 delta[2] = b[2] - a[2];
251#if defined(LONG_Z_BITS)
252 delta[2] = (a[2] << LONG_Z_BITS) - (b[2] << LONG_Z_BITS);
256 delta[2] >>= LONG_Z_BITS;
260 delta[2] >>= LONG_Z_BITS;
262 delta[2] = a[2] - b[2];
271#if defined(LONG_X_BITS)
272 delta[0] = (a[0] << LONG_X_BITS) - (b[0] << LONG_X_BITS);
276 delta[0] >>= LONG_X_BITS;
280 delta[0] >>= LONG_X_BITS;
282 delta[0] = a[0] - b[0];
285#if defined(LONG_Y_BITS)
286 delta[1] = (a[1] << LONG_Y_BITS) - (b[1] << LONG_Y_BITS);
290 delta[1] >>= LONG_Y_BITS;
294 delta[1] >>= LONG_Y_BITS;
296 delta[1] = a[1] - b[1];
299#if defined(LONG_Z_BITS)
300 delta[2] = (a[2] << LONG_Z_BITS) - (b[2] << LONG_Z_BITS);
304 delta[2] >>= LONG_Z_BITS;
308 delta[2] >>= LONG_Z_BITS;
310 delta[2] = a[2] - b[2];
314 delta[0] = -delta[0];
317 delta[1] = -delta[1];
320 delta[2] = -delta[2];
323#if defined(POSITIONS_IN_32BIT)
324 template <
typename T>
330 template <
typename T>
333 for(
int j = 0; j < 3; j++)
336#elif defined(POSITIONS_IN_64BIT)
337 template <
typename T>
343 template <
typename T>
346 for(
int j = 0; j < 3; j++)
350 template <
typename T>
356 template <
typename T>
359 for(
int j = 0; j < 3; j++)
364 template <
typename T>
367 for(
int j = 0; j < 3; j++)
374 for(
int j = 0; j < 3; j++)
376 return sqrt(pos[0] * pos[0] + pos[1] * pos[1] + pos[2] * pos[2]);
379 template <
typename T>
382#ifdef RANDOMIZE_DOMAINCENTER
385 for(
int j = 0; j < 3; j++)
386 xyz[j] = intpos[j] - CurrentShiftVector[j];
388 for(
int j = 0; j < 3; j++)
391 for(
int j = 0; j < 3; j++)
396 for(
int j = 0; j < 3; j++)
399 for(
int j = 0; j < 3; j++)
407#ifdef RANDOMIZE_DOMAINCENTER
408 for(
int j = 0; j < 3; j++)
409 xyz[j] = intpos[j] - CurrentShiftVector[j];
411 for(
int j = 0; j < 3; j++)
418 Terminate(
"integer coordinate output not defined if PERIODIC is not no");
422 template <
typename T>
436 while(pos >= ((T)(~((
MyIntPosType)0)) +
static_cast<T
>(1.0)))
448 template <
typename T>
451#ifdef RANDOMIZE_DOMAINCENTER
453 for(
int j = 0; j < 3; j++)
456 intpos[j] += CurrentShiftVector[j];
460 for(
int j = 0; j < 3; j++)
463 intpos[j] += CurrentShiftVector[j];
468 for(
int j = 0; j < 3; j++)
473 for(
int j = 0; j < 3; j++)
declares a structure for global parameters and variables.
global_data_all_processes All
void nearest_image_intpos_to_absolute_intdist(const MyIntPosType *a, const MyIntPosType *b, MyIntPosType *delta)
double signedintpos_to_distanceorigin(MySignedIntPosType *intpos)
void intpos_to_intpos(MyIntPosType *intpos, MyIntPosType *xyz)
void pos_to_intpos(T *posdiff, MyIntPosType *intpos)
void nearest_image_intpos_to_pos(const MyIntPosType *const a, const MyIntPosType *const b, T *posdiff)
void pos_to_signedintpos(T *posdiff, MySignedIntPosType *intpos)
MySignedIntPosType pos_to_signedintpos(T posdiff)
void diff_intpos_to_pos(MyIntPosType *a, MyIntPosType *b, T *posdiff, offset_tuple off=0)
MyIntPosType nearest_image_intpos_to_intpos_Y(const MyIntPosType a, const MyIntPosType b)
MyIntPosType nearest_image_intpos_to_intpos_Z(const MyIntPosType a, const MyIntPosType b)
void intpos_to_pos(MyIntPosType *intpos, T *posdiff)
MyIntPosType nearest_image_intpos_to_intpos_X(const MyIntPosType a, const MyIntPosType b)
void signedintpos_to_pos(MySignedIntPosType *intpos, T *pos)
void constrain_intpos(MyIntPosType *pos)
defines some custom data types used by the code
int32_t MySignedIntPosType