StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMicky.cxx
1 //*-- Author : Valery Fine(fine@bnl.gov) 25/09/99
2 //
3 // mverif.F -- translated by f2c (version 19970219).
4 //
5 // The test ("micky") of the set of methods to work with the plain
6 // matrix / vector "derived" from
7 // http://wwwinfo.cern.ch/asdoc/shortwrupsdir/f110/top.html
8 //
9 // $Id: StMicky.cxx,v 1.7 2006/12/08 17:51:12 fine Exp $
10 // $Log: StMicky.cxx,v $
11 // Revision 1.7 2006/12/08 17:51:12 fine
12 // prepare the test are to move to ROOT CVS
13 //
14 // Revision 1.6 2003/09/02 17:59:24 perev
15 // gcc 3.2 updates + WarnOff
16 //
17 // Revision 1.5 1999/12/07 22:33:10 fine
18 // Clean up to remove compilation warnings
19 //
20 // Revision 1.4 1999/10/02 21:58:07 fine
21 // double precision
22 //
23 // Revision 1.3 1999/09/30 15:50:20 fine
24 // ClassDef has been introduced
25 //
26 // Revision 1.2 1999/09/28 19:54:56 fine
27 // RMath has been renamed to StCL
28 //
29 // Revision 1.1 1999/09/26 19:35:12 fine
30 // Micky test has been rearranged
31 //
32 // Revision 1.1 1999/09/23 18:33:10 fine
33 // test system for StCL class has been introduced
34 //
35 //
36 
37 #include <Stiostream.h>
38 #include "StMicky.h"
39 
40 inline double dabs(double d){ return d>0?d: -d;}
41 inline int min(int n1, int n2){ return n1 < n2 ? n1 : n2;}
42 
43 
44 //___________________________________________________________________________
45 StMicky::StMicky(){ Minit(); }
46 
47 //___________________________________________________________________________
48 void StMicky::Prtest(){
49  if (param_1.ntest <= 0 ) return;
50  if (param_1.nfail) cout << " TESTS FAIL ";
51  else cout << " Tests pass ";
52  for (int i =0;i<=param_1.ntest;i++) cout << param_1.mtestv[i] << " ";
53  cout << endl;
54  param_1.ntest = 0;
55 };
56 
57 //__________________________________________________________________
58 void StMicky::Minit()
59 {
60  /* Initialized data */
61 
62  static struct {
63  char e_1[188];
64  int e_2;
65  } equiv_7 = { {' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', '1', ' ', ' ',
66  ' ', '2', ' ', ' ', ' ', '3', ' ', ' ', ' ', '4', ' ', ' ',
67  ' ', '5', ' ', ' ', ' ', '6', ' ', ' ', ' ', '7', ' ', ' ',
68  ' ', '8', ' ', ' ', ' ', '9', ' ', ' ', ' ', 'A', ' ', ' ',
69  ' ', 'B', ' ', ' ', ' ', 'C', ' ', ' ', ' ', 'D', ' ', ' ',
70  ' ', 'E', ' ', ' ', ' ', 'F', ' ', ' ', ' ', 'G', ' ', ' ',
71  ' ', 'H', ' ', ' ', ' ', 'I', ' ', ' ', ' ', 'J', ' ', ' ',
72  ' ', 'K', ' ', ' ', ' ', 'L', ' ', ' ', ' ', 'M', ' ', ' ',
73  ' ', 'N', ' ', ' ', ' ', 'O', ' ', ' ', ' ', 'P', ' ', ' ',
74  ' ', 'Q', ' ', ' ', ' ', 'R', ' ', ' ', ' ', 'S', ' ', ' ',
75  ' ', 'T', ' ', ' ', ' ', 'U', ' ', ' ', ' ', 'V', ' ', ' ',
76  ' ', 'W', ' ', ' ', ' ', 'X', ' ', ' ', ' ', 'Y', ' ', ' ',
77  ' ', 'Z', ' ', ' ', ' ', '+', ' ', ' ', ' ', '-', ' ', ' ',
78  ' ', '=', ' ', ' ', ' ', '*', ' ', ' ', ' ', '/', ' ', ' ',
79  ' ', '(', ' ', ' ', ' ', ')', ' ', ' ', ' ', '.', ' ', ' ',
80  ' ', ',', ' ', ' ', ' ', '\'', ' ', ' ', ' '}, 0 };
81 
82 #define mbcd ((int *)&equiv_7)
83 
84 
85  /* Local variables */
86  int j;
87 
88  ia = (int *)(&(_BLNK__1.a));
89  ib = (int *)(&(_BLNK__1.b));
90 
91  da = (double *)(&(_BLNK__1.a));
92  db = (double *)(&(_BLNK__1.b));
93 
94  param_1.iqbitw = 32;
95  param_1.iqchaw = 4;
96  param_1.itb = 6;
97  param_1.itimes = 0;
98  for (j = 1; j <= 47; ++j) _BLNK__1.ibcd[j - 1] = mbcd[j - 1];
99  for (j = 1; j <= 100; ++j) _BLNK__1.intg[j - 1] = j;
100 
101 /* ---- ZEROV(1-5) CONTAIN THE LEVELS OF PRECISION EXPECTED AFTER */
102 /* - (1) NO, (2) LITTLE, (3) SOME, (4) FAIR, (5) MUCH FLOATING CALC
103  */
104  param_1.zerov[0] = (float)1e-10;
105  param_1.zerov[1] = (float)1e-6;
106  param_1.zerov[2] = (float)1e-5;
107  param_1.zerov[3] = (float)1e-4;
108  param_1.zerov[4] = (float).001;
109  param_1.zergu = param_1.zerov[0];
110  param_1.zerlev = param_1.zerov[0];
111  param_1.nfaipr = 4;
112  param_1.neachp = 0;
113  param_1.nfailt = 0;
114  param_1.nfail = 0;
115  param_1.ntest = 0;
116  /* Format strings */
117  cout << " MICKY executing." << endl;
118  cout << " MICKY 2.71 950712 9.30" << endl;
119 
120 
121 // kerngt_(&param_1.itb);
122 } /* minit_ */
123 
124 
125 //___________________________________________________________________________
126 void StMicky::Mverif(int ntt, float *have, float *amust, int nn)
127 {
128  /* System generated locals */
129  float r__1;
130 
131  /* Local variables */
132  float diff, test[200], zeru;
133  int j, nhave, ntuse, n1, n2;
134 
135  int jj;
136  float sum;
137 
138 
139 /* -----------------------------------------------------------------------
140  */
141  /* Parameter adjustments */
142  --amust;
143  --have;
144 
145  /* Function Body */
146  ntuse = ntt;
147  nhave = nn;
148  if (nhave >= 201) {
149  Prtest();
150  cout << endl << " VERIFF VECTOR FOR TEST" << ntuse
151  << " MORE THAN 200 WORDS, namely " << nhave << endl;
152  return;
153  }
154 
155  zeru = param_1.zerlev;
156  if (param_1.ntest >= 10) StMicky::Prtest();
157 
158 /* ---- Verify */
159  for (jj = 1; jj <= nhave; ++jj) {
160  j = jj;
161  diff = (r__1 = have[j] - amust[j], dabs(r__1));
162  if (diff < zeru) continue;
163  sum = (r__1 = have[j] + amust[j], dabs(r__1));
164 
165  if (sum < 2. || (diff * (float)2. / sum > zeru)) goto L41;
166  }
167 /* ---- VERIFY OK. */
168  if (param_1.nfail) {
169  Prtest();
170  param_1.nfail = 0;
171  }
172 
173  ++param_1.ntest;
174  param_1.mtestv[param_1.ntest - 1] = ntuse;
175  if (param_1.neachp == 0) return ;
176  Prtest();
177  return ;
178 /* ---- VERIFY FAILURE */
179 L41:
180  jj = j;
181  ++param_1.nfailt;
182  if (param_1.nfail == 0) Prtest();
183  else if (param_1.nfail > param_1.nfaipr) ++param_1.nfail;
184 
185  cout << " TEST " << ntuse << " FAILED, Dump follows" << endl;
186  ++param_1.nfail;
187  n1 = jj;
188  do {
189  // Computing MIN */
190  n2 = min(n1 + 4,nhave);
191  cout << n1 << " MUST ";
192  for (j = n1; j <= n2; ++j) {
193 // cout << hex << amust[j] << " ";
194  cout << amust[j] << " ";
195  if ((j-n1)%5 == 0) cout << endl;
196  }
197  cout << endl;
198 
199  cout << " HAVE ";
200  for (j = n1; j <= n2; ++j) {
201 // cout << hex << have[j] << " ";
202  cout << have[j] << " ";
203  if ((j-n1)%5 == 0) cout << endl;
204  }
205  cout << endl;
206 
207  n1 += 5;
208  } while (n1 <= nhave);
209 
210  if (n1 - 1 != nhave) cout << endl;
211 
212 /* -- PRINT VECTORS IN FLOATING FORMAT */
213 
214  cout << " Floating point values, ZERLEV= "<< zeru << endl;
215 
216  for (j = jj; j <= nhave; ++j) {
217  diff = (r__1 = have[j] - amust[j], dabs(r__1));
218  sum = (r__1 = have[j] + amust[j], dabs(r__1));
219  test[j - 1] = (float)0.;
220  if (diff < zeru) continue;
221  test[j - 1] = diff;
222  if (sum < (float)2.) continue;
223  test[j - 1] = test[j - 1] * (float)2. / sum;
224  }
225  n1 = jj;
226 
227  do {
228  // Computing MIN
229  n2 = min(n1 + 4,nhave);
230  cout << n1 << " MUST ";
231  for (j = n1; j <= n2; ++j) {
232  cout << amust[j] << " ";
233  if ((j-n1)%5 == 0) cout << endl;
234  }
235  cout << endl;
236 
237  cout << " HAVE ";
238  for (j = n1; j <= n2; ++j) {
239  cout << have[j] << " ";
240  if ((j-n1)%5 == 0) cout << endl;
241  }
242  cout << endl;
243 
244  cout << " TEST ";
245  for (j = n1; j <= n2; ++j) {
246  cout << test[j - 1] << " ";
247  if ((j-n1)%5 == 0) cout << endl;
248  }
249  cout << endl;
250 
251  n1 += 5;
252  } while (n1 <= nhave);
253 
254  cout << endl;
255  return;
256 } /* mverif_ */
257 
258 //____________________________________________________________________________________
259 void StMicky::Newguy(const char *t1, const char *t2) {
260  Prtest();
261  param_1.nfail = 0;
262  cout << " ---------------------------------------------------------------" << endl <<
263  " Routing " << t2 << " testing " << t1 << endl;
264 }
265