20 Lattice(
void) : a1(0,0,0), a2(0,0,0), a3(0,0,0),
21 b1(0,0,0), b2(0,0,0), b3(0,0,0),
22 o(0,0,0), p1(0), p2(0), p3(0) {};
25 static int index(
int i=0,
int j=0,
int k=0)
27 return 9 * (k+1) + 3 * (j+1) + (i+1);
43 if ( ! p1 ) a1 =
Vector(1.0,0.0,0.0);
47 if ( fabs(e_z * u1) < 0.9 ) { a2 =
cross(e_z,a1); }
55 if (
volume() < 0.0 ) a3 *= -1.0;
79 return (o + a1*s.
x + a2*s.
y + a3*s.
z);
86 return Vector(b1*p,b2*p,b3*p);
134 return ( data + t.
i*a1 + t.
j*a2 + t.
k*a3 );
140 return ( data - t.
i*a1 - t.
j*a2 - t.
k*a3 );
146 Vector diff = pos1 - pos2;
147 #ifdef ARCH_POWERPC //Prevents stack temporaries
151 result.
x -= a1.
x *fval;
152 result.
y -= a1.
y *fval;
153 result.
z -= a1.
z *fval;
157 result.
x -= a2.
x * fval;
158 result.
y -= a2.
y * fval;
159 result.
z -= a2.
z * fval;
163 result.
x -= a3.
x * fval;
164 result.
y -= a3.
y * fval;
165 result.
z -= a3.
z * fval;
172 diff.x -= f1*a1.
x + f2*a2.
x + f3*a3.
x;
173 diff.y -= f1*a1.
y + f2*a2.
y + f3*a3.
y;
174 diff.z -= f1*a1.
z + f2*a2.
z + f3*a3.
z;
179 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
184 Vector diff = pos1 - pos2;
227 for (
int i1=-p1; i1<=p1; ++i1 ) {
228 for (
int i2 =-p2; i2<=p2; ++i2 ) {
229 for (
int i3 =-p3; i3<=p3; ++i3 ) {
230 Vector newresult = i1*a1+i2*a2+i3*a3;
231 BigReal newdist = (diff+newresult).length2();
232 if ( newdist < dist ) {
239 return result0 + result;
244 return ( (i%3-1) * a1 + ((i/3)%3-1) * a2 + (i/9-1) * a3 );
258 return ( ! ( a1.
y || a1.
z || a2.
x || a2.
z || a3.
x || a3.
y ) );
273 int a_p()
const {
return p1; }
274 int b_p()
const {
return p2; }
275 int c_p()
const {
return p3; }
279 return ( p1 && p2 && p3 ?
cross(a1,a2) * a3 : 0.0 );
289 void recalculate(
void) {
static int index(int i=0, int j=0, int k=0)
static int offset_b(int i)
static int offset_c(int i)
Vector delta(const Position &pos1) const
Vector wrap_delta(const Position &pos1) const
__device__ __forceinline__ float3 cross(const float3 v1, const float3 v2)
BigReal length(void) const
void set(Vector A, Vector B, Vector C, Position Origin)
Position nearest(Position data, ScaledPosition ref) const
Position nearest(Position data, ScaledPosition ref, Transform *t) const
void rescale(Tensor factor)
static int offset_a(int i)
void set(Vector A, Vector B, Vector C)
Vector delta(const Position &pos1, const Position &pos2) const
BigReal volume(void) const
BigReal length2(void) const
Vector offset(int i) const
Position apply_transform(Position data, const Transform &t) const
Position unscale(ScaledPosition s) const
Position reverse_transform(Position data, const Transform &t) const
ScaledPosition scale(Position p) const
void rescale(Position &p, Tensor factor) const
Vector wrap_nearest_delta(Position pos1) const