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 template <typename T, unsigned int N, unsigned int D>
8 struct ProjectMatrix {
9  typedef ROOT::Math::SMatrix<T, D, D, ROOT::Math::MatRepSym<T, D> > SMatDD;
10  typedef ROOT::Math::SMatrix<T, N, N> SMatNN;
11  typedef ROOT::Math::SMatrix<T, N, D> SMatND;
12  typedef ROOT::Math::SMatrix<T, D, N> SMatDN;
13 
14  // no constructor
15 
16  // H
17  SMatDN matrix() const {
18  SMatDN r;
19  for (unsigned int i = 0; i < D; i++)
20  r(i, index[i]) = T(1.);
21  return r;
22  }
23 
24  // constuct given H
25  void fromH(SMatDN const& H) {
26  for (unsigned int i = 0; i < D; i++) {
27  index[i] = N;
28  for (unsigned int j = 0; j < N; j++)
29  if (H(i, j) > 0) {
30  index[i] = j;
31  break;
32  }
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 #endif
class-composition.H
H
Definition: class-composition.py:31
mps_fire.i
i
Definition: mps_fire.py:355
ProjectMatrix::matrix
SMatDN matrix() const
Definition: ProjectMatrix.h:17
ProjectMatrix::project
SMatND project(SMatDD const &s) const
Definition: ProjectMatrix.h:37
ProjectMatrix::SMatNN
ROOT::Math::SMatrix< T, N, N > SMatNN
Definition: ProjectMatrix.h:10
alignCSCRings.s
s
Definition: alignCSCRings.py:92
ProjectMatrix::index
unsigned int index[D]
Definition: ProjectMatrix.h:62
ProjectMatrix::project
SMatNN project(SMatND const &k) const
Definition: ProjectMatrix.h:46
ProjectMatrix::fromH
void fromH(SMatDN const &H)
Definition: ProjectMatrix.h:25
N
#define N
Definition: blowfish.cc:9
dqmdumpme.k
k
Definition: dqmdumpme.py:60
ProjectMatrix::SMatDN
ROOT::Math::SMatrix< T, D, N > SMatDN
Definition: ProjectMatrix.h:12
ProjectMatrix::SMatDD
ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > SMatDD
Definition: ProjectMatrix.h:9
ProjectMatrix::projectAndSubtractFrom
void projectAndSubtractFrom(SMatNN &__restrict__ s, SMatND const &__restrict__ k) const
Definition: ProjectMatrix.h:55
alignCSCRings.r
r
Definition: alignCSCRings.py:93
funct::D
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
T
long double T
Definition: Basic3DVectorLD.h:48
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ProjectMatrix
Definition: ProjectMatrix.h:8
ProjectMatrix::SMatND
ROOT::Math::SMatrix< T, N, D > SMatND
Definition: ProjectMatrix.h:11