1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
int
TheseusLite(Cds *cds, int num, int len, double prec)
{
int i, outrnd, inrnd;
Cds **cdsa = NULL;
Cds *avecds = NULL;
/* setup cdsA */
CdsSetup(cdsa);
CdsCpy(avecds, cdsa->cds[0]);
/* The CEM algorithm */
/* The outer loop:
(1) First calculates the translations
(2) Does inner loop -- calc rotations and average till convergence
(3) Holding the superposition constant, calculates the covariance
matrices and corresponding weight matrices */
outrnd = 0;
while(1)
{
++outrnd;
/* Estimate Translations: Find weighted center and translate all cds */
CalcTransIp(cdsa);
CenCdsIp(cdsa);
/* Inner loop:
(1) Calc rotations given weights/weight matrices
(2) Rotate cds with new rotations
(3) Recalculate average
Loop till convergence, holding constant the variances, covariances, and translations */
inrnd = 0;
do
{
++inrnd;
/* find the optimal rotation matrices */
CalcRots(cdsa);
if (CheckOutConv(cdsa, inrnd, outrnd, prec) == 1)
return(outrnd);
/* rotate the scratch cds with new rotation matrix */
RotCdsIp(cdsa);
/* find global rmsd and average cds (both held in structure) */
AveCds(cdsa, avecds);
}
while(CheckInConv(cdsa, outrnd, inrnd, prec) == 0);
/* Holding the superposition constant, calculate the covariance
matrix and corresponding weight matrix, looping till convergence. */
CalcVars(cdsa, vars);
}
return(outrnd);
}
|