StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Micky.C
1 #ifndef __CINT__
2 #include "StRoot/TR/TRMatrixD.h"
3 #else
4 class TRMatrixD;
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  TRMatrixD ac(3,2," 0. 1. 2. 3. 4. 5.");
14  TRMatrixD acA(2,3,ac.GetArray());
15  TRMatrixD bc(2,4," 0. 20. 30. 40. 50. 60. 70. 80.");
16  TRMatrixD bcA(4,2,bc.GetArray());
17  //TRMatrixD c1c(3,4,"50. 60. 70. 80. 170. 220. 270. 320. 290. 380. 470. 560.");
18  TRMatrixD c1c(3,4,"50. 60. 70. 80. 150. 220. 270. 320. 250. 380. 470. 560.");
19  TRMatrixD c1cA(4,3,c1c.GetArray());
20  TRMatrixD c2c(3,3,"3. 4. 5. 9. 14. 19. 15. 24. 33.");
21  TRMatrixD d__(3,4,"2. 4. 6. 8. 102. 104. 106. 108. 202. 204. 206. 208.");
22  TRMatrixD d_A(4,3,d__.GetArray());
23  TRMatrixD d_3(3,3,d__.GetArray());
24  TRMatrixD bct(bc,kTransposed);
25  TRMatrixD act(ac,kTransposed);
26  Double_t zeru = 1.e6;
27  /* TEST FOR MXMPY-1-2-3 */
28  Newguy("MXMPY-1-2-3.", "TMXM ");
29  TRMatrixD *temp = 0;
30  temp = new TRMatrixD(ac,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 TRMatrixD(ac,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 TRMatrixD(act,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 TRMatrixD(act,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 TRMatrixD(ac,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  TRMatrixD aplus(c1c);
80  aplus += d__;
81  TRMatrixD amin(c1c);
82  amin -= d__;
83  TRMatrixD aplus1(ac,kAxB,acA);
84  TRMatrixD amin2(aplus1);
85  aplus1 += d_3;
86  amin2 -= d_3;
87  temp = new TRMatrixD(d__);
88  temp->Add(ac,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 TRMatrixD(d__);
99  temp->Add(ac,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 TRMatrixD(d__);
110  temp->Add(act,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 TRMatrixD(d__);
122  temp->Add(act,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 TRMatrixD(d_3);
133  temp->Add(ac,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  TRMatrixD dmin__(3,4);
145  dmin__ -= d__;
146  temp = new TRMatrixD(d__);
147  temp->Substruct(ac,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 TRMatrixD(d__);
158  temp->Substruct(ac,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 TRMatrixD(d__);
169  temp->Substruct(act,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 TRMatrixD(d__);
180  temp->Substruct(act,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 TRMatrixD(d_3);
192  temp->Substruct(ac,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  TRSymMatrixD ac(4,"1. 0. 0. 2. 0. 13. 4. 0. 23. 77. ");
210  TRSymMatrixD rc(4," 1.45679 0. 0. -.191358 0. .1882716 -.0185185 0. -.0462963 .02777778 ");
211 
212  Newguy("TRINV -TRSINV.", "TTRINV ");
213  zerlev = 1e-4;
214  TRSymMatrixD *B = new TRSymMatrixD(ac,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  TRSymMatrixD dc(4," 1. 2. 3. 0. 0. 0. 4. 5. 0. 6. ");
232  //? TRMatrixD ec(4,3,"4. 7. 3. 17. 32. 18. 0. 0. 0. 43. 64. 44.");
233  TRSymMatrixD ac(4,"1. 0. 0. 2. 0. 13. 4. 0. 23. 77.");
234  TRSymMatrixD sc(3,"1384. 1712. 2201. 858. 1075. 538.");
235  TRSymMatrixD atsac(3," 239. 331. 447. 248. 345. 257. ");
236  TRSymMatrixD qsqc(4," 1265. 1594. 2009. 0. 0. 0. 1940. 2446. 0. 2980. ");
237  TRMatrixD sac(4,3," 18. 23. 19. 27. 37. 28. 0. 0. 0. 43. 64. 44. ");
238  TRMatrixD asc(3,4," 30. 44. 0. 69. 34. 49. 0. 74. 17. 26. 0. 42.");
239  // TRMatrixD atsac[6] = { 239. 331. 447. 248. 345. 257. };
240 
241  Double_t zerlev = 1e-6;
242 
243  Newguy("TRAAT-TRATA.", "TTRLA ");
244  TRMatrixD ec(4,3,"4. 7. 3. 3. 6. 4. 0. 5. 5. 2. 1. 2.");
245  TRSymMatrixD *A = new TRSymMatrixD(ec,kAxAT);
246  TRSymMatrixD 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  TRMatrixD ecA(3,4,ec.GetArray());
256  TRSymMatrixD *A = new TRSymMatrixD(ecA,kATxA);
257  TRSymMatrixD 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  TRSymMatrixD *A2 = new TRSymMatrixD(ecA,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  TRSymMatrixD *A3 = new TRSymMatrixD(ec,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  TRSymMatrixD *A4 = new TRSymMatrixD(dc,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  TRMatrixD *A5 = new TRMatrixD(dc,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  TRMatrixD *A6 = new TRMatrixD(ecA,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  TRMatrixD *A7 = new TRMatrixD(dc,kSxAT,ecA);
316  TRMatrixD 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  TRMatrixD *A8 = new TRMatrixD(ec,kATxS,dc);
325  TRMatrixD 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  TRMatrixD upckc(4,4," 1.,2.,4.,7.,2.,3.,5.,8.,4.,5.,6.,9.,7.,8.,9.,10.");
336  TRSymMatrixD pckc(4,"1.,2.,3.,4.,5.,6.,7.,8.,9.,10.");
337  TRSymMatrixD *A9 = new TRSymMatrixD(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  TRMatrixD *A10 = new TRMatrixD(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  TRSymMatrixD *A11 = new TRSymMatrixD(*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  TRMatrixD *A12 = new TRMatrixD(*A11);
363  if (A11->Verify(upckc,zerlev)) {
364  cout << "A11:" << *A11 << endl;
365  cout << "upckc:" << upckc << endl;
366  cout << "A12" << *A12 << endl;
367  }
368  else cout << "unpacking of A11 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("../Linux-gcc-dbg/libRootKernel.so");
381 #endif
382 #if 1
383  Tmxm();
384  ttrinv();
385 #endif
386  ttrla();
387 }