Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Vector Class Reference

#include <Vector.h>

Inheritance diagram for Vector:

AlignVector zVector List of all members.

Public Member Functions

 Vector (void)
 Vector (BigReal newx, BigReal newy, BigReal newz)
 Vector (BigReal newv)
 Vector (const FloatVector &v)
BigRealoperator[] (int i)
Vectoroperator= (const BigReal &v2)
void operator+= (const Vector &v2)
void operator-= (const Vector &v2)
void operator *= (const BigReal &v2)
void operator/= (const BigReal &v2)
BigReal length (void) const
BigReal length2 (void) const
BigReal rlength (void)
Vector unit (void) const
void cross (const Vector &v2)
BigReal dot (const Vector &v2)
Bool set (const char *s)

Public Attributes

BigReal x
BigReal y
BigReal z

Friends

int operator== (const Vector &v1, const Vector &v2)
int operator!= (const Vector &v1, const Vector &v2)
Vector operator+ (const Vector &v1, const Vector &v2)
Vector operator- (const Vector &v1)
Vector operator- (const Vector &v1, const Vector &v2)
BigReal operator * (const Vector &v1, const Vector &v2)
Vector operator * (const BigReal &f, const Vector &v1)
Vector operator * (const Vector &v1, const BigReal &f)
Vector operator/ (const Vector &v1, const BigReal &f)
Vector cross (const Vector &v1, const Vector &v2)
Vector cross (const Real &k, const Vector &v1, const Vector &v2)
Vector cross (const BigReal &k, const Vector &v1, const Vector &v2)

Constructor & Destructor Documentation

Vector::Vector void   )  [inline]
 

Definition at line 68 of file Vector.h.

00068 : x(-99999), y(-99999), z(-99999) { ; }

Vector::Vector BigReal  newx,
BigReal  newy,
BigReal  newz
[inline]
 

Definition at line 71 of file Vector.h.

00072        : x(newx), y(newy), z(newz) { ; }

Vector::Vector BigReal  newv  )  [inline]
 

Definition at line 74 of file Vector.h.

00075        : x(newv), y(newv), z(newv) { ; }

Vector::Vector const FloatVector v  )  [inline]
 

Definition at line 77 of file Vector.h.

00077 : x(v.x), y(v.y), z(v.z) { ; }


Member Function Documentation

void Vector::cross const Vector v2  )  [inline]
 

Definition at line 209 of file Vector.h.

References BigReal, x, y, and z.

00209                                   {
00210        BigReal xx =  y*v2.z-v2.y*z;
00211        // BigReal yy = -x*v2.z+v2.x*z;
00212        BigReal yy = v2.x*z-x*v2.z;
00213        z =  x*v2.y-v2.x*y;
00214        y=yy;
00215        x=xx;
00216      }

BigReal Vector::dot const Vector v2  )  [inline]
 

Definition at line 219 of file Vector.h.

References BigReal, x, y, and z.

Referenced by ComputeStir::doForce().

00219                                    {
00220        return x*v2.x + y*v2.y + z*v2.z;
00221      }

BigReal Vector::length void   )  const [inline]
 

Definition at line 166 of file Vector.h.

References BigReal.

Referenced by Sequencer::addRotDragToPosition(), ImproperElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AngleElem::computeForce(), ComputeStir::doForce(), ComputeNonbondedPair::doForce(), ComputeConsTorque::doForce(), GridforceGrid::initialize(), Sequencer::maximumMove(), Lattice::set(), and vec_rotation_matrix().

00166                                        {
00167        return sqrt(x*x+y*y+z*z);
00168      }

BigReal Vector::length2 void   )  const [inline]
 

Definition at line 170 of file Vector.h.

References BigReal.

Referenced by BondElem::computeForce(), Controller::correctMomentum(), ComputeRestraints::doForce(), HomePatch::doPairlistCheck(), Sequencer::maximumMove(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), and Lattice::wrap_nearest_delta().

00170                                         {
00171        return (x*x + y*y + z*z);
00172      }

void Vector::operator *= const BigReal v2  )  [inline]
 

Definition at line 110 of file Vector.h.

00110                                                {
00111        x *= v2;
00112        y *= v2;
00113        z *= v2;
00114      }

void Vector::operator+= const Vector v2  )  [inline]
 

Definition at line 96 of file Vector.h.

References x, y, and z.

00096                                               {
00097        x += v2.x;
00098        y += v2.y;
00099        z += v2.z;
00100      }

void Vector::operator-= const Vector v2  )  [inline]
 

Definition at line 103 of file Vector.h.

References x, y, and z.

00103                                               {
00104        x -= v2.x;
00105        y -= v2.y;
00106        z -= v2.z;
00107      }

void Vector::operator/= const BigReal v2  )  [inline]
 

Definition at line 117 of file Vector.h.

References BigReal, and namd_reciprocal.

00117                                                {
00118        BigReal v2_recip = namd_reciprocal(v2);
00119        x *= v2_recip;
00120        y *= v2_recip;
00121        z *= v2_recip;
00122      }

Vector& Vector::operator= const BigReal v2  )  [inline]
 

Definition at line 88 of file Vector.h.

00088                                                  {
00089        x = v2;
00090        y = v2;
00091        z = v2;
00092        return *this;
00093      }

BigReal& Vector::operator[] int  i  )  [inline]
 

Definition at line 79 of file Vector.h.

References BigReal, and NAMD_die().

00079                                        {
00080        return i==0 ? x
00081              :i==1 ? y
00082              :i==2 ? z
00083              :(NAMD_die("Vector reference out of bounds."), x);
00084 
00085      }

BigReal Vector::rlength void   )  [inline]
 

Definition at line 174 of file Vector.h.

References BigReal, and namd_rsqrt.

Referenced by DihedralElem::computeForce(), and AngleElem::computeForce().

00174                                    {
00175        return namd_rsqrt (x*x + y*y + z*z);
00176      }

Bool Vector::set const char *  s  )  [inline]
 

Definition at line 225 of file Vector.h.

References Bool.

Referenced by ParseOptions::get().

00225                              {
00226         double a[3];    // read into doubles, since I don't know what
00227         char tmp[100];  // a "BigReal" is in real life
00228         // cheap way to get commas, etc.  a poor regex
00229        int i=sscanf(s, "%lf%99[ \t,]%lf%99[ \t,]%lf%99s",
00230                     a, tmp, a+1, tmp, a+2, tmp);
00231        if (i != 5) return FALSE;
00232        const char *t = s;       // now count commas (for "1,,,,2,  , 3")
00233        int flg = 0;                 // and check for "1 2,,3"
00234        i = 0;
00235        for (;*t;t++) {
00236           if (*t == ',') { 
00237              if (flg == 0) {   // expecting non-whitespace
00238                 return FALSE;  //    so error
00239              }
00240              flg = 0;          // now expect non-whitespace
00241              i++;              // and increment comma counter
00242           }
00243           else if (*t != ' ' && *t != '\t') {  // got non-whitespace
00244              flg = 1;          // so the next can be whitespace or commas
00245           }
00246        }
00247        if (i == 0 || i == 2) {  // allow "1 2 3" or "1, 2,3" forms
00248           x = a[0]; y = a[1]; z = a[2];
00249           return TRUE;
00250        }
00251        return FALSE;
00252      }

Vector Vector::unit void   )  const [inline]
 

Definition at line 179 of file Vector.h.

Referenced by ComputeStir::ComputeStir(), ComputeStir::doForce(), HomePatch::doMarginCheck(), ComputePmeMgr::initialize(), ComputePmeMgr::initialize_pencils(), settle1(), settlev(), and PatchMap::sizeGrid().

00179                                     {
00180        return Vector(x, y, z)/length();
00181      }


Friends And Related Function Documentation

Vector cross const BigReal k,
const Vector v1,
const Vector v2
[friend]
 

Definition at line 201 of file Vector.h.

00201                                                                                       {
00202        return Vector( k*(v1.y*v2.z-v2.y*v1.z),
00203                       // k*(-v1.x*v2.z+v2.x*v1.z),
00204                       k*(v2.x*v1.z-v1.x*v2.z),
00205                       k*(v1.x*v2.y-v2.x*v1.y) );
00206      }

Vector cross const Real k,
const Vector v1,
const Vector v2
[friend]
 

Definition at line 194 of file Vector.h.

00194                                                                                    {
00195        return Vector( k*(v1.y*v2.z-v2.y*v1.z),
00196                       // k*(-v1.x*v2.z+v2.x*v1.z),
00197                       k*(v2.x*v1.z-v1.x*v2.z),
00198                       k*(v1.x*v2.y-v2.x*v1.y) );
00199      }

Vector cross const Vector v1,
const Vector v2
[friend]
 

Definition at line 185 of file Vector.h.

00185                                                                     {
00186        return Vector( v1.y*v2.z-v2.y*v1.z,
00187                      // -v1.x*v2.z+v2.x*v1.z,
00188                       v2.x*v1.z-v1.x*v2.z,
00189                       v1.x*v2.y-v2.x*v1.y  );
00190      }

Vector operator * const Vector v1,
const BigReal f
[friend]
 

Definition at line 155 of file Vector.h.

00155                                                                         {
00156        return Vector(f*v1.x, f*v1.y, f*v1.z);
00157      }

Vector operator * const BigReal f,
const Vector v1
[friend]
 

Definition at line 151 of file Vector.h.

00151                                                                         {
00152        return Vector(f*v1.x, f*v1.y, f*v1.z);
00153      }

BigReal operator * const Vector v1,
const Vector v2
[friend]
 

Definition at line 147 of file Vector.h.

00147                                                                          {
00148        return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
00149      }

int operator!= const Vector v1,
const Vector v2
[friend]
 

Definition at line 127 of file Vector.h.

00127                                                                         {
00128        // return !(v1.x == v2.x && v1.y == v2.y && v1.z == v2.z);
00129        return v1.x != v2.x || v1.y != v2.y || v1.z != v2.z;
00130      }

Vector operator+ const Vector v1,
const Vector v2
[friend]
 

Definition at line 133 of file Vector.h.

00133                                                                         {
00134        return Vector( v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
00135      }

Vector operator- const Vector v1,
const Vector v2
[friend]
 

Definition at line 143 of file Vector.h.

00143                                                                         {
00144        return Vector( v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
00145      }

Vector operator- const Vector v1  )  [friend]
 

Definition at line 138 of file Vector.h.

00138                                                       {
00139        return Vector( -v1.x, -v1.y, -v1.z);
00140      }

Vector operator/ const Vector v1,
const BigReal f
[friend]
 

Definition at line 159 of file Vector.h.

00159                                                                         {
00160 //       if (!f)
00161 //         NAMD_die("Division by 0 on a vector operation.");
00162        return Vector(v1.x/f, v1.y/f, v1.z/f);
00163      }

int operator== const Vector v1,
const Vector v2
[friend]
 

Definition at line 124 of file Vector.h.

00124                                                                         {
00125        return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
00126      }


Member Data Documentation

BigReal Vector::x
 

Definition at line 66 of file Vector.h.

Referenced by HomePatch::addForceToMomentum(), HomePatch::addVelocityToPosition(), PatchMap::assignToPatch(), Molecule::build_constant_forces(), GlobalMasterTest::calculate(), colvarproxy_namd::calculate(), PmeRealSpace::compute_forces(), ImproperElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AngleElem::computeForce(), Controller::correctMomentum(), cross(), Lattice::delta(), Tensor::diagonal(), HomePatch::doAtomMigration(), ComputeStir::doForce(), ComputeSphericalBC::doForce(), ComputeRestraints::doForce(), ComputeNonbondedPair::doForce(), ComputeGridForce::doForce(), ComputeCylindricalBC::doForce(), HomePatch::doMarginCheck(), HomePatch::doPairlistCheck(), dot(), ComputePme::doWork(), ComputeFullDirect::doWork(), ComputeEwald::doWork(), dump_param(), dumpbench(), PDB::get_all_positions(), PDB::get_position_for_atom(), GlobalMasterIMD::get_vmd_forces(), ProxyResultVarsizeMsg::getANewMsg(), GridforceGrid::initialize(), Sequencer::langevinPiston(), PatchMap::makePatches(), mat_multiply_vec(), Lattice::nearest(), operator+=(), operator-=(), operator<<(), outer(), Tensor::outerAdd(), ProxyCombinedResultMsg::pack(), PACK_MSG(), pairlist_from_pairlist(), WorkDistrib::patchMapInit(), colvarproxy_namd::position_dist2(), colvarproxy_namd::position_dist2_lgrad(), colvarproxy_namd::position_distance(), Controller::printEnergies(), HomePatch::rattle1(), HomePatch::rattle2(), HomePatch::receiveResults(), ComputeExtMgr::recvCoord(), scale_coordinates(), scale_forces(), colvarproxy_namd::select_closest_image(), SELF(), PDB::set_all_positions(), SetEqual(), settle1(), PatchMap::sizeGrid(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), Tensor::symmetric(), Tensor::triangular(), ComputePme::ungridForces(), ProxyCombinedResultMsg::unpack(), ProxyResultMsg::unpack(), Lattice::unscale(), vec_rotation_matrix(), and Controller::writeExtendedSystemData().

BigReal Vector::y
 

Definition at line 66 of file Vector.h.

Referenced by HomePatch::addForceToMomentum(), HomePatch::addVelocityToPosition(), PatchMap::assignToPatch(), Molecule::build_constant_forces(), GlobalMasterTest::calculate(), colvarproxy_namd::calculate(), PmeRealSpace::compute_forces(), ImproperElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AngleElem::computeForce(), Controller::correctMomentum(), cross(), Lattice::delta(), Tensor::diagonal(), HomePatch::doAtomMigration(), ComputeStir::doForce(), ComputeSphericalBC::doForce(), ComputeRestraints::doForce(), ComputeNonbondedPair::doForce(), ComputeGridForce::doForce(), ComputeCylindricalBC::doForce(), HomePatch::doMarginCheck(), HomePatch::doPairlistCheck(), dot(), ComputePme::doWork(), ComputeFullDirect::doWork(), ComputeEwald::doWork(), dump_param(), dumpbench(), PDB::get_all_positions(), PDB::get_position_for_atom(), GlobalMasterIMD::get_vmd_forces(), ProxyResultVarsizeMsg::getANewMsg(), GridforceGrid::initialize(), Sequencer::langevinPiston(), PatchMap::makePatches(), mat_multiply_vec(), Lattice::nearest(), operator+=(), operator-=(), operator<<(), outer(), Tensor::outerAdd(), ProxyCombinedResultMsg::pack(), PACK_MSG(), pairlist_from_pairlist(), WorkDistrib::patchMapInit(), colvarproxy_namd::position_dist2(), colvarproxy_namd::position_dist2_lgrad(), colvarproxy_namd::position_distance(), Controller::printEnergies(), HomePatch::rattle1(), HomePatch::rattle2(), HomePatch::receiveResults(), ComputeExtMgr::recvCoord(), scale_coordinates(), scale_forces(), colvarproxy_namd::select_closest_image(), SELF(), PDB::set_all_positions(), SetEqual(), settle1(), PatchMap::sizeGrid(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), Tensor::symmetric(), Tensor::triangular(), ComputePme::ungridForces(), ProxyCombinedResultMsg::unpack(), ProxyResultMsg::unpack(), Lattice::unscale(), vec_rotation_matrix(), and Controller::writeExtendedSystemData().

BigReal Vector::z
 

Definition at line 66 of file Vector.h.

Referenced by HomePatch::addForceToMomentum(), HomePatch::addVelocityToPosition(), PatchMap::assignToPatch(), Molecule::build_constant_forces(), GlobalMasterTest::calculate(), colvarproxy_namd::calculate(), PmeRealSpace::compute_forces(), ImproperElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AngleElem::computeForce(), Controller::correctMomentum(), cross(), Lattice::delta(), Tensor::diagonal(), HomePatch::doAtomMigration(), ComputeStir::doForce(), ComputeSphericalBC::doForce(), ComputeRestraints::doForce(), ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), ComputeGridForce::doForce(), ComputeCylindricalBC::doForce(), HomePatch::doMarginCheck(), HomePatch::doPairlistCheck(), dot(), ComputePme::doWork(), ComputeHomeTuples< BondElem, Bond, BondValue >::doWork(), ComputeFullDirect::doWork(), ComputeEwald::doWork(), dump_param(), dumpbench(), PDB::get_all_positions(), PDB::get_position_for_atom(), GlobalMasterIMD::get_vmd_forces(), ProxyResultVarsizeMsg::getANewMsg(), GridforceGrid::initialize(), Sequencer::langevinPiston(), Controller::langevinPiston1(), Controller::langevinPiston2(), PatchMap::makePatches(), mat_multiply_vec(), Lattice::nearest(), operator+=(), operator-=(), operator<<(), outer(), Tensor::outerAdd(), ProxyCombinedResultMsg::pack(), PACK_MSG(), pairlist_from_pairlist(), WorkDistrib::patchMapInit(), colvarproxy_namd::position_dist2(), colvarproxy_namd::position_dist2_lgrad(), colvarproxy_namd::position_distance(), Controller::printEnergies(), HomePatch::rattle1(), HomePatch::rattle2(), HomePatch::receiveResults(), ComputeExtMgr::recvCoord(), scale_coordinates(), scale_forces(), colvarproxy_namd::select_closest_image(), SELF(), PDB::set_all_positions(), SetEqual(), settle1(), PatchMap::sizeGrid(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), Tensor::symmetric(), Tensor::triangular(), ComputePme::ungridForces(), ProxyCombinedResultMsg::unpack(), ProxyResultMsg::unpack(), Lattice::unscale(), vec_rotation_matrix(), and Controller::writeExtendedSystemData().


The documentation for this class was generated from the following file:
Generated on Sat Oct 11 04:07:48 2008 for NAMD by  doxygen 1.3.9.1