2 #include "StRoot/TR/TRMatrixD.h"
6 void Newguy(
const char *t1,
const char *t2) {
7 cout <<
" ---------------------------------------------------------------" << endl <<
8 " Routing " << t2 <<
" testing " << t1 << endl;
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());
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);
28 Newguy(
"MXMPY-1-2-3.",
"TMXM ");
30 temp =
new TRMatrixD(ac,kAxB,bc);
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;
37 else cout <<
"ac,kAxB,bc Passed" << endl;
39 temp =
new TRMatrixD(ac,kAxBT,bct);
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;
46 else cout <<
"ac,kAxBT,bct Passed" << endl;
48 temp =
new TRMatrixD(act,kATxB,bc);
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;
55 else cout <<
"act,kATxB,bc Passed" << endl;
58 temp =
new TRMatrixD(act,kATxBT,bct);
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;
65 else cout <<
"act,kATxBT,bct Passed" << endl;
68 temp =
new TRMatrixD(ac,kAxB,acA);
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;
75 else cout <<
"ac,kAxB,acA Passed" << endl;
78 Newguy(
"MXMAD-1-2-3.",
"TMXM ");
83 TRMatrixD aplus1(ac,kAxB,acA);
84 TRMatrixD amin2(aplus1);
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;
95 else cout <<
"Add ac,kAxB,acA Passed" << endl;
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;
106 else cout <<
"Add ac,kAxBT,bct Passed" << endl;
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;
117 else cout <<
"Add act,kATxB,bc Passed" << endl;
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;
129 else cout <<
"Add act,kATxBT,bct Passed" << endl;
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;
140 else cout <<
"Add act,kATxBT,bct Passed" << endl;
143 Newguy(
"MXMUB-1-2-3.",
"TMXM ");
144 TRMatrixD dmin__(3,4);
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;
154 else cout <<
"Substruct(ac,kAxB,bc) Passed" << endl;
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;
165 else cout <<
"Substruct(ac,kAxBT,bct) Passed" << endl;
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;
176 else cout <<
"Substruct(act,kATxB,bc) Passed" << endl;
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;
187 else cout <<
"Substruct(act,kATxBT,bct) Passed" << endl;
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;
199 else cout <<
"Substruct(ac,kAxB,acA) Passed" << endl;
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 ");
212 Newguy(
"TRINV -TRSINV.",
"TTRINV ");
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;
220 else cout <<
"ac,kInverted Passed" << endl;
231 TRSymMatrixD dc(4,
" 1. 2. 3. 0. 0. 0. 4. 5. 0. 6. ");
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.");
241 Double_t zerlev = 1e-6;
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;
252 else cout <<
"ec,kAxAT passed" << endl;
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;
263 else cout <<
"ecA,kATxA passed" << endl;
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;
273 else cout <<
"ecA,kAxSxATx,ac Passed" << endl;
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;
282 else cout <<
"ec,kATxSxA,dc Passed" << endl;
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;
291 else cout <<
"dc,kRxSxR,ac Passed" << endl;
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;
301 else cout <<
"dc,kSxA, ec Passed" << endl;
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;
311 else cout <<
"acA,kAxS,dc Passed" << endl;
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;
322 else cout <<
"dc,kSxAT,ecA Passed" << endl;
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;
331 else cout <<
"ec,kATxS,dc Passed" << endl;
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;
343 else cout <<
"packing of upckc Passed" << endl;
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;
352 else cout <<
"unpacking of pckc Passed" << endl;
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;
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;
368 else cout <<
"unpacking of A11 Passed" << endl;
380 gSystem->Load(
"../Linux-gcc-dbg/libRootKernel.so");