AliRoot Core  aab2016 (aab2016)
AliFastContainerAccess.h
Go to the documentation of this file.
1 #ifndef ALIFASTCONTAINERACCESS_H
2 #define ALIFASTCONTAINERACCESS_H
3 
4 #include <TMatrixT.h>
5 #include <cassert>
6 
8 
9 // a fast access to ROOT's TMatrix class
10 // without boundary checks nor R_ASSERT as enforced by ROOT
11 // boundary checks can be enabled by compiling without -DNDEBUG
12 template <typename T>
13 inline
14 T TMatrixFastAt(TMatrixT<T> const &m, int rown, int coln){
15  const Int_t arown = rown - m.GetRowLwb();
16  const Int_t acoln = coln - m.GetColLwb();
17 #ifndef NDEBUG
18 // put boundary checks here
19 #endif
20  T const *entries = m.TMatrixT<T>::GetMatrixArray();
21 
22  // verify correctness w.r.t to original implementation
23  assert(entries[arown*m.GetNcols() + acoln] == m(rown,coln));
24 
25  return entries[arown*m.GetNcols() + acoln];
26 }
27 
28 // fast access to a reference to elements of ROOT's TMatrix class
29 template <typename T>
30 inline
31 T &TMatrixFastAtRef(TMatrixT<T> &m, int rown, int coln){
32  const Int_t arown = rown - m.GetRowLwb();
33  const Int_t acoln = coln - m.GetColLwb();
34 #ifndef NDEBUG
35 // put boundary checks here
36 #endif
37  T *entries = m.TMatrixT<T>::GetMatrixArray();
38 
39  // verify correctness w.r.t to original implementation
40  assert(entries[arown*m.GetNcols() + acoln] == m(rown,coln));
41 
42  return entries[arown*m.GetNcols() + acoln];
43 }
44 
45 
46 
47 }
48 
49 
50 #endif // ALIFASTCONTAINERACCESS_H
T & TMatrixFastAtRef(TMatrixT< T > &m, int rown, int coln)
T TMatrixFastAt(TMatrixT< T > const &m, int rown, int coln)