1 #define ENABLE_TEMPORARIES 18 #ifdef TEST_ALL_MATRIX_SIZES 22 #define NITER 1 // number of iterations 25 #define NLOOP_MIN 1000; 29 #include "CLHEP/Matrix/SymMatrix.h" 30 #include "CLHEP/Matrix/Matrix.h" 31 #include "CLHEP/Matrix/Vector.h" 60 template<
unsigned int NDIM1,
unsigned int NDIM2>
79 std::cout <<
"************************************************\n";
80 std::cout <<
" SMatrix operations test " << first <<
" x " << second << std::endl;
81 std::cout <<
"************************************************\n";
84 double t_veq, t_meq, t_vad, t_mad, t_dot, t_mv, t_gmv, t_mm, t_prd, t_inv, t_vsc, t_msc, t_ama, t_tra = 0;
85 double totTime1, totTime2;
92 for (
int k = 0; k <
npass; k++) {
123 std::cout <<
"pass " << k << std::endl;
125 std::cout <<
" A = " << A << std::endl;
126 std::cout <<
" B = " << B << std::endl;
127 std::cout <<
" C = " << C << std::endl;
128 std::cout <<
" D = " << D << std::endl;
129 std::cout <<
" v = " << v << std::endl;
130 std::cout <<
" p = " << p << std::endl;
139 MnVectorN v1;
testMV(A,v,t_mv,v1);
141 MnVectorN v2;
testGMV(A,v,v1,t_gmv,v2);
143 MnMatrixNN C0;
testMM(A,B,C,t_mm,C0);
148 MnVectorN v3;
testVeq(v,t_veq,v3);
149 MnVectorN v4;
testVad(v2,v3,t_vad,v4);
151 MnMatrixNN C3;
testMeq(C,t_meq,C3);
152 MnMatrixNN C4;
testMad(C2,C3,t_mad,C4);
154 MnMatrixNN C6;
testMT_S(C5,t_tra,C6);
158 std::cout <<
" C6 = " << C5 << std::endl;
159 std::cout <<
" v5 = " << v5 << std::endl;
176 std::cout <<
"Total Time = " << totTime1 <<
" (s) " <<
" cpu " << totTime2 <<
" (s) " << std::endl;
177 std::cerr <<
"SMatrix: r1 = " << r1 <<
" r2 = " << r2 << std::endl;
185 template<
unsigned int NDIM1,
unsigned int NDIM2>
200 std::cout <<
"************************************************\n";
201 std::cout <<
" SMatrixSym operations test " << first <<
" x " << first << std::endl;
202 std::cout <<
"************************************************\n";
205 double t_meq, t_mad, t_mv, t_gmv, t_mm, t_prd, t_inv, t_msc, t_ama = 0;
206 double totTime1, totTime2;
213 for (
int k = 0; k <
npass; k++) {
235 std::cout <<
"pass " << k << std::endl;
237 std::cout <<
" A = " << A << std::endl;
238 std::cout <<
" B = " << B << std::endl;
239 std::cout <<
" C = " << C << std::endl;
240 std::cout <<
" v = " << v << std::endl;
246 MnVectorN v1;
testMV(A,v,t_mv,v1);
247 MnVectorN v2;
testGMV(A,v,v1,t_gmv,v2);
248 MnMatrixNN C0;
testMM(A,B,C,t_mm,C0);
251 MnSymMatrixNN C3;
testMeq(C2,t_meq,C3);
252 MnSymMatrixNN C4;
testMad(A,C3,t_mad,C4);
253 MnSymMatrixNN C5;
testMscale(C4,0.5,t_msc,C5);
259 std::cout <<
"output matrices" << std::endl;
261 std::cout <<
" C1 = " << C1 << std::endl;
262 std::cout <<
" C3 = " << C3 << std::endl;
263 std::cout <<
" C4 = " << C4 << std::endl;
264 std::cout <<
" C5 = " << C5 << std::endl;
278 std::cout <<
"Total Time = " << totTime1 <<
" (s) - cpu " << totTime2 <<
" (s) " << std::endl;
279 std::cerr <<
"SMatrixSym: r1 = " << r1 << std::endl;
289 template<
unsigned int NDIM1,
unsigned int NDIM2>
306 std::cout <<
"************************************************\n";
307 std::cout <<
" TMatrix operations test " << first <<
" x " << second << std::endl;
308 std::cout <<
"************************************************\n";
310 double t_veq, t_meq, t_vad, t_mad, t_dot, t_mv, t_gmv, t_mm, t_prd, t_inv, t_vsc, t_msc, t_ama, t_tra = 0;
311 double totTime1, totTime2;
318 for (
int k = 0; k <
npass; k++) {
343 std::cout <<
"pass " << k << std::endl;
345 A.Print(); B.Print(); C.Print(); D.Print(); v.Print(); p.Print();
392 std::cout <<
"Total Time = " << totTime1 <<
" (s) - cpu " << totTime2 <<
" (s) " << std::endl;
393 std::cerr <<
"TMatrix: r1 = " << r1 <<
" r2 = " << r2 << std::endl;
402 template<
unsigned int NDIM1,
unsigned int NDIM2>
417 std::cout <<
"************************************************\n";
418 std::cout <<
" TMatrixSym operations test " << first <<
" x " << first << std::endl;
419 std::cout <<
"************************************************\n";
422 double t_meq, t_mad, t_mv, t_gmv, t_mm, t_prd, t_inv, t_msc, t_ama = 0;
423 double totTime1, totTime2;
430 for (
int k = 0; k <
npass; k++) {
453 std::cout <<
"pass " << k << std::endl;
455 A.Print(); B.Print(); C.Print(); v.Print();
466 MnSymMatrix C3(
N);
testMeq(C2,t_meq,C3);
473 std::cout <<
"output matrices" << std::endl;
475 C1.Print(); C3.Print(); C4.Print(); C5.Print();
487 std::cout <<
"Total Time = " << totTime1 <<
" (s) - cpu " << totTime2 <<
" (s) " << std::endl;
488 std::cerr <<
"TMatrixSym: r1 = " << r1 << std::endl;
492 #endif // end TEST_SYM 496 template<
unsigned int NDIM1,
unsigned int NDIM2>
497 int test_hepmatrix_op() {
502 typedef HepMatrix MnMatrix;
503 typedef HepVector MnVector;
511 std::cout <<
"************************************************\n";
512 std::cout <<
" HepMatrix operations test " << first <<
" x " << second << std::endl;
513 std::cout <<
"************************************************\n";
515 double t_veq, t_meq, t_vad, t_mad, t_dot, t_mv, t_gmv, t_mm, t_prd, t_inv, t_vsc, t_msc, t_ama, t_tra = 0;
518 double totTime1, totTime2;
524 for (
int k = 0; k <
npass; k++) {
548 std::cout <<
"pass " << k << std::endl;
550 std::cout <<
" A = " << A << std::endl;
551 std::cout <<
" B = " << B << std::endl;
552 std::cout <<
" C = " << C << std::endl;
553 std::cout <<
" D = " << D << std::endl;
554 std::cout <<
" v = " << v << std::endl;
555 std::cout <<
" p = " << p << std::endl;
584 std::cout <<
" C6 = " << C6 << std::endl;
585 std::cout <<
" v5 = " << v5 << std::endl;
598 std::cout <<
"Total Time = " << totTime1 <<
" (s) - cpu " << totTime2 <<
" (s) " << std::endl;
599 std::cerr <<
"HepMatrix: r1 = " << r1 <<
" r2 = " << r2 << std::endl;
606 template<
unsigned int NDIM1,
unsigned int NDIM2>
607 int test_hepmatrix_sym_op() {
612 typedef HepSymMatrix MnSymMatrix;
613 typedef HepMatrix MnMatrix;
614 typedef HepVector MnVector;
621 std::cout <<
"************************************************\n";
622 std::cout <<
" HepMatrixSym operations test " << first <<
" x " << first << std::endl;
623 std::cout <<
"************************************************\n";
626 double t_meq, t_mad, t_mv, t_gmv, t_mm, t_prd, t_inv, t_msc, t_ama = 0;
628 double totTime1, totTime2;
634 for (
int k = 0; k <
npass; k++) {
656 std::cout <<
"pass " << k << std::endl;
663 MnVector v1(
N);
testMV(A,v,t_mv,v1);
664 MnVector v2(
N);
testGMV(A,v,v1,t_gmv,v2);
675 std::cout <<
"output matrices" << std::endl;
687 std::cout <<
"Total Time = " << totTime1 <<
" (s) - cpu " << totTime2 <<
" (s) " << std::endl;
688 std::cerr <<
"HepMatrixSym: r1 = " << r1 << std::endl;
697 #if defined(HAVE_CLHEP) && defined (TEST_SYM) 701 TEST_TYPE=0; test_smatrix_op<N,N>(); \ 702 TEST_TYPE=1; test_tmatrix_op<N,N>(); \ 703 TEST_TYPE=2; test_hepmatrix_op<N,N>(); \ 704 TEST_TYPE=3; test_smatrix_sym_op<N,N>(); \ 705 TEST_TYPE=4; test_tmatrix_sym_op<N,N>(); \ 706 TEST_TYPE=5; test_hepmatrix_sym_op<N,N>(); 707 #elif !defined(HAVE_CLHEP) && defined (TEST_SYM) 711 TEST_TYPE=0; test_smatrix_op<N,N>(); \ 712 TEST_TYPE=1; test_tmatrix_op<N,N>(); \ 713 TEST_TYPE=2; test_smatrix_sym_op<N,N>(); \ 714 TEST_TYPE=3; test_tmatrix_sym_op<N,N>(); 715 #elif defined(HAVE_CLHEP) && !defined (TEST_SYM) 719 TEST_TYPE=0; test_smatrix_op<N,N>(); \ 720 TEST_TYPE=1; test_tmatrix_op<N,N>(); \ 721 TEST_TYPE=2; test_hepmatrix_op<N,N>(); 725 TEST_TYPE=0; test_smatrix_op<N,N>(); \ 726 TEST_TYPE=1; test_tmatrix_op<N,N>(); 734 std::vector< std::map<std::string, TH1D *> > testTimeResults(
NTYPES);
735 std::vector< std::string > typeNames(
NTYPES);
737 void ROOT::Math::test::reportTime(std::string s,
double time) {
741 std::map<std::string, TH1D * >::iterator pos = result.find(s);
743 if ( pos != result.end() ) {
750 h =
new TProfile(name.c_str(), name.c_str(),100,0.5,100.5);
755 if (s.find(
"dot") != std::string::npos ||
756 s.find(
"V=V") != std::string::npos ||
757 s.find(
"V+V") != std::string::npos ) scale = 10;
773 int main(
int argc ,
char *argv[] ) {
776 std::string fname =
"testOperations";
778 std::string platf(argv[1]);
779 fname = fname +
"_" + platf;
781 fname = fname +
".root";
785 TFile *
f =
new TFile(fname.c_str(),
"recreate");
787 typeNames[0] =
"SMatrix";
788 typeNames[1] =
"TMatrix";
789 #if !defined(HAVE_CLHEP) && defined (TEST_SYM) 790 typeNames[2] =
"SMatrix_sym";
791 typeNames[3] =
"TMatrix_sym";
792 #elif defined(HAVE_CLHEP) && defined (TEST_SYM) 793 typeNames[2] =
"HepMatrix";
794 typeNames[3] =
"SMatrix_sym";
795 typeNames[4] =
"TMatrix_sym";
796 typeNames[5] =
"HepMatrix_sym";
797 #elif defined(HAVE_CLHEP) && !defined (TEST_SYM) 798 typeNames[2] =
"HepMatrix";
803 #ifndef TEST_ALL_MATRIX_SIZES void testATBA_C2(const A &a, const B &b, double &time, C &result)
void testVeq(const V &v, double &time, V &result)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void testATBA_T(const A &a, const B &b, double &time, C &result)
int main(int argc, char *argv[])
Random number generator class based on M.
void fillRandomSym(TRandom &r, M &m, unsigned int first, unsigned int start=0, double offset=1)
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void testMM(const A &a, const B &b, const C &c, double &time, C &result)
void testMV_T(const M &mat, const V &v, double &time, V &result)
void testVscale(const V &v1, double a, double &time, V &result)
void testATBA_T2(const A &a, const B &b, double &time, C &result)
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void testMscale(const M &m1, double a, double &time, M &result)
int test_smatrix_sym_op()
double testDot_S(const V &v1, const V &v2, double &time)
void Stop()
Stop the stopwatch.
SMatrix: a generic fixed size D1 x D2 Matrix class.
void testMM_T(const A &a, const B &b, const C &c, double &time, C &result)
void testInv_T(const M &m, double &time, M &result)
void testMeq(const M &m, double &time, M &result)
void testMad(const M &m1, const M &m2, double &time, M &result)
double testInnerProd_C(const M &a, const V &v, double &time)
void testInv_S(const M &m, double &time, M &result)
void testMscale_T(const M &m1, double a, double &time, M &result)
unsigned int r1[N_CITIES]
void testMT_S(const A &a, double &time, C &result)
void testMM_C(const A &a, const B &b, const C &c, double &time, C &result)
double testInnerProd_S(const M &a, const V &v, double &time)
R__EXTERN Int_t gMatrixCheck
tomato 1-D histogram with a double per channel (see TH1 documentation)}
double testDot_T(const V &v1, const V &v2, double &time)
void testMeq_C(const M &m, double &time, M &result)
void testATBA_C(const A &a, const B &b, double &time, C &result)
void testInv_C(const M &a, double &time, M &result)
void testMT_C(const A &a, double &time, C &result)
void fillRandomMat(TRandom &r, M &m, unsigned int first, unsigned int second, unsigned int start=0, double offset=1)
void testGMV_T(const M &mat, const V &v1, const V &v2, double &time, V &result)
void testATBA_S(const A &a, const B &b, double &time, C &result)
void fillRandomVec(TRandom &r, V &v, unsigned int len, unsigned int start=0, double offset=1)
void testGMV(const M &mat, const V &v1, const V &v2, double &time, V &result)
void testVad(const V &v1, const V &v2, double &time, V &result)
void testVscale_T(const V &v1, double a, double &time, V &result)
double testInnerProd_T(const M &a, const V &v, double &time)
void testMad_C(const M &m1, const M &m2, double &time, M &result)
void testMT_T(const A &a, double &time, C &result)
void testMad_T(const M &m1, const M &m2, double &time, M &result)
double testDot_C(const V &v1, const V &v2, double &time)
void testMV(const M &mat, const V &v, double &time, V &result)
void testVad_T(const V &v1, const V &v2, double &time, V &result)
void testMscale_C(const M &m1, double a, double &time, M &result)
void testATBA_S2(const A &a, const B &b, double &time, C &result)
unsigned int r2[N_CITIES]
int test_tmatrix_sym_op()
SVector: a generic fixed size Vector class.