Initial snark14m import
[snark14.git] / src / snark / emap_CReadInp.cpp
1 /*   
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/emap_CReadInp.cpp $
5  $LastChangedRevision: 85 $
6  $Date: 2014-07-02 16:07:08 -0400 (Wed, 02 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9
10  ===========================================================================
11  Read information of the input file and allocates the work space
12  ===========================================================================
13  */
14
15 #include <cstdio>
16
17 #include "blkdta.h"
18 #include "uiod.h"
19 #include "infile.h"
20 #include "blob.h"
21
22 #include "emap.h"   
23
24 void emap_class::ReadInp(INTEGER area, INTEGER nelem, INTEGER usrays,
25                 INTEGER prjnum, BOOLEAN* flag) // nelem is not used. hstau 6/9/2003, flag added 1/04
26 {
27         INTEGER eval;
28         BOOLEAN eol;
29         INTEGER doit = CHAR2INT('e', 'v', 'a', 'l');
30
31         //------ read parameters from input file
32         ///MAPEM.gamma1 = getnum(input, &eol);
33
34         (*flag) = FALSE;
35         MAPEM.gamma1 = InFile.getnum(TRUE, &eol);
36         if (eol)
37         {
38                 fprintf(output, "\n          **** error - must specify gamma ***");
39                 (*flag) = TRUE;
40                 return;
41         }
42         MAPEM.idxmax = 1;
43         MAPEM.idymax = 1;
44         MAPEM.mapevl = FALSE;
45
46         INTEGER exp[1] =
47         { doit };
48         eval = InFile.getwrd(FALSE, &eol, exp, 1);
49
50         if (!eol)
51                 MAPEM.mapevl = TRUE;
52
53         if (MAPEM.mapevl)
54         {
55                 MAPEM.sclfactor = 1.0;
56         }
57
58         //------ write the parameters into the output file
59         fprintf(output,
60                         "\n\n  -----------------------------------------------------------\n");
61
62         fprintf(output,
63                         "\n   maximum a-posteriori probability expectation maximization");
64
65         fprintf(output, "\n\n            gamma:%8.3f", MAPEM.gamma1);
66
67         if (MAPEM.mapevl)
68         {
69                 fprintf(output, "\n            evaluation flag is set ");
70
71         }
72         else
73         {
74                 fprintf(output, "\n            evaluation flag is not set");
75         }
76
77         fprintf(output,
78                         "\n\n  -----------------------------------------------------------\n");
79
80         //------ allocate space for the intermediate results
81
82         MAPEM.qj = new REAL[area];
83
84         if (Blob.pix_basis)
85         {       //only when pixel
86                 MAPEM.Kx = new REAL[area];
87                 MAPEM.Sx = new REAL[area];
88                 MAPEM.Sjjinv = new REAL[area];
89         }
90
91         MAPEM.Wjj = new REAL[area];
92         MAPEM.prj = new REAL[prjnum * usrays];
93
94         return;
95 }