4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Gromacs Runs One Microsecond At Cannonball Speeds
39 t_mat
*init_mat(int n1
,bool b1D
)
52 m
->mat
= mk_matrix(n1
,n1
,b1D
);
61 void enlarge_mat(t_mat
*m
,int deltan
)
65 srenew(m
->erow
,m
->nn
+deltan
);
66 srenew(m
->m_ind
,m
->nn
+deltan
);
67 srenew(m
->mat
,m
->nn
+deltan
);
69 /* Reallocate existing rows in the matrix, and set them to zero */
70 for(i
=0; (i
<m
->nn
); i
++) {
71 srenew(m
->mat
[i
],m
->nn
+deltan
);
72 for(j
=m
->nn
; (j
<m
->nn
+deltan
); j
++)
75 /* Allocate new rows of the matrix, set energies to zero */
76 for(i
=m
->nn
; (i
<m
->nn
+deltan
); i
++) {
78 snew(m
->mat
[i
],m
->nn
+deltan
);
83 void reset_index(t_mat
*m
)
87 for(i
=0; (i
<m
->n1
); i
++)
91 void set_mat_entry(t_mat
*m
,int i
,int j
,real val
)
93 m
->mat
[i
][j
] = m
->mat
[j
][i
] = val
;
94 m
->maxrms
= max(m
->maxrms
,val
);
96 m
->minrms
= min(m
->minrms
,val
);
98 m
->nn
= max(m
->nn
,max(j
+1,i
+1));
101 void done_mat(t_mat
**m
)
103 done_matrix((*m
)->n1
,&((*m
)->mat
));
110 real
row_energy(int nn
,int row
,real
*mat
)
115 for(i
=0; (i
<nn
); i
++) {
116 re
+= abs(i
-row
)*mat
[i
];
121 real
mat_energy(t_mat
*m
)
127 for(j
=0; (j
<m
->nn
); j
++) {
129 re
= row_energy(m
->nn
,jj
,m
->mat
[j
]);
133 m
->emat
= retot
/m
->nn
;
137 void swap_rows(t_mat
*m
,int isw
,int jsw
)
144 m
->mat
[isw
] = m
->mat
[jsw
];
147 for(i
=0; (i
<m
->nn
); i
++) {
148 ttt
= m
->mat
[isw
][i
];
149 m
->mat
[isw
][i
] = m
->mat
[jsw
][i
];
150 m
->mat
[jsw
][i
] = ttt
;
154 void swap_mat(t_mat
*m
)
159 tmp
= init_mat(m
->nn
,FALSE
);
160 for(i
=0; (i
<m
->nn
); i
++)
161 for(j
=0; (j
<m
->nn
); j
++)
162 tmp
->mat
[m
->m_ind
[i
]][m
->m_ind
[j
]] = m
->mat
[i
][j
];
163 /*tmp->mat[i][j] = m->mat[m->m_ind[i]][m->m_ind[j]]; */
164 for(i
=0; (i
<m
->nn
); i
++)
165 for(j
=0; (j
<m
->nn
); j
++)
166 m
->mat
[i
][j
] = tmp
->mat
[i
][j
];
170 void low_rmsd_dist(char *fn
,real maxrms
,int nn
,real
**mat
)
179 for(j
=i
+1; j
<nn
; j
++) {
180 x
= (int)(fac
*mat
[i
][j
]+0.5);
185 fp
= xvgropen(fn
,"RMS Distribution","RMS (nm)","a.u.");
186 for(i
=0; (i
<101); i
++)
187 fprintf(fp
,"%10g %10d\n",i
/fac
,histo
[i
]);
192 void rmsd_distribution(char *fn
,t_mat
*rms
)
194 low_rmsd_dist(fn
,rms
->maxrms
,rms
->nn
,rms
->mat
);
197 t_clustid
*new_clustid(int n1
)
203 for(i
=0; (i
<n1
); i
++) {