]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMatrixSparse.h
Partial fix for bug #59809: putting HLT trigger decision in the ESD, not yet in stand...
[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);
27
28 void Clear(Option_t* option="");
29 void Reset() {for (int i=fNcols;i--;) GetRow(i)->Reset();}
30 void Print(Option_t* option="") const;
31 AliMatrixSparse& operator=(const AliMatrixSparse& src);
32 Double_t& operator()(Int_t row,Int_t col);
33 Double_t operator()(Int_t row,Int_t col) const;
f748efd7 34 void SetToZero(Int_t row,Int_t col);
8a9ab0eb 35 Float_t GetDensity() const;
36 //
37 Double_t DiagElem(Int_t r) const;
38 Double_t& DiagElem(Int_t r);
39 void SortIndices(Bool_t valuesToo=kFALSE);
40 //
de34b538 41 void MultiplyByVec(TVectorD &vecIn, TVectorD &vecOut) const;
8a9ab0eb 42 void MultiplyByVec(Double_t* vecIn, Double_t* vecOut) const;
de34b538 43 //
44 void AddToRow(Int_t r, Double_t *valc,Int_t *indc,Int_t n);
8a9ab0eb 45 //
46 protected:
47 //
48 AliVectorSparse** fVecs;
49 //
50 ClassDef(AliMatrixSparse,0)
51};
52
de34b538 53//___________________________________________________
54inline void AliMatrixSparse::MultiplyByVec(TVectorD &vecIn, TVectorD &vecOut) const
55{
56 MultiplyByVec((Double_t*)vecIn.GetMatrixArray(),(Double_t*)vecOut.GetMatrixArray());
57}
58
8a9ab0eb 59//___________________________________________________
f748efd7 60inline void AliMatrixSparse::SetToZero(Int_t row,Int_t col)
8a9ab0eb 61{
62 // set existing element to 0
63 if (IsSymmetric() && col>row) Swap(row,col);
64 AliVectorSparse* rowv = GetRow(row);
f748efd7 65 if (rowv) rowv->SetToZero(col);
8a9ab0eb 66}
67
68//___________________________________________________
69inline Double_t AliMatrixSparse::operator()(Int_t row,Int_t col) const
70{
71 // printf("M: find\n");
72 if (IsSymmetric() && col>row) Swap(row,col);
73 AliVectorSparse* rowv = GetRow(row);
74 if (!rowv) return 0;
75 return rowv->FindIndex(col);
76}
77
78//___________________________________________________
79inline Double_t& AliMatrixSparse::operator()(Int_t row,Int_t col)
80{
81 // printf("M: findindexAdd\n");
82 if (IsSymmetric() && col>row) Swap(row,col);
83 AliVectorSparse* rowv = GetRowAdd(row);
84 return rowv->FindIndexAdd(col);
85}
86
87//___________________________________________________
88inline Double_t AliMatrixSparse::DiagElem(Int_t row) const
89{
90 AliVectorSparse* rowv = GetRow(row);
91 if (!rowv) return 0;
92 if (IsSymmetric()) return (rowv->GetNElems()>0 && rowv->GetLastIndex()==row) ? rowv->GetLastElem() : 0.;
93 else return rowv->FindIndex(row);
94 //
95}
96
97//___________________________________________________
98inline Double_t &AliMatrixSparse::DiagElem(Int_t row)
99{
100 AliVectorSparse* rowv = GetRowAdd(row);
101 if (IsSymmetric()) return (rowv->GetNElems()>0 && rowv->GetLastIndex()==row) ?
102 rowv->GetLastElem() : rowv->FindIndexAdd(row);
103 else return rowv->FindIndexAdd(row);
104 //
105}
106
de34b538 107
8a9ab0eb 108#endif
109