test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
invertPosDefMatrix.h
Go to the documentation of this file.
1 #ifndef DataFormat_Math_invertPosDefMatrix_H
2 #define DataFormat_Math_invertPosDefMatrix_H
3 
4 #define SMATRIX_USE_CONSTEXPR
5 #include "Math/SMatrix.h"
6 #include "Math/CholeskyDecomp.h"
7 
8 template<typename T,unsigned int N>
9 inline bool invertPosDefMatrix(ROOT::Math::SMatrix<T,N,N,ROOT::Math::MatRepSym<T,N> > & m) {
10 
11  ROOT::Math::CholeskyDecomp<T,N> decomp(m);
12  if (!decomp) {
13  return m.Invert();
14  } else
15  decomp.Invert(m);
16  return true;
17 
18 }
19 
20 template<>
21 inline bool invertPosDefMatrix<double,1>(ROOT::Math::SMatrix<double,1,1,ROOT::Math::MatRepSym<double,1> > & m) {
22  m(0,0) = 1./m(0,0);
23  return true;
24 }
25 template<>
26 inline bool invertPosDefMatrix<float,1>(ROOT::Math::SMatrix<float,1,1,ROOT::Math::MatRepSym<float,1> > & m) {
27  m(0,0) = 1.f/m(0,0);
28  return true;
29 }
30 
31 template<typename T,unsigned int N>
32 inline bool invertPosDefMatrix(ROOT::Math::SMatrix<T,N,N,ROOT::Math::MatRepSym<T,N> > const & mIn,
33  ROOT::Math::SMatrix<T,N,N,ROOT::Math::MatRepSym<T,N> > & mOut) {
34 
35  ROOT::Math::CholeskyDecomp<T,N> decomp(mIn);
36  if (!decomp) {
37  mOut=mIn;
38  return mOut.Invert();
39  } else
40  decomp.Invert(mOut);
41  return true;
42 
43 }
44 
45 #endif
bool invertPosDefMatrix< double, 1 >(ROOT::Math::SMatrix< double, 1, 1, ROOT::Math::MatRepSym< double, 1 > > &m)
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
#define N
Definition: blowfish.cc:9
bool invertPosDefMatrix< float, 1 >(ROOT::Math::SMatrix< float, 1, 1, ROOT::Math::MatRepSym< float, 1 > > &m)
long double T