1 #ifndef DataFormat_Math_invertPosDefMatrix_H
2 #define DataFormat_Math_invertPosDefMatrix_H
4 #include "Math/SMatrix.h"
5 #include "Math/CholeskyDecomp.h"
8 template<
typename T,
unsigned int N>
20 template<
typename T,
unsigned int N>
22 ROOT::Math::SMatrix<
T,
N,
N,ROOT::Math::MatRepSym<T,N> > & mOut) {
36 #include <pmmintrin.h>
41 struct M {
double m00,m01,m11,m10;};
50 inline M2(
double i00,
double i01,
double i10,
double i11) {
51 mm.m00=i00; mm.m01=i01; mm.m11=i11; mm.m10=i10; }
53 double & operator[](
int i) {
return m[
i];}
54 __m128d & r0() {
return r[0]; }
55 __m128d &
r1() {
return r[1]; }
57 double operator[](
int i)
const {
return m[
i];}
58 __m128d
const & r0()
const {
return r[0]; }
59 __m128d
const &
r1()
const {
return r[1]; }
63 inline bool invert() {
66 __m128d det = _mm_mul_pd(r0(),tmp);
67 __m128d det2 = _mm_shuffle_pd(det,det,1);
69 det = _mm_sub_pd(det,det2);
71 r1() = _mm_div_pd(r0(),det);
73 r0() = _mm_div_pd(tmp,det);
74 double d; _mm_store_sd(&d,det);
82 inline bool invertPosDefMatrix<double,2>(ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > &
m) {
83 mathSSE::M2 mm(
m.Array()[0],
m.Array()[1],
m.Array()[1],
m.Array()[2]);
85 bool ok = mm.invert();
95 inline bool invertPosDefMatrix<double,2>(ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> >
const & mIn,
96 ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > & mOut) {
98 mathSSE::M2 mm(mIn.Array()[0], mIn.Array()[1], mIn.Array()[1], mIn.Array()[2]);
100 bool ok = mm.invert();
101 mOut.Array()[0] = mm[0];
102 mOut.Array()[1] = mm[1];
103 mOut.Array()[2] = mm[2];
bool Invert(M &m) const
place the inverse into m
class to compute the Cholesky decomposition of a matrix
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
struct mathSSE::Rot3 __attribute__
std::vector< std::vector< double > > tmp