test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfMatrixTools.h
Go to the documentation of this file.
1 #ifndef GsfMatrixTools_h_
2 #define GsfMatrixTools_h_
3 
4 #define SMATRIX_USE_CONSTEXPR
5 
6 #include "Math/SVector.h"
7 #include "Math/SMatrix.h"
8 
9 namespace GsfMatrixTools {
10 
11 // template <unsigned int N>
12 // double similarity (ROOT::Math::SMatrix<double, N, N, ROOT::Math::MatRepSym<double, N> >,
13 // ROOT::Math::SVector<double, N> vector) {
14 // return vector*matrix*vector;
15 // }
16 
17  template <unsigned int N>
18  double trace (const ROOT::Math::SMatrix<double, N, N>& matrix) {
19  double result(0.);
20  for ( unsigned int i=0; i<N; i++ ) result += matrix(i,i);
21  return result;
22  }
23 
24 
25  /* compute the trace of a product of two sym matrices
26  * a(i,j)*b(j,i) = a(i,j)*b(i,j) sum over i and j
27  */
28  template<typename T, unsigned int N>
29  double trace(ROOT::Math::SMatrix<T,N,N,ROOT::Math::MatRepSym<T,N> > const & a,
30  ROOT::Math::SMatrix<T,N,N,ROOT::Math::MatRepSym<T,N> > const & b) {
31  typedef typename ROOT::Math::SMatrix<T,N,N,ROOT::Math::MatRepSym<T,N> >::const_iterator CI;
32  CI i1 = a.begin();
33  CI e1 = a.end();
34  CI i2 = b.begin();
35  // CI e2 = b.end();
36 
37  T res =0;
38  // sum of the lower triangle;
39  for (;i1!=e1; i1++, i2++)
40  res += (*i1)*(*i2);
41  res *=2.;
42  // remove the duplicated diagonal...
43  for (unsigned int i=0;i<N;i++)
44  res -= a(i,i)*b(i,i);
45  return res;
46  }
47 
48 }
49 #endif
50 
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
double trace(const ROOT::Math::SMatrix< double, N, N > &matrix)
#define N
Definition: blowfish.cc:9
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
long double T