]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMatrixSparse.h
Adding the individual channel mult in order to be used in the event plane calculation.
[u/mrichter/AliRoot.git] / STEER / AliMatrixSparse.h
CommitLineData
8a9ab0eb 1#ifndef ALIMATRIXSPARSE_H
2#define ALIMATRIXSPARSE_H
3
4#include "AliMatrixSq.h"
de34b538 5#include "AliVectorSparse.h"
8a9ab0eb 6
7
de34b538 8/**********************************************************************************************/
9/* Sparse matrix class, used as a global matrix for AliMillePede2 */
10/* */
11/* Author: ruben.shahoyan@cern.ch */
12/* */
13/**********************************************************************************************/
8a9ab0eb 14
8a9ab0eb 15
8a9ab0eb 16//
17class AliMatrixSparse : public AliMatrixSq
18{
19 public:
20 AliMatrixSparse() : fVecs(0) {}
21 AliMatrixSparse(Int_t size);
22 AliMatrixSparse(const AliMatrixSparse &mat);
23 virtual ~AliMatrixSparse() {Clear();}
24 //
25 AliVectorSparse* GetRow(Int_t ir) const {return (ir<fNcols) ? fVecs[ir] : 0;}
26 AliVectorSparse* GetRowAdd(Int_t ir);
3bc5dd7d 27 //
28 virtual Int_t GetSize() const {return fNrows;}
29 virtual Int_t GetNRows() const {return fNrows;}
30 virtual Int_t GetNCols() const {return fNcols;}
31 //
8a9ab0eb 32 void Clear(Option_t* option="");
33 void Reset() {for (int i=fNcols;i--;) GetRow(i)->Reset();}
34 void Print(Option_t* option="") const;
35 AliMatrixSparse& operator=(const AliMatrixSparse& src);
36 Double_t& operator()(Int_t row,Int_t col);
37 Double_t operator()(Int_t row,Int_t col) const;
f748efd7 38 void SetToZero(Int_t row,Int_t col);
8a9ab0eb 39 Float_t GetDensity() const;
40 //
41 Double_t DiagElem(Int_t r) const;
42 Double_t& DiagElem(Int_t r);
43 void SortIndices(Bool_t valuesToo=kFALSE);
44 //
551c9e69 45 void MultiplyByVec(const TVectorD &vecIn, TVectorD &vecOut) const;
46 void MultiplyByVec(const Double_t* vecIn, Double_t* vecOut) const;
de34b538 47 //
48 void AddToRow(Int_t r, Double_t *valc,Int_t *indc,Int_t n);
8a9ab0eb 49 //
50 protected:
51 //
52 AliVectorSparse** fVecs;
53 //
54 ClassDef(AliMatrixSparse,0)
55};
56
de34b538 57//___________________________________________________
551c9e69 58inline void AliMatrixSparse::MultiplyByVec(const TVectorD &vecIn, TVectorD &vecOut) const
de34b538 59{
60 MultiplyByVec((Double_t*)vecIn.GetMatrixArray(),(Double_t*)vecOut.GetMatrixArray());
61}
62
8a9ab0eb 63//___________________________________________________
f748efd7 64inline void AliMatrixSparse::SetToZero(Int_t row,Int_t col)
8a9ab0eb 65{
66 // set existing element to 0
67 if (IsSymmetric() && col>row) Swap(row,col);
68 AliVectorSparse* rowv = GetRow(row);
f748efd7 69 if (rowv) rowv->SetToZero(col);
8a9ab0eb 70}
71
72//___________________________________________________
73inline Double_t AliMatrixSparse::operator()(Int_t row,Int_t col) const
74{
75 // printf("M: find\n");
76 if (IsSymmetric() && col>row) Swap(row,col);
77 AliVectorSparse* rowv = GetRow(row);
78 if (!rowv) return 0;
79 return rowv->FindIndex(col);
80}
81
82//___________________________________________________
83inline Double_t& AliMatrixSparse::operator()(Int_t row,Int_t col)
84{
85 // printf("M: findindexAdd\n");
86 if (IsSymmetric() && col>row) Swap(row,col);
87 AliVectorSparse* rowv = GetRowAdd(row);
3bc5dd7d 88 if (col>=fNcols) fNcols = col+1;
8a9ab0eb 89 return rowv->FindIndexAdd(col);
90}
91
92//___________________________________________________
93inline Double_t AliMatrixSparse::DiagElem(Int_t row) const
94{
95 AliVectorSparse* rowv = GetRow(row);
96 if (!rowv) return 0;
97 if (IsSymmetric()) return (rowv->GetNElems()>0 && rowv->GetLastIndex()==row) ? rowv->GetLastElem() : 0.;
98 else return rowv->FindIndex(row);
99 //
100}
101
102//___________________________________________________
103inline Double_t &AliMatrixSparse::DiagElem(Int_t row)
104{
105 AliVectorSparse* rowv = GetRowAdd(row);
3bc5dd7d 106 if (row>=fNcols) fNcols = row+1;
107 if (IsSymmetric()) {
108 return (rowv->GetNElems()>0 && rowv->GetLastIndex()==row) ?
8a9ab0eb 109 rowv->GetLastElem() : rowv->FindIndexAdd(row);
3bc5dd7d 110 }
8a9ab0eb 111 else return rowv->FindIndexAdd(row);
112 //
113}
114
de34b538 115
8a9ab0eb 116#endif
117