CMS 3D CMS Logo

MatriplexVector.h
Go to the documentation of this file.
1 #ifndef RecoTracker_MkFitCore_src_Matriplex_MatriplexVector_h
2 #define RecoTracker_MkFitCore_src_Matriplex_MatriplexVector_h
3 
4 #include "Matriplex.h"
5 #include "Memory.h"
6 #include <vector>
7 #include <cassert>
8 
9 namespace Matriplex {
10 
11  //------------------------------------------------------------------------------
12 
13  template <class MP>
15  MP* fV;
16  const idx_t fN;
17 
18  typedef typename MP::value_type T;
19 
20  public:
21  MatriplexVector(idx_t n) : fN(n) { fV = (MP*)aligned_alloc64(sizeof(MP) * fN); }
22 
24 
25  idx_t size() const { return fN; }
26 
27  MP& mplex(int i) { return fV[i]; }
28  MP& operator[](int i) { return fV[i]; }
29 
30  const MP& mplex(int i) const { return fV[i]; }
31  const MP& operator[](int i) const { return fV[i]; }
32 
33  void setVal(T v) {
34  for (idx_t i = 0; i < kTotSize; ++i) {
35  fArray[i] = v;
36  }
37  }
38 
39  T& At(idx_t n, idx_t i, idx_t j) { return fV[n / fN].At(n % fN, i, j); }
40 
41  T& operator()(idx_t n, idx_t i, idx_t j) { return fV[n / fN].At(n % fN, i, j); }
42 
43  void copyIn(idx_t n, T* arr) { fV[n / fN].copyIn(n % fN, arr); }
44  void copyOut(idx_t n, T* arr) { fV[n / fN].copyOut(n % fN, arr); }
45  };
46 
47  template <class MP>
49 
50  //==============================================================================
51 
52  template <typename T, idx_t D1, idx_t D2, idx_t D3, idx_t N>
56  int n_to_process = 0) {
57  assert(A.size() == B.size());
58  assert(A.size() == C.size());
59 
60  const int np = n_to_process ? n_to_process : A.size();
61 
62  for (int i = 0; i < np; ++i) {
63  multiply(A[i], B[i], C[i]);
64  }
65  }
66 
67  template <typename T, idx_t D1, idx_t D2, idx_t D3, idx_t N>
71  int n_to_process = 0) {
72  assert(A.size() == B.size());
73  assert(A.size() == C.size());
74 
75  const int np = n_to_process ? n_to_process : A.size();
76 
77  for (int i = 0; i < np; ++i) {
78  multiplyGeneral(A[i], B[i], C[i]);
79  }
80  }
81 
82  template <typename T, idx_t D1, idx_t D2, idx_t D3, idx_t N>
86  int n_to_process = 0) {
87  assert(A.size() == B.size());
88  assert(A.size() == C.size());
89 
90  const int np = n_to_process ? n_to_process : A.size();
91 
92  for (int i = 0; i < np; ++i) {
93  multiply(A[i], B[i], C[i]);
94  multiply(B[i], C[i], A[i]);
95  multiply(C[i], A[i], B[i]);
96  }
97  }
98 
99  template <typename T, idx_t D, idx_t N>
101  const MPlexVec<MPlexSym<T, D, N>>& B,
103  int n_to_process = 0) {
104  assert(A.size() == B.size());
105  assert(A.size() == C.size());
106 
107  const int np = n_to_process ? n_to_process : A.size();
108 
109  for (int i = 0; i < np; ++i) {
110  multiply(A[i], B[i], C[i]);
111  }
112  }
113 
114  //==============================================================================
115 
116  template <typename T, idx_t D, idx_t N>
117  void invertCramer(MPlexVec<MPlex<T, D, D, N>>& A, int n_to_process = 0) {
118  const int np = n_to_process ? n_to_process : A.size();
119 
120  for (int i = 0; i < np; ++i) {
121  invertCramer(A[i]);
122  }
123  }
124 
125  template <typename T, idx_t D, idx_t N>
126  void invertCholesky(MPlexVec<MPlex<T, D, D, N>>& A, int n_to_process = 0) {
127  const int np = n_to_process ? n_to_process : A.size();
128 
129  for (int i = 0; i < np; ++i) {
130  invertCholesky(A[i]);
131  }
132  }
133 
134  template <typename T, idx_t D, idx_t N>
135  void invertCramerSym(MPlexVec<MPlexSym<T, D, N>>& A, int n_to_process = 0) {
136  const int np = n_to_process ? n_to_process : A.size();
137 
138  for (int i = 0; i < np; ++i) {
139  invertCramerSym(A[i]);
140  }
141  }
142 
143  template <typename T, idx_t D, idx_t N>
144  void invertCholeskySym(MPlexVec<MPlexSym<T, D, N>>& A, int n_to_process = 0) {
145  const int np = n_to_process ? n_to_process : A.size();
146 
147  for (int i = 0; i < np; ++i) {
149  }
150  }
151 
152 } // namespace Matriplex
153 
154 #endif
MatriplexSym< T, D, N > MPlexSym
Definition: MatriplexSym.h:269
Definition: APVGainStruct.h:7
Matriplex< T, D1, D2, N > MPlex
Definition: Matriplex.h:314
void multiply(const MPlex< T, D, D, N > &A, const MPlex< T, D, D, N > &B, MPlex< T, D, D, N > &C)
Definition: Matriplex.h:627
const MP & operator[](int i) const
void invertCholeskySym(MPlexSym< T, D, N > &A)
Definition: MatriplexSym.h:461
assert(be >=bs)
void multiply3in(MPlexVec< MPlex< T, D1, D2, N >> &A, MPlexVec< MPlex< T, D2, D3, N >> &B, MPlexVec< MPlex< T, D1, D3, N >> &C, int n_to_process=0)
void invertCramerSym(MPlexSym< T, D, N > &A, double *determ=nullptr)
Definition: MatriplexSym.h:410
void free(void *ptr) noexcept
int np
Definition: AMPTWrapper.h:43
void multiplyGeneral(const MPlex< T, D1, D2, N > &A, const MPlex< T, D2, D3, N > &B, MPlex< T, D1, D3, N > &C)
Definition: Matriplex.h:482
void invertCramer(MPlex< T, D, D, N > &A, double *determ=nullptr)
Definition: Matriplex.h:711
void copyIn(idx_t n, T *arr)
T & operator()(idx_t n, idx_t i, idx_t j)
void * aligned_alloc64(std::size_t size)
Definition: Memory.h:13
void invertCholesky(MPlex< T, D, D, N > &A)
Definition: Matriplex.h:765
Definition: APVGainStruct.h:7
const MP & mplex(int i) const
T & At(idx_t n, idx_t i, idx_t j)
void copyOut(idx_t n, T *arr)