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

colvartypes.h File Reference

Go to the source code of this file.

Classes

class  colvarmodule::rvector
 1-dimensional vector of real numbers with three components More...
class  colvarmodule::vector1d< T, length >
 Arbitrary size array (one dimensions) suitable for linear algebra operations (i.e. for floating point numbers it can be used with library functions). More...
class  colvarmodule::matrix2d< T, outer_length, inner_length >
 Arbitrary size array (two dimensions) suitable for linear algebra operations (i.e. for floating point numbers it can be used with library functions). More...
class  colvarmodule::rmatrix
 2-dimensional array of real numbers with three components along each dimension (works with colvarmodule::rvector) More...
class  colvarmodule::quaternion
 1-dimensional vector of real numbers with four components and a quaternion algebra More...
class  colvarmodule::rotation
 A rotation between two sets of coordinates (for the moment a wrapper for colvarmodule::quaternion). More...

Defines

#define PI   3.14159265358979323846

Functions

cvm::rvector operator * (cvm::rmatrix const &m, cvm::rvector const &r)
void jacobi (cvm::real **a, int n, cvm::real d[], cvm::real **v, int *nrot)
 Numerical recipes diagonalization.
void eigsrt (cvm::real d[], cvm::real **v, int n)
 Eigenvector sort.
void transpose (cvm::real **v, int n)
 Transpose the matrix.


Define Documentation

#define PI   3.14159265358979323846
 

Definition at line 5 of file colvartypes.h.

Referenced by colvar::dihedral::calc_force_invgrads(), colvarbias_meta::colvarbias_meta(), CrosstermElem::computeForce(), crossterm_setup(), colvarmodule::quaternion::dist2(), colvar::dihedral::dist2(), colvarmodule::quaternion::dist2_grad(), colvar::dihedral::dist2_lgrad(), colvar::dihedral::dist2_rgrad(), ComputeEField::doForce(), GromacsTopFile::GromacsTopFile(), proc_getdihedral(), and vec_rotation_matrix().


Function Documentation

void eigsrt cvm::real  d[],
cvm::real **  v,
int  n
 

Eigenvector sort.

Definition at line 1244 of file colvarmodule.C.

References j.

01245 {
01246   int k,j,i;
01247   cvm::real p;
01248 
01249   for (i=0;i<n;i++) {
01250     p=d[k=i];
01251     for (j=i+1;j<n;j++)
01252       if (d[j] >= p) p=d[k=j];
01253     if (k != i) {
01254       d[k]=d[i];
01255       d[i]=p;
01256       for (j=0;j<n;j++) {
01257         p=v[j][i];
01258         v[j][i]=v[j][k];
01259         v[j][k]=p;
01260       }
01261     }
01262   }
01263 }

void jacobi cvm::real **  a,
int  n,
cvm::real  d[],
cvm::real **  v,
int *  nrot
 

Numerical recipes diagonalization.

Definition at line 1163 of file colvarmodule.C.

References colvarmodule::fatal_error(), j, and ROTATE.

01164 {
01165   int j,iq,ip,i;
01166   cvm::real tresh,theta,tau,t,sm,s,h,g,c;
01167 
01168   std::vector<cvm::real> b (n, 0.0);
01169   std::vector<cvm::real> z (n, 0.0);
01170 
01171   for (ip=0;ip<n;ip++) {
01172     for (iq=0;iq<n;iq++) v[ip][iq]=0.0;
01173     v[ip][ip]=1.0;
01174   }
01175   for (ip=0;ip<n;ip++) {
01176     b[ip]=d[ip]=a[ip][ip];
01177     z[ip]=0.0;
01178   }
01179   *nrot=0;
01180   for (i=0;i<=50;i++) {
01181     sm=0.0;
01182     for (ip=0;ip<n-1;ip++) {
01183       for (iq=ip+1;iq<n;iq++)
01184         sm += fabs(a[ip][iq]);
01185     }
01186     if (sm == 0.0) {
01187       return;
01188     }
01189     if (i < 4)
01190       tresh=0.2*sm/(n*n);
01191     else
01192       tresh=0.0;
01193     for (ip=0;ip<n-1;ip++) {
01194       for (iq=ip+1;iq<n;iq++) {
01195         g=100.0*fabs(a[ip][iq]);
01196         if (i > 4 && (cvm::real)(fabs(d[ip])+g) == (cvm::real)fabs(d[ip])
01197             && (cvm::real)(fabs(d[iq])+g) == (cvm::real)fabs(d[iq]))
01198           a[ip][iq]=0.0;
01199         else if (fabs(a[ip][iq]) > tresh) {
01200           h=d[iq]-d[ip];
01201           if ((cvm::real)(fabs(h)+g) == (cvm::real)fabs(h))
01202             t=(a[ip][iq])/h;
01203           else {
01204             theta=0.5*h/(a[ip][iq]);
01205             t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
01206             if (theta < 0.0) t = -t;
01207           }
01208           c=1.0/sqrt(1+t*t);
01209           s=t*c;
01210           tau=s/(1.0+c);
01211           h=t*a[ip][iq];
01212           z[ip] -= h;
01213           z[iq] += h;
01214           d[ip] -= h;
01215           d[iq] += h;
01216           a[ip][iq]=0.0;
01217           for (j=0;j<=ip-1;j++) {
01218             ROTATE(a,j,ip,j,iq)
01219               }
01220           for (j=ip+1;j<=iq-1;j++) {
01221             ROTATE(a,ip,j,j,iq)
01222               }
01223           for (j=iq+1;j<n;j++) {
01224             ROTATE(a,ip,j,iq,j)
01225               }
01226           for (j=0;j<n;j++) {
01227             ROTATE(v,j,ip,j,iq)
01228               }
01229           ++(*nrot);
01230         }
01231       }
01232     }
01233     for (ip=0;ip<n;ip++) {
01234       b[ip] += z[ip];
01235       d[ip]=b[ip];
01236       z[ip]=0.0;
01237     }
01238   }
01239   cvm::fatal_error ("Too many iterations in routine jacobi.\n");
01240 }

cvm::rvector operator * cvm::rmatrix const &  m,
cvm::rvector const &  r
[inline]
 

Definition at line 529 of file colvartypes.h.

References colvarmodule::rmatrix::xx(), colvarmodule::rmatrix::xy(), colvarmodule::rmatrix::xz(), colvarmodule::rmatrix::yx(), colvarmodule::rmatrix::yy(), colvarmodule::rmatrix::yz(), colvarmodule::rmatrix::zx(), colvarmodule::rmatrix::zy(), and colvarmodule::rmatrix::zz().

00531 {
00532   return cvm::rvector (m.xx()*r.x + m.xy()*r.y + m.xz()*r.z,
00533                        m.yx()*r.x + m.yy()*r.y + m.yz()*r.z,
00534                        m.zx()*r.x + m.zy()*r.y + m.zz()*r.z);
00535 }

void transpose cvm::real **  v,
int  n
 

Transpose the matrix.

Definition at line 1266 of file colvarmodule.C.

References j.

01267 {
01268   cvm::real p;
01269   for (int i=0;i<n;i++) {
01270     for (int j=i+1;j<n;j++) {
01271       p=v[i][j];
01272       v[i][j]=v[j][i];
01273       v[j][i]=p;
01274     }
01275   }
01276 }


Generated on Mon Nov 23 04:59:26 2009 for NAMD by  doxygen 1.3.9.1