9 #include "CLHEP/Matrix/defs.h"
10 #include "CLHEP/Matrix/Matrix.h"
11 #include "CLHEP/Matrix/SymMatrix.h"
12 #include "CLHEP/Matrix/DiagMatrix.h"
13 #include "CLHEP/Matrix/Vector.h"
14 #include "CLHEP/Random/Random.h"
15 #include "CLHEP/Random/JamesRandom.h"
16 #include "CLHEP/Random/RandFlat.h"
23 using namespace CLHEP;
39 double neg(
double f,
int,
int) {
43 double absf(
double f,
int,
int) {
60 cout <<
"Starting Matrix tests" << endl;
70 cout <<
"4x5 matrix initialized to zero " <<
b;
72 cout <<
"3x3 matrix initialized to identity " << c;
80 cout <<
"3x3 matrix initialized with Random " <<
a;
83 cout <<
"matrix initialized to the previous matrix " <<
b;
92 cout <<
"8x5 matrix" <<
a;
93 cout <<
"sub matrix (2-6 x 3-5 of the previous matrix." <<
b;
96 cout <<
"embedding sub matrix at 4,3" <<
a;
99 cout <<
"dsum" <<
dsum(a,d);
110 cout <<
"a += b" << (a+=
b);
113 cout <<
"a + b" << c;
126 cout <<
"End of Matrix tests" << endl;
140 cout <<
"4x4 Symmetric matrix initialuzed to zero " <<
b;
142 cout <<
"3x3 Symmetric matrix initialized to identity "<< c;
150 cout <<
"3x3 symmetric matrix initialized with Random " << a << endl;
153 cout <<
"symmetric matrix initialized to the previous matrix " <<
b;
155 cout <<
"matrix initialized to the previous symmetric matrix "
162 cout << c(1,1) <<
" " << c[0][0] << endl;
169 cout << d(1,1) <<
" " << d[0][0] << endl;
179 cout <<
"5x5 sym matrix" <<
a;
180 cout <<
"sub sym matrix (2-5 x 2-5 of the previous sub matrix." <<
b;
183 cout <<
"embedding sub matrix at 2" <<
a;
192 cout <<
"b(sym)" <<
b;
193 cout <<
"a += b" << (a+=
b);
195 cout <<
"a + b" << c;
240 cout <<
"c\t" << c << endl;
243 cout <<
"End of SymMatrix tests" << endl;
257 cout <<
"4x4 diagonal matrix initialized to zero " <<
b;
259 cout <<
"3x3 diagonal matrix initialized to identity " << c;
267 cout <<
"3x3 diagonal matrix initialized to Random " <<
a;
270 cout <<
"diagonal matrix initialized to the previous matrix " <<
b;
272 cout <<
"matrix initialized to the previous diagonal matrix "
275 cout <<
"Symmetric matrix initialized to the previous diagonal matrix "
285 cout <<
"8x8 diag matrix" <<
a;
286 cout <<
"sub diag matrix (2-5 x 2-5 of the previous diag matrix." <<
b;
289 cout <<
"embedding sub matrix at 2" <<
a;
298 cout <<
"b(diag)" <<
b;
299 cout <<
"a += b" << (a+=
b);
301 cout <<
"a + b" << c;
304 cout <<
"End of DiagMatrix tests" << endl;
317 cout <<
"4 vector initialized to zero "<<
b;
319 cout <<
"3 vector initialized to identity " << c;
327 cout <<
"3 vector initialized to Random " <<
a;
330 cout <<
"Vector initialized to the previous vector " <<
b;
332 cout <<
"matrix initialized to the previous vector "
335 cout <<
"Vector initialized to the previous matrix "
345 cout <<
"8 vector" <<
a;
346 cout <<
"sub vector (2-5 of the previous vector." <<
b;
349 cout <<
"embedding sub vector at 2 " <<
a;
358 cout <<
"b(vector)" <<
b;
359 cout <<
"a += b" << (a+=
b);
361 cout <<
"a + b" << c;
364 cout <<
"End of Vector tests" << endl;
371 cout << std::setiosflags(std::ios::fixed) << std::setw(10);
395 #if defined(PRINTOUT)
400 #if defined(PRINTOUT)
410 #if defined(PRINTOUT)
411 cout <<
"nraw=" << b.
num_row() <<
" ncol=" << b.
num_col() << endl;
413 #if defined(PRINTOUT)
414 cout <<
"b(1,1)=" <<
b(1,1) <<
" b(2,1)=" <<
b(2,1) << endl;
454 #if defined(PRINTOUT)
455 cout <<
"Dm=" << dm <<
" d = " << d << endl;
473 #if defined(PRINTOUT)
474 cout <<
"nraw=" << sr.
num_row() <<
" ncol=" << sr.
num_col() << endl;
476 #if defined(PRINTOUT)
477 cout <<
"sr(1,1)=" << sr(1,1) <<
" sr(2,1)=" << sr(2,1) << endl;
484 #if defined(PRINTOUT)
485 cout <<
"d=" << d <<
"s=" << s << endl;
534 #if defined(PRINTOUT)
537 #if defined(PRINTOUT)
538 cout <<
"dr(1,1)=" << dr(1,1) << endl;
561 #if defined(PRINTOUT)
578 #if defined(PRINTOUT)
579 cout <<
"vz=" << vz <<
"vi=" << vi << endl;
585 #if defined(PRINTOUT)
586 cout <<
"Nr=" << vr.
num_row() << endl;
588 #if defined(PRINTOUT)
589 cout <<
"vr(3)=" << vr(3) << endl;
615 #if defined(PRINTOUT)
616 cout <<
"Normsq=" << vc.
normsq() <<
"Norm=" << vc.
norm() << endl;
705 #if defined(PRINTOUT)
706 cout <<
"Inv=" << inv << endl;
709 #if defined(PRINTOUT)
711 cout <<
"a*m=" << am.apply(
absf) <<
"m*a=" << ma.
apply(
absf) << endl;
718 #if defined(PRINTOUT)
719 cout <<
"m*vt=" << m*vt <<
"v=" << v << endl;
726 #if defined(PRINTOUT)
727 cout <<
"Inv=" << inv << endl;
730 #if defined(PRINTOUT)
736 #if defined(PRINTOUT)
737 cout <<
"Before diag:ss=" << ss << endl;
741 #if defined(PRINTOUT)
742 cout <<
"m=" << m << endl;
744 #if defined(PRINTOUT)
745 cout <<
"ss=" << ss << endl;
746 cout <<
"Sim" << ss.similarity(m) << endl;
748 cout <<
"Diff" << diff.
apply(
absf) << endl;
753 #if defined(PRINTOUT)
757 #if defined(PRINTOUT)
758 cout <<
"Norm 1 =" <<
norm1(m) << endl;
760 #if defined(PRINTOUT)
761 cout <<
"Norm 2 =" <<
norm(m) << endl;
763 #if defined(PRINTOUT)
768 #if defined(PRINTOUT)
769 cout <<
"m=" << m << endl;
772 #if defined(PRINTOUT)
773 cout <<
"a=" << a <<
"m=" << m << endl;
775 #if defined(PRINTOUT)
776 cout <<
"a*m=" << a*m << endl;
782 #if defined(PRINTOUT)
783 cout <<
"v=" << v <<
" m*vt=" << m*vt << endl;
789 #if defined(PRINTOUT)
790 cout <<
"v=" << a <<
" m*b=" << m*b << endl;
792 #if defined(PRINTOUT)
793 cout <<
"Test was successful" << endl;
814 double psq = p[i].
normsq();
815 sp(1,1) += psq - p[i](1)*p[i](1);
816 sp(2,2) += psq - p[i](2)*p[i](2);
817 sp(3,3) += psq - p[i](3)*p[i](3);
818 sp(2,1) -= p[i](2)*p[i](1);
819 sp(3,1) -= p[i](3)*p[i](1);
820 sp(3,2) -= p[i](3)*p[i](2);
823 cout <<
"sp=" << sp <<
" spd=" << spd << endl;
826 cout <<
"condition = " <<
condition(spps) << endl;
829 cout <<
"spps=" << spps <<
"sppss - sim = " << sppssdiff.
apply(
absf)