1 #ifndef ALIVECTORSPARSE_H
2 #define ALIVECTORSPARSE_H
7 /**********************************************************************************************/
8 /* Sparse vector class, used as row of the AliMatrixSparse class */
10 /* Author: ruben.shahoyan@cern.ch */
12 /**********************************************************************************************/
14 ///////////////////////////////////////////////////////////////////////////////////////
15 class AliVectorSparse : public TObject {
18 AliVectorSparse(const AliVectorSparse& src);
19 virtual ~AliVectorSparse() {Clear();}
20 virtual void Print(Option_t* option="") const;
22 Int_t GetNElems() const {return fNElems;}
23 UShort_t *GetIndices() const {return fIndex;}
24 Double_t *GetElems() const {return fElems;}
25 UShort_t& GetIndex(Int_t i) {return fIndex[i];}
26 Double_t& GetElem(Int_t i) const {return fElems[i];}
27 void Clear(Option_t* option="");
28 void Reset() {memset(fElems,0,fNElems*sizeof(Double_t));}
29 void ReSize(Int_t sz,Bool_t copy=kFALSE);
30 void SortIndices(Bool_t valuesToo=kFALSE);
31 void Add(Double_t *valc,Int_t *indc,Int_t n);
33 AliVectorSparse& operator=(const AliVectorSparse& src);
35 virtual Double_t operator()(Int_t ind) const;
36 virtual Double_t& operator()(Int_t ind);
37 virtual void SetToZero(Int_t ind);
38 Double_t FindIndex(Int_t ind) const;
39 Double_t& FindIndexAdd(Int_t ind);
41 Int_t GetLastIndex() const {return fIndex[fNElems-1];}
42 Double_t GetLastElem() const {return fElems[fNElems-1];}
43 Double_t &GetLastElem() {return fElems[fNElems-1];}
46 Int_t fNElems; // Number of elements
47 UShort_t* fIndex; // Index of stored elems
48 Double_t* fElems; // pointer on elements
50 ClassDef(AliVectorSparse,0)
54 //___________________________________________________
55 inline Double_t AliVectorSparse::operator()(Int_t ind) const
57 return FindIndex(ind);
60 //___________________________________________________
61 inline Double_t& AliVectorSparse::operator()(Int_t ind)
63 return FindIndexAdd(ind);
66 //////////////////////////////////////////////////////////////////////////////////////