CMS 3D CMS Logo

ProjectMatrix.h
Go to the documentation of this file.
1 #ifndef DataFormat_Math_ProjectMatrix_H
2 #define DataFormat_Math_ProjectMatrix_H
3 
4 #define SMATRIX_USE_CONSTEXPR
5 #include "Math/SMatrix.h"
6 
7 
8 
9 template<typename T, unsigned int N, unsigned int D>
11  typedef ROOT::Math::SMatrix<T,D,D,ROOT::Math::MatRepSym<T,D> > SMatDD;
12  typedef ROOT::Math::SMatrix<T,N,N > SMatNN;
13  typedef ROOT::Math::SMatrix<T,N,D > SMatND;
14  typedef ROOT::Math::SMatrix<T,D,N > SMatDN;
15 
16 
17  // no constructor
18 
19  // H
20  SMatDN matrix() const {
21  SMatDN r;
22  for (unsigned int i=0; i<D; i++)
23  r(i,index[i]) = T(1.);
24  return r;
25  }
26 
27  // constuct given H
28  void fromH(SMatDN const & H) {
29  for (unsigned int i=0; i<D; i++) {
30  index[i]=N;
31  for (unsigned int j=0; j<N; j++)
32  if ( H(i,j)>0 ) { index[i]=j; break;}
33  }
34  }
35 
36  // H*S
37  SMatND project(SMatDD const & s) const {
38  SMatND r;
39  for (unsigned int i=0; i<D; i++)
40  for (unsigned int j=0; j<D; j++)
41  r(index[i],j) = s(i,j);
42  return r;
43  }
44 
45  // K*H
46  SMatNN project(SMatND const & k) const {
47  SMatNN s;
48  for (unsigned int i=0; i<N; i++)
49  for (unsigned int j=0; j<D; j++)
50  s(i,index[j]) = k(i,j);
51  return s;
52  }
53 
54  // S-K*H
55  void projectAndSubtractFrom(SMatNN & __restrict__ s, SMatND const & __restrict__ k) const {
56  for (unsigned int i=0; i<N; i++)
57  for (unsigned int j=0; j<D; j++)
58  s(i,index[j]) -= k(i,j);
59  }
60 
61  // only H(i,index[i])=1.
62  unsigned int index[D];
63 
64 };
65 
66 
67 #endif
SMatNN project(SMatND const &k) const
Definition: ProjectMatrix.h:46
void projectAndSubtractFrom(SMatNN &__restrict__ s, SMatND const &__restrict__ k) const
Definition: ProjectMatrix.h:55
SMatDN matrix() const
Definition: ProjectMatrix.h:20
ROOT::Math::SMatrix< T, N, N > SMatNN
Definition: ProjectMatrix.h:12
int k[5][pyjets_maxn]
#define N
Definition: blowfish.cc:9
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:152
ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > SMatDD
Definition: ProjectMatrix.h:11
SMatND project(SMatDD const &s) const
Definition: ProjectMatrix.h:37
ROOT::Math::SMatrix< T, D, N > SMatDN
Definition: ProjectMatrix.h:14
unsigned int index[D]
Definition: ProjectMatrix.h:62
ROOT::Math::SMatrix< T, N, D > SMatND
Definition: ProjectMatrix.h:13
long double T
void fromH(SMatDN const &H)
Definition: ProjectMatrix.h:28