#include <cmath>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. | |
|
|
||||||||||||||||
|
Eigenvector sort.
Definition at line 1326 of file colvarmodule.C. References j. 01327 {
01328 int k,j,i;
01329 cvm::real p;
01330
01331 for (i=0;i<n;i++) {
01332 p=d[k=i];
01333 for (j=i+1;j<n;j++)
01334 if (d[j] >= p) p=d[k=j];
01335 if (k != i) {
01336 d[k]=d[i];
01337 d[i]=p;
01338 for (j=0;j<n;j++) {
01339 p=v[j][i];
01340 v[j][i]=v[j][k];
01341 v[j][k]=p;
01342 }
01343 }
01344 }
01345 }
|
|
||||||||||||||||||||||||
|
Numerical recipes diagonalization.
Definition at line 1245 of file colvarmodule.C. References colvarmodule::fatal_error(), j, and ROTATE. 01246 {
01247 int j,iq,ip,i;
01248 cvm::real tresh,theta,tau,t,sm,s,h,g,c;
01249
01250 std::vector<cvm::real> b (n, 0.0);
01251 std::vector<cvm::real> z (n, 0.0);
01252
01253 for (ip=0;ip<n;ip++) {
01254 for (iq=0;iq<n;iq++) v[ip][iq]=0.0;
01255 v[ip][ip]=1.0;
01256 }
01257 for (ip=0;ip<n;ip++) {
01258 b[ip]=d[ip]=a[ip][ip];
01259 z[ip]=0.0;
01260 }
01261 *nrot=0;
01262 for (i=0;i<=50;i++) {
01263 sm=0.0;
01264 for (ip=0;ip<n-1;ip++) {
01265 for (iq=ip+1;iq<n;iq++)
01266 sm += std::fabs(a[ip][iq]);
01267 }
01268 if (sm == 0.0) {
01269 return;
01270 }
01271 if (i < 4)
01272 tresh=0.2*sm/(n*n);
01273 else
01274 tresh=0.0;
01275 for (ip=0;ip<n-1;ip++) {
01276 for (iq=ip+1;iq<n;iq++) {
01277 g=100.0*std::fabs(a[ip][iq]);
01278 if (i > 4 && (cvm::real)(std::fabs(d[ip])+g) == (cvm::real)std::fabs(d[ip])
01279 && (cvm::real)(std::fabs(d[iq])+g) == (cvm::real)std::fabs(d[iq]))
01280 a[ip][iq]=0.0;
01281 else if (std::fabs(a[ip][iq]) > tresh) {
01282 h=d[iq]-d[ip];
01283 if ((cvm::real)(std::fabs(h)+g) == (cvm::real)std::fabs(h))
01284 t=(a[ip][iq])/h;
01285 else {
01286 theta=0.5*h/(a[ip][iq]);
01287 t=1.0/(std::fabs(theta)+std::sqrt(1.0+theta*theta));
01288 if (theta < 0.0) t = -t;
01289 }
01290 c=1.0/std::sqrt(1+t*t);
01291 s=t*c;
01292 tau=s/(1.0+c);
01293 h=t*a[ip][iq];
01294 z[ip] -= h;
01295 z[iq] += h;
01296 d[ip] -= h;
01297 d[iq] += h;
01298 a[ip][iq]=0.0;
01299 for (j=0;j<=ip-1;j++) {
01300 ROTATE(a,j,ip,j,iq)
01301 }
01302 for (j=ip+1;j<=iq-1;j++) {
01303 ROTATE(a,ip,j,j,iq)
01304 }
01305 for (j=iq+1;j<n;j++) {
01306 ROTATE(a,ip,j,iq,j)
01307 }
01308 for (j=0;j<n;j++) {
01309 ROTATE(v,j,ip,j,iq)
01310 }
01311 ++(*nrot);
01312 }
01313 }
01314 }
01315 for (ip=0;ip<n;ip++) {
01316 b[ip] += z[ip];
01317 d[ip]=b[ip];
01318 z[ip]=0.0;
01319 }
01320 }
01321 cvm::fatal_error ("Too many iterations in routine jacobi.\n");
01322 }
|
|
||||||||||||
|
Definition at line 531 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(). 00533 {
00534 return cvm::rvector (m.xx()*r.x + m.xy()*r.y + m.xz()*r.z,
00535 m.yx()*r.x + m.yy()*r.y + m.yz()*r.z,
00536 m.zx()*r.x + m.zy()*r.y + m.zz()*r.z);
00537 }
|
|
||||||||||||
|
Transpose the matrix.
Definition at line 1348 of file colvarmodule.C. References j. 01349 {
01350 cvm::real p;
01351 for (int i=0;i<n;i++) {
01352 for (int j=i+1;j<n;j++) {
01353 p=v[i][j];
01354 v[i][j]=v[j][i];
01355 v[j][i]=p;
01356 }
01357 }
01358 }
|
1.3.9.1