CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/Math/interface/ProjectMatrix.h

Go to the documentation of this file.
00001 #ifndef DataFormat_Math_ProjectMatrix_H
00002 #define DataFormat_Math_ProjectMatrix_H
00003 
00004 #include "Math/SMatrix.h"
00005 
00006 
00007 
00008 template<typename T, unsigned int N, unsigned int D>
00009 struct ProjectMatrix{
00010   typedef  ROOT::Math::SMatrix<T,D,D,ROOT::Math::MatRepSym<T,D> > SMatDD;
00011   typedef  ROOT::Math::SMatrix<T,N,N > SMatNN;
00012   typedef  ROOT::Math::SMatrix<T,N,D > SMatND;
00013   
00014   // no constructor
00015   
00016   // H*S
00017   SMatND project(SMatDD const & s) {
00018     SMatND r;
00019     for (unsigned int i=0; i<D; i++)
00020       for (unsigned int j=0; j<D; j++)
00021         r(index[i],j) = s(i,j);
00022     return r;
00023   }
00024   
00025   // K*H
00026   SMatNN project(SMatND const & k) {
00027     SMatNN s;
00028     for (unsigned int i=0; i<N; i++)
00029       for (unsigned int j=0; j<D; j++)
00030         s(i,index[j]) = k(i,j);
00031     return s;
00032   }
00033 
00034   // S-K*H
00035   void projectAndSubtractFrom(SMatNN & __restrict__ s, SMatND const & __restrict__ k) {
00036     for (unsigned int i=0; i<N; i++)
00037       for (unsigned int j=0; j<D; j++)
00038         s(i,index[j]) -= k(i,j);
00039   }
00040 
00041   // only H(i,index(i))=1.
00042   unsigned int index[D];
00043 
00044 };
00045 
00046 
00047 #endif