2 ***********************************************************
3 $SNARK_Header: S N A R K 1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4 $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/trm3.cpp $
5 $LastChangedRevision: 122 $
6 $Date: 2014-07-09 18:18:59 -0400 (Wed, 09 Jul 2014) $
8 ***********************************************************
10 trm3.cpp,v 1.5 2009/06/01 03:33:26 jklukowska Exp
19 #include "consts.h" // added. hstau
21 #include "blob.h" //wei, 9/05
23 // bug220 - allow user args for termination tests - swr - 1/30/07
25 void trm3_class::Init()
29 epsiln = InFile.getnum(FALSE, &eol);
30 // bug 128 - added check for epsilon - swr - 7/6/05
31 if (epsiln <= Consts_class::zero)
33 fprintf(output, "\n **** epsilon must be specified and greater than ZERO");
34 fprintf(output, "\n **** program aborted\n");
37 fprintf(output, "\n epsilon = %10.6f", epsiln);
40 BOOLEAN trm3_class::Run(REAL* recon, INTEGER* list, REAL* weight, INTEGER iter)
47 REAL area; //wei, 9/05
54 INTEGER lhf, lhl, lmf, lml, h, m, h1, m1, ind; //wei, 9/05
59 lhf = (INTEGER) (-1 * (INTEGER) (Blob.H / 2));
60 lhl = (INTEGER) ((Blob.H - 1) / 2);
62 lmf = -1 * (INTEGER) (Blob.M / 2);
63 lml = (INTEGER) ((Blob.M - 1) / 2);
67 for (h = lhl; h >= lhf; h--)
69 for (m = lmf; m <= lml; m++)
70 { // m and h must have the same parity!!
75 ind = h1 * Blob.M + m1;
77 sqsum += recon[ind] * recon[ind];
88 for (i = 0; i < area; i++)
91 sqsum += recon[i] * recon[i];
96 var2 = sqsum / area - mean * mean; //wei, 9/05
100 if (fabs(var1) < Consts.zero)
101 { // added for robustness. hstau
103 "\n the variance in the previous iteration is less than ZERO");
107 { //added for robustness. hsta
108 chgvar = ((REAL) fabs(var2 - var1)) / var1;
112 "\n iterative process stops at iteration %5i",
115 "\n the change in variance is less than %10.6f of the variance",