]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliVectorSparse.h
Coverity 15850
[u/mrichter/AliRoot.git] / STEER / AliVectorSparse.h
CommitLineData
de34b538 1#ifndef ALIVECTORSPARSE_H
2#define ALIVECTORSPARSE_H
3
4#include <TObject.h>
5#include <TMath.h>
6
7/**********************************************************************************************/
8/* Sparse vector class, used as row of the AliMatrixSparse class */
9/* */
10/* Author: ruben.shahoyan@cern.ch */
11/* */
12/**********************************************************************************************/
13
14///////////////////////////////////////////////////////////////////////////////////////
15class AliVectorSparse : public TObject {
16 public:
17 AliVectorSparse();
18 AliVectorSparse(const AliVectorSparse& src);
19 virtual ~AliVectorSparse() {Clear();}
20 virtual void Print(Option_t* option="") const;
21 //
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);
32 //
33 AliVectorSparse& operator=(const AliVectorSparse& src);
34 //
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);
40 //
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];}
44 //
45 protected:
46 Int_t fNElems; //
47 UShort_t* fIndex; // Index of stored elems
48 Double_t* fElems; // pointer on elements
49 //
50 ClassDef(AliVectorSparse,0)
51};
52
53
54//___________________________________________________
55inline Double_t AliVectorSparse::operator()(Int_t ind) const
56{
57 return FindIndex(ind);
58}
59
60//___________________________________________________
61inline Double_t& AliVectorSparse::operator()(Int_t ind)
62{
63 return FindIndexAdd(ind);
64}
65
66//////////////////////////////////////////////////////////////////////////////////////
67
68#endif