CMS 3D CMS Logo

Migration.h

Go to the documentation of this file.
00001 #ifndef _CLEHP_2_SMATRIX_MIGRATION_H_
00002 #define _CLEHP_2_SMATRIX_MIGRATION_H_
00003 
00004 #include <Math/SVector.h>
00005 #include <Math/SMatrix.h>
00006 
00007 // Use ".!" in VIM
00008 // for I in $(seq 1 6); do echo "typedef ROOT::Math::SVector<double,$I> AlgebraicVector$I;"; done
00009 typedef ROOT::Math::SVector<double,1> AlgebraicVector1;
00010 typedef ROOT::Math::SVector<double,2> AlgebraicVector2;
00011 typedef ROOT::Math::SVector<double,3> AlgebraicVector3;
00012 typedef ROOT::Math::SVector<double,4> AlgebraicVector4;
00013 typedef ROOT::Math::SVector<double,5> AlgebraicVector5;
00014 typedef ROOT::Math::SVector<double,6> AlgebraicVector6;
00015 
00016 // for I in $(seq 1 6); do echo "typedef ROOT::Math::SMatrix<double,$I,$I,ROOT::Math::MatRepSym<double,$I> > AlgebraicSymMatrix$I$I;"; done
00017 typedef ROOT::Math::SMatrix<double,1,1,ROOT::Math::MatRepSym<double,1> > AlgebraicSymMatrix11;
00018 typedef ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > AlgebraicSymMatrix22;
00019 typedef ROOT::Math::SMatrix<double,3,3,ROOT::Math::MatRepSym<double,3> > AlgebraicSymMatrix33;
00020 typedef ROOT::Math::SMatrix<double,4,4,ROOT::Math::MatRepSym<double,4> > AlgebraicSymMatrix44;
00021 typedef ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepSym<double,5> > AlgebraicSymMatrix55;
00022 typedef ROOT::Math::SMatrix<double,6,6,ROOT::Math::MatRepSym<double,6> > AlgebraicSymMatrix66;
00023 
00024 // for I in $(seq 1 6); do for J in $(seq 1 6); do echo "typedef ROOT::Math::SMatrix<double,$I,$J,ROOT::Math::MatRepStd<double,$I,$J> > AlgebraicMatrix$I$J;"; done; done
00025 typedef ROOT::Math::SMatrix<double,1,1,ROOT::Math::MatRepStd<double,1,1> > AlgebraicMatrix11;
00026 typedef ROOT::Math::SMatrix<double,1,2,ROOT::Math::MatRepStd<double,1,2> > AlgebraicMatrix12;
00027 typedef ROOT::Math::SMatrix<double,1,3,ROOT::Math::MatRepStd<double,1,3> > AlgebraicMatrix13;
00028 typedef ROOT::Math::SMatrix<double,1,4,ROOT::Math::MatRepStd<double,1,4> > AlgebraicMatrix14;
00029 typedef ROOT::Math::SMatrix<double,1,5,ROOT::Math::MatRepStd<double,1,5> > AlgebraicMatrix15;
00030 typedef ROOT::Math::SMatrix<double,1,6,ROOT::Math::MatRepStd<double,1,6> > AlgebraicMatrix16;
00031 typedef ROOT::Math::SMatrix<double,2,1,ROOT::Math::MatRepStd<double,2,1> > AlgebraicMatrix21;
00032 typedef ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepStd<double,2,2> > AlgebraicMatrix22;
00033 typedef ROOT::Math::SMatrix<double,2,3,ROOT::Math::MatRepStd<double,2,3> > AlgebraicMatrix23;
00034 typedef ROOT::Math::SMatrix<double,2,4,ROOT::Math::MatRepStd<double,2,4> > AlgebraicMatrix24;
00035 typedef ROOT::Math::SMatrix<double,2,5,ROOT::Math::MatRepStd<double,2,5> > AlgebraicMatrix25;
00036 typedef ROOT::Math::SMatrix<double,2,6,ROOT::Math::MatRepStd<double,2,6> > AlgebraicMatrix26;
00037 typedef ROOT::Math::SMatrix<double,3,1,ROOT::Math::MatRepStd<double,3,1> > AlgebraicMatrix31;
00038 typedef ROOT::Math::SMatrix<double,3,2,ROOT::Math::MatRepStd<double,3,2> > AlgebraicMatrix32;
00039 typedef ROOT::Math::SMatrix<double,3,3,ROOT::Math::MatRepStd<double,3,3> > AlgebraicMatrix33;
00040 typedef ROOT::Math::SMatrix<double,3,4,ROOT::Math::MatRepStd<double,3,4> > AlgebraicMatrix34;
00041 typedef ROOT::Math::SMatrix<double,3,5,ROOT::Math::MatRepStd<double,3,5> > AlgebraicMatrix35;
00042 typedef ROOT::Math::SMatrix<double,3,6,ROOT::Math::MatRepStd<double,3,6> > AlgebraicMatrix36;
00043 typedef ROOT::Math::SMatrix<double,4,1,ROOT::Math::MatRepStd<double,4,1> > AlgebraicMatrix41;
00044 typedef ROOT::Math::SMatrix<double,4,2,ROOT::Math::MatRepStd<double,4,2> > AlgebraicMatrix42;
00045 typedef ROOT::Math::SMatrix<double,4,3,ROOT::Math::MatRepStd<double,4,3> > AlgebraicMatrix43;
00046 typedef ROOT::Math::SMatrix<double,4,4,ROOT::Math::MatRepStd<double,4,4> > AlgebraicMatrix44;
00047 typedef ROOT::Math::SMatrix<double,4,5,ROOT::Math::MatRepStd<double,4,5> > AlgebraicMatrix45;
00048 typedef ROOT::Math::SMatrix<double,4,6,ROOT::Math::MatRepStd<double,4,6> > AlgebraicMatrix46;
00049 typedef ROOT::Math::SMatrix<double,5,1,ROOT::Math::MatRepStd<double,5,1> > AlgebraicMatrix51;
00050 typedef ROOT::Math::SMatrix<double,5,2,ROOT::Math::MatRepStd<double,5,2> > AlgebraicMatrix52;
00051 typedef ROOT::Math::SMatrix<double,5,3,ROOT::Math::MatRepStd<double,5,3> > AlgebraicMatrix53;
00052 typedef ROOT::Math::SMatrix<double,5,4,ROOT::Math::MatRepStd<double,5,4> > AlgebraicMatrix54;
00053 typedef ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepStd<double,5,5> > AlgebraicMatrix55;
00054 typedef ROOT::Math::SMatrix<double,5,6,ROOT::Math::MatRepStd<double,5,6> > AlgebraicMatrix56;
00055 typedef ROOT::Math::SMatrix<double,6,1,ROOT::Math::MatRepStd<double,6,1> > AlgebraicMatrix61;
00056 typedef ROOT::Math::SMatrix<double,6,2,ROOT::Math::MatRepStd<double,6,2> > AlgebraicMatrix62;
00057 typedef ROOT::Math::SMatrix<double,6,3,ROOT::Math::MatRepStd<double,6,3> > AlgebraicMatrix63;
00058 typedef ROOT::Math::SMatrix<double,6,4,ROOT::Math::MatRepStd<double,6,4> > AlgebraicMatrix64;
00059 typedef ROOT::Math::SMatrix<double,6,5,ROOT::Math::MatRepStd<double,6,5> > AlgebraicMatrix65;
00060 typedef ROOT::Math::SMatrix<double,6,6,ROOT::Math::MatRepStd<double,6,6> > AlgebraicMatrix66;
00061 
00062 
00064 template <unsigned int D1, unsigned int D2=D1> struct AlgebraicROOTObject {
00065     typedef typename ROOT::Math::SVector<double,D1> Vector;
00066     typedef typename ROOT::Math::SMatrix<double,D1,D1,ROOT::Math::MatRepSym<double,D1> > SymMatrix;
00067     typedef typename ROOT::Math::SMatrix<double,D1,D2,ROOT::Math::MatRepStd<double,D1,D2> > Matrix;
00068 };
00069 
00070 typedef ROOT::Math::SMatrixIdentity AlgebraicMatrixID;
00071 
00072 
00073 /*
00074 template <unsigned int N1, unsigned int N2> 
00075     ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > clhep2smatrix(const HepMatrix &mt) {
00076         typedef ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > RM;
00077         RM rm;
00078         memcpy(rm.Array(), &matmt(1,1), (N1*N2)*sizeof(double));
00079         return rm;
00080     }
00081 template <unsigned int N1> 
00082     ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > clhep2smatrix(const HepSymMatrix &mt) {
00083         typedef ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > RM;
00084         RM rm;
00085         memcpy(rm.Array(), &matmt(1,1), (D1*D2)*sizeof(double));
00086         return rm;
00087     }
00088 */
00089 
00090 template<unsigned int N1, unsigned int N2> 
00091     ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > asSMatrix(const HepMatrix &m) {
00092         typedef typename ROOT::Math::MatRepStd<double,N1,N2>  REP;
00093         assert(m.num_row() == N1); assert(m.num_col() == N2);
00094         return  ROOT::Math::SMatrix<double,N1,N2,REP> (&m(1,1), REP::kSize);
00095     }
00096 
00097 template<unsigned int N1> 
00098     ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > asSMatrix(const HepSymMatrix &m) {
00099         typedef typename ROOT::Math::MatRepSym<double,N1>  REP;
00100         assert(m.num_row() == N1);
00101         return  ROOT::Math::SMatrix<double,N1,N1,REP> (&m(1,1), REP::kSize);
00102     }
00103 
00104 template<unsigned int N1> 
00105     ROOT::Math::SVector<double,N1> asSVector(const HepVector &m) {
00106         return  ROOT::Math::SVector<double,N1> (&m[0], N1);
00107     }
00108 
00109 template<unsigned int N> HepVector asHepVector(const ROOT::Math::SVector<double,N> &v) {
00110     HepVector hv(N);
00111     memcpy(&hv[0], &v[0], N*sizeof(double));
00112     return hv;
00113     }
00114 
00115 template<unsigned int N1, unsigned int N2> HepMatrix asHepMatrix (
00116      const ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > &rm) {
00117         HepMatrix am(N1,N2);
00118         memcpy(&am(1,1), rm.Array(), N1*N2*sizeof(double));
00119         return am;
00120     }
00121 
00122 template<unsigned int N1> HepSymMatrix asHepMatrix (
00123      const ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > &rm) {
00124         HepSymMatrix am(N1);
00125         memcpy(&am(1,1), rm.Array(), (N1*(N1+1))/2*sizeof(double));
00126         return am;
00127     }
00128 
00129 
00130 #endif

Generated on Tue Jun 9 17:27:30 2009 for CMSSW by  doxygen 1.5.4