StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Micky.C
1 #ifndef __CINT__
2 #include "TRMatrix.h"
3 #else
4 class TRMatrix;
5 #endif
6 void Newguy(const char *t1, const char *t2) {
7  cout << " ---------------------------------------------------------------" << endl <<
8  " Routing " << t2 << " testing " << t1 << endl;
9 }
10 //________________________________________________________________________________
11 void Tmxm() {// F110
12  /* Initialized data */
13  TRMatrix ac(3,2," 0. 1. 2. 3. 4. 5.");
14  TRMatrix acA(2,3,ac.GetArray());
15  TRMatrix bc(2,4," 0. 20. 30. 40. 50. 60. 70. 80.");
16  TRMatrix bcA(4,2,bc.GetArray());
17  //TRMatrix c1c(3,4,"50. 60. 70. 80. 170. 220. 270. 320. 290. 380. 470. 560.");
18  TRMatrix c1c(3,4,"50. 60. 70. 80. 150. 220. 270. 320. 250. 380. 470. 560.");
19  TRMatrix c1cA(4,3,c1c.GetArray());
20  TRMatrix c2c(3,3,"3. 4. 5. 9. 14. 19. 15. 24. 33.");
21  TRMatrix d__(3,4,"2. 4. 6. 8. 102. 104. 106. 108. 202. 204. 206. 208.");
22  TRMatrix d_A(4,3,d__.GetArray());
23  TRMatrix d_3(3,3,d__.GetArray());
24  TRMatrix bct(bc,TRArray::kTransposed);
25  TRMatrix act(ac,TRArray::kTransposed);
26  Double_t zeru = 1.e6;
27  /* TEST FOR MXMPY-1-2-3 */
28  Newguy("MXMPY-1-2-3.", "TMXM ");
29  TRMatrix *temp = 0;
30  temp = new TRMatrix(ac,TRArray::kAxB,bc); //[3,2]*[2,4]
31  if (temp->Verify(c1c)) {
32  cout << "ac:" << ac << endl;
33  cout << "bc:" << bc << endl;
34  cout << "Temp kAxB: ac x bc" << *temp << endl;
35  cout << "c1c " << c1c << endl;
36  }
37  else cout << "ac,kAxB,bc Passed" << endl;
38  delete temp;
39  temp = new TRMatrix(ac,TRArray::kAxBT,bct);//[3,2]*[4,2]T
40  if (temp->Verify(c1c)) {
41  cout << "act:" << act << endl;
42  cout << "bct:" << bct << endl;
43  cout << "Temp kAxBT: ac x bctT " << *temp << endl;
44  cout << "c1c " << c1c << endl;
45  }
46  else cout << "ac,kAxBT,bct Passed" << endl;
47  delete temp;
48  temp = new TRMatrix(act,TRArray::kATxB,bc);//[2,3]T*[2,4]
49  if (temp->Verify(c1c)) {
50  cout << "act:" << act << endl;
51  cout << "bc:" << bc << endl;
52  cout << "Temp kATxB: actT x bc" << *temp << endl;
53  cout << "c1c " << c1c << endl;
54  }
55  else cout << "act,kATxB,bc Passed" << endl;
56  delete temp;
57 
58  temp = new TRMatrix(act,TRArray::kATxBT,bct);//[2,3]T*[4,2]T
59  if (temp->Verify(c1c)) {
60  cout << "act:" << act << endl;
61  cout << "bct:" << bct << endl;
62  cout << "Temp kATxBT: actT x bctT" << *temp << endl;
63  cout << "c1c " << c1c << endl;
64  }
65  else cout << "act,kATxBT,bct Passed" << endl;
66  delete temp;
67 
68  temp = new TRMatrix(ac,TRArray::kAxB,acA); //[3,2]*[2,3]
69  if (temp->Verify(c2c)) {
70  cout << "ac:" << ac << endl;
71  cout << "acA:" << acA << endl;
72  cout << "Temp kAxB: ac x acA" << *temp << endl;
73  cout << "c2c " << c2c << endl;
74  }
75  else cout << "ac,kAxB,acA Passed" << endl;
76  delete temp;
77  /* TEST FOR MXMAD-12-3- */
78  Newguy("MXMAD-1-2-3.", "TMXM ");
79  TRMatrix aplus(c1c);
80  aplus += d__;
81  TRMatrix amin(c1c);
82  amin -= d__;
83  TRMatrix aplus1(ac,TRArray::kAxB,acA);
84  TRMatrix amin2(aplus1);
85  aplus1 += d_3;
86  amin2 -= d_3;
87  temp = new TRMatrix(d__);
88  temp->Add(ac,TRArray::kAxB,bc);
89  if (temp->Verify(aplus)) {
90  cout << "ac:" << ac << endl;
91  cout << "acA:" << acA << endl;
92  cout << "Temp Add kAxB: ac x acA" << *temp << endl;
93  cout << "aplus " << aplus << endl;
94  }
95  else cout << "Add ac,kAxB,acA Passed" << endl;
96  delete temp;
97 
98  temp = new TRMatrix(d__);
99  temp->Add(ac,TRArray::kAxBT,bct);
100  if (temp->Verify(aplus)) {
101  cout << "ac:" << ac << endl;
102  cout << "bct:" << bct << endl;
103  cout << "Temp Add kAxBT: ac x bctT" << *temp << endl;
104  cout << "aplus " << aplus << endl;
105  }
106  else cout << "Add ac,kAxBT,bct Passed" << endl;
107  delete temp;
108 
109  temp = new TRMatrix(d__);
110  temp->Add(act,TRArray::kATxB,bc);
111  if (temp->Verify(aplus)) {
112  cout << "act:" << act << endl;
113  cout << "bc:" << bc << endl;
114  cout << "Temp Add kATxB: actT x bc" << *temp << endl;
115  cout << "aplus " << aplus << endl;
116  }
117  else cout << "Add act,kATxB,bc Passed" << endl;
118  delete temp;
119 
120 
121  temp = new TRMatrix(d__);
122  temp->Add(act,TRArray::kATxBT,bct);
123  if (temp->Verify(aplus)) {
124  cout << "act:" << act << endl;
125  cout << "bct:" << bct << endl;
126  cout << "Temp Add kATxBT: actT x bctT" << *temp << endl;
127  cout << "aplus " << aplus << endl;
128  }
129  else cout << "Add act,kATxBT,bct Passed" << endl;
130  delete temp;
131 
132  temp = new TRMatrix(d_3);
133  temp->Add(ac,TRArray::kAxB,acA);
134  if (temp->Verify(aplus1)) {
135  cout << "ac:" << ac << endl;
136  cout << "acA:" << acA << endl;
137  cout << "Temp Add kAxB: ac x acA" << *temp << endl;
138  cout << "aplus " << aplus << endl;
139  }
140  else cout << "Add act,kATxBT,bct Passed" << endl;
141  delete temp;
142 /* TEST FOR MXMUB-1-2-3 */
143  Newguy("MXMUB-1-2-3.", "TMXM ");
144  TRMatrix dmin__(3,4);
145  dmin__ -= d__;
146  temp = new TRMatrix(d__);
147  temp->Substruct(ac,TRArray::kAxB,bc);
148  if (temp->Verify(amin)) {
149  cout << "ac:" << ac << endl;
150  cout << "bc:" << ac << endl;
151  cout << "Temp kAxB: ac x bc" << *temp << endl;
152  cout << "amin " << amin << endl;
153  }
154  else cout << "Substruct(ac,kAxB,bc) Passed" << endl;
155  delete temp;
156 
157  temp = new TRMatrix(d__);
158  temp->Substruct(ac,TRArray::kAxBT,bct);
159  if (temp->Verify(amin)) {
160  cout << "ac:" << ac << endl;
161  cout << "bct:" << act << endl;
162  cout << "Temp kAxBT: ac x bctT" << *temp << endl;
163  cout << "amin " << amin << endl;
164  }
165  else cout << "Substruct(ac,kAxBT,bct) Passed" << endl;
166  delete temp;
167 
168  temp = new TRMatrix(d__);
169  temp->Substruct(act,TRArray::kATxB,bc);
170  if (temp->Verify(amin)) {
171  cout << "act:" << act << endl;
172  cout << "bc:" << bc << endl;
173  cout << "Temp kATxB: actT x bc" << *temp << endl;
174  cout << "amin " << amin << endl;
175  }
176  else cout << "Substruct(act,kATxB,bc) Passed" << endl;
177  delete temp;
178 
179  temp = new TRMatrix(d__);
180  temp->Substruct(act,TRArray::kATxBT,bct);
181  if (temp->Verify(amin)) {
182  cout << "act:" << act << endl;
183  cout << "bct:" << bct << endl;
184  cout << "Temp kATxBT: actT x bctT" << *temp << endl;
185  cout << "amin " << amin << endl;
186  }
187  else cout << "Substruct(act,kATxBT,bct) Passed" << endl;
188  delete temp;
189 
190 
191  temp = new TRMatrix(d_3);
192  temp->Substruct(ac,TRArray::kAxB,acA);
193  if (temp->Verify(amin2)) {
194  cout << "ac:" << ac << endl;
195  cout << "acA:" << acA << endl;
196  cout << "Temp kAxB: ac xx acA" << *temp << endl;
197  cout << "amin2 " << amin2 << endl;
198  }
199  else cout << "Substruct(ac,kAxB,acA) Passed" << endl;
200  delete temp;
201 } /* tmxm_ */
202 
203 //____________________________________________________________________________________
204 void ttrinv()
205 {
206  // ttrinv.F -- translated by f2c (version 19970219).
207  /* Initialized data */
208 
209  TRSymMatrix ac(4,"1. 0. 0. 2. 0. 13. 4. 0. 23. 77. ");
210  TRSymMatrix rc(4," 1.45679 0. 0. -.191358 0. .1882716 -.0185185 0. -.0462963 .02777778 ");
211 
212  Newguy("TRINV -TRSINV.", "TTRINV ");
213  Double_t zerlev = 1e-4;
214  TRSymMatrix *B = new TRSymMatrix(ac,TRArray::kInverted);
215  if (B->Verify(rc,zerlev)) {
216  cout << "ac:" << ac << endl;
217  cout << "rc:" << rc << endl;
218  cout << "B ac,kInverted" << *B << endl;
219  }
220  else cout << "ac,kInverted Passed" << endl;
221  delete B;
222 
223 } /* trinv */
224 
225 
226 //____________________________________________________________________________________
227 void ttrla()
228 {
229 // ttrla.F -- translated by f2c (version 19970219).
230  /* Initialized data */
231  TRSymMatrix dc(4," 1. 2. 3. 0. 0. 0. 4. 5. 0. 6. ");
232  //? TRMatrix ec(4,3,"4. 7. 3. 17. 32. 18. 0. 0. 0. 43. 64. 44.");
233  TRSymMatrix ac(4,"1. 0. 0. 2. 0. 13. 4. 0. 23. 77.");
234  TRSymMatrix sc(3,"1384. 1712. 2201. 858. 1075. 538.");
235  TRSymMatrix atsac(3," 239. 331. 447. 248. 345. 257. ");
236  TRSymMatrix qsqc(4," 1265. 1594. 2009. 0. 0. 0. 1940. 2446. 0. 2980. ");
237  TRMatrix sac(4,3," 18. 23. 19. 27. 37. 28. 0. 0. 0. 43. 64. 44. ");
238  TRMatrix asc(3,4," 30. 44. 0. 69. 34. 49. 0. 74. 17. 26. 0. 42.");
239  // TRMatrix atsac[6] = { 239. 331. 447. 248. 345. 257. };
240 
241  Double_t zerlev = 1e-6;
242 
243  Newguy("TRAAT-TRATA.", "TTRLA ");
244  TRMatrix ec(4,3,"4. 7. 3. 3. 6. 4. 0. 5. 5. 2. 1. 2.");
245  TRSymMatrix *A = new TRSymMatrix(ec,TRArray::kAxAT);
246  TRSymMatrix wc(4,"74. 66. 61. 50. 50. 50. 21. 20. 15. 9.");
247  if (A->Verify(wc,zerlev)) {
248  cout << "ec:" << ec << endl;
249  cout << "wc:" << wc << endl;
250  cout << "A ec,kAxAT" << *A << endl;
251  }
252  else cout << "ec,kAxAT passed" << endl;
253  delete A;
254 
255  TRMatrix ecA(3,4,ec.GetArray());
256  TRSymMatrix *A = new TRSymMatrix(ecA,TRArray::kATxA);
257  TRSymMatrix xc(4,"77. 62. 69. 17. 23. 10. 52. 45. 11. 38.");
258  if (A->Verify(xc,zerlev)) {
259  cout << "ecA:" << ecA << endl;
260  cout << "xc:" << xc << endl;
261  cout << "A ecA,kATxA" << *A << endl;
262  }
263  else cout << "ecA,kATxA passed" << endl;
264  delete A;
265 
266  Newguy("TRASAT-TRATSA-TRQSQ.", "TTRLA ");
267  TRSymMatrix *A2 = new TRSymMatrix(ecA,TRArray::kAxSxAT,ac);
268  if (A2->Verify(sc,zerlev)) {
269  cout << "ecA:" << ecA << endl;
270  cout << "ac:" << ac << endl;
271  cout << "A ecA,kAxSxAT,ac" << *A2 << endl;
272  }
273  else cout << "ecA,kAxSxATx,ac Passed" << endl;
274  delete A2;
275 
276  TRSymMatrix *A3 = new TRSymMatrix(ec,TRArray::kATxSxA,dc);
277  if (A3->Verify(atsac,zerlev)) {
278  cout << "ec:" << ec << endl;
279  cout << "dc:" << dc << endl;
280  cout << "A ec,kATxSxA,dc" << *A3 << endl;
281  }
282  else cout << "ec,kATxSxA,dc Passed" << endl;
283  delete A3;
284 
285  TRSymMatrix *A4 = new TRSymMatrix(dc,TRArray::kRxSxR,ac);
286  if (A4->Verify(qsqc,zerlev)) {
287  cout << "dc:" << dc << endl;
288  cout << "ac:" << ac << endl;
289  cout << "A dc,kRxSxR,ac" << *A4 << endl;
290  }
291  else cout << "dc,kRxSxR,ac Passed" << endl;
292  delete A4;
293 
294  Newguy("TRSA-TRAS-TRSAT-TRATS.", "TTRLA ");
295  TRMatrix *A5 = new TRMatrix(dc,TRArray::kSxA, ec);
296  if (A5->Verify(sac,zerlev)) {
297  cout << "dc:" << dc << endl;
298  cout << "ec:" << ec << endl;
299  cout << "A dc,kSxA, ec" << *A5 << endl;
300  }
301  else cout << "dc,kSxA, ec Passed" << endl;
302  delete A5;
303 
304 
305  TRMatrix *A6 = new TRMatrix(ecA,TRArray::kAxS,dc);
306  if (A6->Verify(asc,zerlev)) {
307  cout << "ecA:" << ecA << endl;
308  cout << "asc:" << asc << endl;
309  cout << "" << *A6 << endl;
310  }
311  else cout << "acA,kAxS,dc Passed" << endl;
312  delete A6;
313 
314 
315  TRMatrix *A7 = new TRMatrix(dc,TRArray::kSxAT,ecA);
316  TRMatrix satc(4,3,"30. 34. 17. 44. 49. 26. 0. 0. 0. 69. 74. 42.");
317  if (A7->Verify(satc,zerlev)) {
318  cout << "dc:" << dc << endl;
319  cout << "ecA:" << ecA << endl;
320  cout << "A dc,kSxAT,ecA" << *A7 << endl;
321  }
322  else cout << "dc,kSxAT,ecA Passed" << endl;
323  delete A7;
324  TRMatrix *A8 = new TRMatrix(ec,TRArray::kATxS,dc);
325  TRMatrix atsc(3,4," 18. 27. 0. 43. 23. 37. 0. 64. 19. 28. 0. 44.");
326  if (A8->Verify(atsc,zerlev)) {
327  cout << "ec:" << ec << endl;
328  cout << "dc:" << dc << endl;
329  cout << "A ec,kATxS,dc" << *A8 << endl;
330  }
331  else cout << "ec,kATxS,dc Passed" << endl;
332  delete A8;
333 
334  Newguy("TRPCK-TRUPCK.", "TTRLA ");
335  TRMatrix upckc(4,4," 1.,2.,4.,7.,2.,3.,5.,8.,4.,5.,6.,9.,7.,8.,9.,10.");
336  TRSymMatrix pckc(4,"1.,2.,3.,4.,5.,6.,7.,8.,9.,10.");
337  TRSymMatrix *A9 = new TRSymMatrix(upckc);
338  if (A9->Verify(pckc,zerlev)) {
339  cout << "upckc:" << upckc << endl;
340  cout << "pckc:" << pckc << endl;
341  cout << "A upckc" << *A9 << endl;
342  }
343  else cout << "packing of upckc Passed" << endl;
344  delete A9;
345 
346  TRMatrix *A10 = new TRMatrix(pckc);
347  if (A10->Verify(upckc,zerlev)) {
348  cout << "pckc:" << pckc << endl;
349  cout << "upckc:" << upckc << endl;
350  cout << "A pckc" << *A10 << endl;
351  }
352  else cout << "unpacking of pckc Passed" << endl;
353 
354 
355  TRSymMatrix *A11 = new TRSymMatrix(*A10);
356  if (A11->Verify(pckc,zerlev)) {
357  cout << "A10:" << *A10 << endl;
358  cout << "pckc:" << pckc << endl;
359  cout << "A11:" << *A11 << endl;
360  }
361  else cout << "packing of upckc Passed" << endl;
362  TRMatrix *A12 = new TRMatrix(*A11);
363  if (A12->Verify(upckc,zerlev)) {
364  cout << "A11:" << *A11 << endl;
365  cout << "upckc:" << upckc << endl;
366  cout << "A12" << *A12 << endl;
367  }
368  else cout << "unpacking of A12 Passed" << endl;
369  delete A10;
370  delete A11;
371  delete A12;
372 
373 } /* trla */
374 
375 //________________________________________________________________________________
376 void Micky(){
377 #ifdef __CINT__
378  // gSystem->Load("libStar");
379  // gSystem->Load("TR");
380  // gSystem->Load("libRootKernel.so");
381 #endif
382 #if 1
383  Tmxm();
384  ttrinv();
385 #endif
386  ttrla();
387 }