NAMD
Public Member Functions | Protected Attributes | Friends | List of all members
AVector Class Reference

#include <FreeEnergyVector.h>

Public Member Functions

 AVector (Vector_t Type=kRegular)
 
 AVector (double x, double y, double z)
 
 AVector (const AVector &Vector)
 
Bool_t Set (double x, double y, double z)
 
AVector operator+ (const AVector &Vector)
 
AVector operator- (const AVector &Vector)
 
AVector operator/ (double divisor)
 
AVectoroperator/= (double divisor)
 
AVectoroperator*= (double scalar)
 
AVector operator* (double scalar)
 
AVectoroperator= (const AVector &Vector)
 
AVectoroperator+= (const AVector &Vector)
 
AVector cross (const AVector &Vector)
 
double dot (const AVector &Vector)
 
double & operator[] (int index)
 
double Dist ()
 
double DistSqr ()
 
double Dist (const AVector &Vector)
 
double DistSqr (const AVector &Vector)
 
void Out ()
 
void Output ()
 
AVectorScale (AVector &SmallVec, AVector &BigVec)
 
AVectorRandom ()
 

Protected Attributes

double m_x
 
double m_y
 
double m_z
 

Friends

void SetEqual (AVector &Vec1, const Vector &Vec2)
 
void SetEqual (Vector &Vec1, const AVector &Vec2)
 

Detailed Description

Definition at line 14 of file FreeEnergyVector.h.

Constructor & Destructor Documentation

AVector::AVector ( Vector_t  Type = kRegular)

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 18 of file FreeEnergyVector.C.

References ASSERT, kRandom, kRegular, m_x, m_y, m_z, and Random().

18  {
19 //------------------------------------------------
20 // init this vector to (0,0,0) for kRegular Type
21 // init this vector to (x,y,z) for kRandom Type
22 // where x, y, and z are in the range (0:1)
23 //
24 // Note: The assumption is made that srand() has
25 // already been called.
26 //------------------------------------------------
27  if (Type == kRegular) {
28  m_x = 0.0;
29  m_y = 0.0;
30  m_z = 0.0;
31  }
32  else {
33  ASSERT(Type == kRandom);
34  Random();
35  }
36 }
#define ASSERT(E)
double m_z
double m_x
AVector & Random()
double m_y
AVector::AVector ( double  x,
double  y,
double  z 
)

Definition at line 39 of file FreeEnergyVector.C.

References m_x, m_y, m_z, x, y, and z.

39  {
40 //-------------------------------------------
41 // init this vector to (x,y,z)
42 //-------------------------------------------
43  m_x = x;
44  m_y = y;
45  m_z = z;
46 }
double m_z
gridSize z
double m_x
gridSize y
gridSize x
double m_y
AVector::AVector ( const AVector Vector)

Definition at line 49 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

49  {
50 //-------------------------------------------
51 // init this vector to Vector
52 //-------------------------------------------
53  m_x = Vector.m_x;
54  m_y = Vector.m_y;
55  m_z = Vector.m_z;
56 }
double m_z
double m_x
double m_y

Member Function Documentation

AVector AVector::cross ( const AVector Vector)

Definition at line 243 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

Referenced by ARestraint::GetDihe(), and ADiheRestraint::GetGrad().

243  {
244 //-------------------------------------------------------------------
245 // calculate this vector crossed with Vector (this x Vector).
246 // see Mathematical Handbook, p.118.
247 //-------------------------------------------------------------------
248  AVector CrossProduct;
249 
250  CrossProduct.m_x = (m_y * Vector.m_z) - (m_z * Vector.m_y);
251  CrossProduct.m_y = (m_z * Vector.m_x) - (m_x * Vector.m_z);
252  CrossProduct.m_z = (m_x * Vector.m_y) - (m_y * Vector.m_x);
253  return(CrossProduct);
254 }
double m_z
double m_x
double m_y
double AVector::Dist ( )

Definition at line 205 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

Referenced by AForcingDistRestraint::Get_dU_dLambda(), ARestraint::GetAngle(), ARestraint::GetDihe(), AFixedPosRestraint::GetDistance(), ABoundPosRestraint::GetDistance(), AForcingPosRestraint::GetDistance(), ADistRestraint::GetE(), ABoundPosRestraint::GetEnergy(), ABoundDistRestraint::GetEnergy(), ADistRestraint::GetGrad(), AnAngleRestraint::GetGrad(), ADiheRestraint::GetGrad(), ABoundPosRestraint::GetGradient(), ABoundDistRestraint::GetGradient(), ADiheRestraint::gradU(), and ADistRestraint::PrintInfo().

205  {
206 //-------------------------------------------------------------------
207 // calculate distance from this point to (0, 0, 0)
208 //-------------------------------------------------------------------
209  return( sqrt(m_x*m_x + m_y*m_y + m_z*m_z) );
210 }
double m_z
double m_x
double m_y
double AVector::Dist ( const AVector Vector)

Definition at line 221 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

221  {
222 //-------------------------------------------------------------------
223 // calculate distance between this point and Vector
224 //-------------------------------------------------------------------
225  double d1 = (m_x - Vector.m_x);
226  double d2 = (m_y - Vector.m_y);
227  double d3 = (m_z - Vector.m_z);
228  return( sqrt(d1*d1 + d2*d2 + d3*d3) );
229 }
double m_z
double m_x
double m_y
double AVector::DistSqr ( )

Definition at line 213 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

213  {
214 //-------------------------------------------------------------------
215 // calculate distance-squared from this point to (0, 0, 0)
216 //-------------------------------------------------------------------
217  return(m_x*m_x + m_y*m_y + m_z*m_z);
218 }
double m_z
double m_x
double m_y
double AVector::DistSqr ( const AVector Vector)

Definition at line 232 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

232  {
233 //-------------------------------------------------------------------
234 // calculate distance-squared between this point and Vector
235 //-------------------------------------------------------------------
236  double d1 = (m_x - Vector.m_x);
237  double d2 = (m_y - Vector.m_y);
238  double d3 = (m_z - Vector.m_z);
239  return(d1*d1 + d2*d2 + d3*d3);
240 }
double m_z
double m_x
double m_y
double AVector::dot ( const AVector Vector)

Definition at line 257 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

Referenced by ARestraint::GetDihe(), ADiheRestraint::GetGrad(), and ADiheRestraint::gradU().

257  {
258 //-------------------------------------------------------------------
259 // calculate dot product of this vector and Vector
260 // see Mathematical Handbook, p.118.
261 //-------------------------------------------------------------------
262  return(m_x*Vector.m_x + m_y*Vector.m_y + m_z*Vector.m_z);
263 }
double m_z
double m_x
double m_y
AVector AVector::operator* ( double  scalar)

Definition at line 137 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

137  {
138 //---------------------------------------------------
139 // create a new vector: this one divided by divisor
140 //---------------------------------------------------
141  AVector Point(m_x*scalar, m_y*scalar, m_z*scalar);
142  return(Point);
143 }
double m_z
double m_x
double m_y
AVector & AVector::operator*= ( double  scalar)

Definition at line 126 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

126  {
127 //------------------------------------------------------
128 // multiply this vector by scalar and return a ref to it
129 //------------------------------------------------------
130  m_x *= scalar;
131  m_y *= scalar;
132  m_z *= scalar;
133  return(*this);
134 }
double m_z
double m_x
double m_y
AVector AVector::operator+ ( const AVector Vector)

Definition at line 88 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

88  {
89 //----------------------------------------------------------
90 // create a new vector: the sum of this one and passed one
91 //----------------------------------------------------------
92  AVector Point(vector.m_x+m_x, vector.m_y+m_y, vector.m_z+m_z);
93  return(Point);
94 }
double m_z
double m_x
double m_y
AVector & AVector::operator+= ( const AVector Vector)

Definition at line 177 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

177  {
178 //--------------------------------------------------
179 // set this vector to this one plus the passed one
180 //--------------------------------------------------
181  m_x += vector.m_x;
182  m_y += vector.m_y;
183  m_z += vector.m_z;
184  return(*this);
185 }
double m_z
double m_x
double m_y
AVector AVector::operator- ( const AVector Vector)

Definition at line 97 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

97  {
98 //----------------------------------------------------------
99 // create a new vector: this one minus the passed one
100 //----------------------------------------------------------
101  AVector Point(m_x-vector.m_x, m_y-vector.m_y, m_z-vector.m_z);
102  return(Point);
103 }
double m_z
double m_x
double m_y
AVector AVector::operator/ ( double  divisor)

Definition at line 106 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

106  {
107 //---------------------------------------------------
108 // create a new vector: this one divided by divisor
109 //---------------------------------------------------
110  AVector Point(m_x/divisor, m_y/divisor, m_z/divisor);
111  return(Point);
112 }
double m_z
double m_x
double m_y
AVector & AVector::operator/= ( double  divisor)

Definition at line 115 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

115  {
116 //------------------------------------------------------
117 // divide this vector by divisor and return a ref to it
118 //------------------------------------------------------
119  m_x /= divisor;
120  m_y /= divisor;
121  m_z /= divisor;
122  return(*this);
123 }
double m_z
double m_x
double m_y
AVector & AVector::operator= ( const AVector Vector)

Definition at line 166 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

166  {
167 //-------------------------------------------
168 // set this vector to the passed one
169 //-------------------------------------------
170  m_x = vector.m_x;
171  m_y = vector.m_y;
172  m_z = vector.m_z;
173  return(*this);
174 }
double m_z
double m_x
double m_y
double & AVector::operator[] ( int  index)

Definition at line 188 of file FreeEnergyVector.C.

References ASSERT, m_x, m_y, and m_z.

188  {
189 //-------------------------------------------------------------------
190 // return one element of this vector
191 // note: this op is used to get AND set an element
192 // (since it returns double&)
193 //-------------------------------------------------------------------
194  ASSERT( (index>=0) && (index<3) );
195 
196  switch(index) {
197  case 0: return(m_x);
198  case 1: return(m_y);
199  case 2: return(m_z);
200  default: return(m_x); // should never get here
201  }
202 }
#define ASSERT(E)
double m_z
double m_x
double m_y
void AVector::Out ( )

Definition at line 266 of file FreeEnergyVector.C.

References iout, m_x, m_y, and m_z.

Referenced by APosRestraint::PrintInfo().

266  {
267 //-------------------------------------------------------------------
268 // write it
269 //-------------------------------------------------------------------
270  char Str1[20], Str2[20], Str3[20];
271 
272  sprintf(Str1, "%8.3f", m_x);
273  sprintf(Str2, "%8.3f", m_y);
274  sprintf(Str3, "%8.3f", m_z);
275  iout << "(" << Str1 << "," << Str2 << "," << Str3 << ")";
276 }
#define iout
Definition: InfoStream.h:51
double m_z
double m_x
double m_y
void AVector::Output ( )

Definition at line 279 of file FreeEnergyVector.C.

References iout, m_x, m_y, and m_z.

279  {
280 //-------------------------------------------------------------------
281 // write it to standard output
282 //-------------------------------------------------------------------
283  char Word1[20], Word2[20], Word3[20];
284 
285  if ( (fabs(m_x)<99999) && (fabs(m_y)<99999) && (fabs(m_z)<99999) ) {
286  sprintf(Word1, "%10.3f", m_x);
287  sprintf(Word2, "%10.3f", m_y);
288  sprintf(Word3, "%10.3f", m_z);
289  }
290  else {
291  sprintf(Word1, "%10.2e", m_x);
292  sprintf(Word2, "%10.2e", m_y);
293  sprintf(Word3, "%10.2e", m_z);
294  }
295  iout << "( " << Word1 << " " << Word2 << " " << Word3 << " )";
296 }
#define iout
Definition: InfoStream.h:51
double m_z
double m_x
double m_y
AVector & AVector::Random ( )

Definition at line 59 of file FreeEnergyVector.C.

References ASSERT, m_x, m_y, and m_z.

Referenced by AVector().

59  {
60 //------------------------------------------------
61 // replace this vector with a new random vector
62 // where x, y, and z are in the range (0:1)
63 //------------------------------------------------
64  double RandMax;
65 
66  RandMax = RAND_MAX;
67  m_x = (double)rand() / RandMax;
68  m_y = (double)rand() / RandMax;
69  m_z = (double)rand() / RandMax;
70  ASSERT(m_x <= 1.0);
71  ASSERT(m_y <= 1.0);
72  ASSERT(m_z <= 1.0);
73  return(*this);
74 }
#define ASSERT(E)
double m_z
double m_x
double m_y
AVector & AVector::Scale ( AVector SmallVec,
AVector BigVec 
)

Definition at line 299 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

299  {
300 //-------------------------------------------------------------------
301 // scale this vector, whose (x,y,z) are in the range (0:1),
302 // to be in the range (SmallVec:BigVec)
303 //-------------------------------------------------------------------
304  m_x = SmallVec.m_x + (BigVec.m_x - SmallVec.m_x) * m_x;
305  m_y = SmallVec.m_y + (BigVec.m_y - SmallVec.m_y) * m_y;
306  m_z = SmallVec.m_z + (BigVec.m_z - SmallVec.m_z) * m_z;
307  return(*this);
308 }
double m_z
double m_x
double m_y
Bool_t AVector::Set ( double  x,
double  y,
double  z 
)

Definition at line 77 of file FreeEnergyVector.C.

References kTrue, m_x, m_y, m_z, x, y, and z.

Referenced by ADistRestraint::GetGrad(), ADiheRestraint::GetGrad(), ABoundPosRestraint::GetGradient(), and ARestraint::UpdateCOMs().

77  {
78 //-------------------------------------------
79 // int this vector to (x,y,z)
80 //-------------------------------------------
81  m_x = x;
82  m_y = y;
83  m_z = z;
84  return(kTrue);
85 }
double m_z
gridSize z
double m_x
gridSize y
gridSize x
double m_y

Friends And Related Function Documentation

void SetEqual ( AVector Vec1,
const Vector Vec2 
)
friend

Definition at line 146 of file FreeEnergyVector.C.

146  {
147 //------------------------------------------------------------------------
148 // used for casting Vector -> AVector
149 //------------------------------------------------------------------------
150  Vec1.m_x = Vec2.x;
151  Vec1.m_y = Vec2.y;
152  Vec1.m_z = Vec2.z;
153 }
BigReal z
Definition: Vector.h:66
double m_z
BigReal x
Definition: Vector.h:66
BigReal y
Definition: Vector.h:66
double m_x
double m_y
void SetEqual ( Vector Vec1,
const AVector Vec2 
)
friend

Definition at line 156 of file FreeEnergyVector.C.

156  {
157 //------------------------------------------------------------------------
158 // used for casting AVector -> Vector
159 //------------------------------------------------------------------------
160  Vec1.x = Vec2.m_x;
161  Vec1.y = Vec2.m_y;
162  Vec1.z = Vec2.m_z;
163 }
BigReal z
Definition: Vector.h:66
double m_z
BigReal x
Definition: Vector.h:66
BigReal y
Definition: Vector.h:66
double m_x
double m_y

Member Data Documentation

double AVector::m_x
protected
double AVector::m_y
protected
double AVector::m_z
protected

The documentation for this class was generated from the following files: