Project
Loading...
Searching...
No Matches
VectorSparse.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_FWDALIGN_VECTORSPARSE_H
17#define ALICEO2_FWDALIGN_VECTORSPARSE_H
18
19#include <TObject.h>
20#include <TMath.h>
21
22namespace o2
23{
24namespace fwdalign
25{
26
28class VectorSparse : public TObject
29{
30 public:
32
35
36 ~VectorSparse() override { Clear(); }
37
39 void Print(Option_t* option = "") const override;
40
41 Int_t GetNElems() const { return fNElems; }
42 UShort_t* GetIndices() const { return fIndex; }
43 Double_t* GetElems() const { return fElems; }
44 UShort_t& GetIndex(Int_t i) { return fIndex[i]; }
45 Double_t& GetElem(Int_t i) const { return fElems[i]; }
46
48 void Clear(Option_t* option = "") override;
49
50 void Reset() { memset(fElems, 0, fNElems * sizeof(Double_t)); }
51
53 void ReSize(Int_t sz, Bool_t copy = kFALSE);
54
56 void SortIndices(Bool_t valuesToo = kFALSE);
57
59 void Add(Double_t* valc, Int_t* indc, Int_t n);
60
63
64 virtual Double_t operator()(Int_t ind) const;
65 virtual Double_t& operator()(Int_t ind);
66
68 virtual void SetToZero(Int_t ind);
69
71 Double_t FindIndex(Int_t ind) const;
72
74 Double_t& FindIndexAdd(Int_t ind);
75
76 Int_t GetLastIndex() const { return fIndex[fNElems - 1]; }
77 Double_t GetLastElem() const { return fElems[fNElems - 1]; }
78 Double_t& GetLastElem() { return fElems[fNElems - 1]; }
79
80 protected:
81 Int_t fNElems;
82 UShort_t* fIndex;
83 Double_t* fElems;
84
86};
87
88//___________________________________________________
89inline Double_t VectorSparse::operator()(Int_t ind) const
90{
91 return FindIndex(ind);
92}
93
94//___________________________________________________
95inline Double_t& VectorSparse::operator()(Int_t ind)
96{
97 return FindIndexAdd(ind);
98}
99
100} // namespace fwdalign
101} // namespace o2
102
103#endif
int32_t i
void Clear(Option_t *option="") override
clear all
void Print(Option_t *option="") const override
print itself
Double_t * GetElems() const
UShort_t * GetIndices() const
Double_t FindIndex(Int_t ind) const
return an element with given index
virtual Double_t operator()(Int_t ind) const
ClassDefOverride(VectorSparse, 0)
Double_t & FindIndexAdd(Int_t ind)
increment an element with given index
Double_t GetLastElem() const
Int_t fNElems
Number of elements.
Double_t & GetElem(Int_t i) const
UShort_t & GetIndex(Int_t i)
void ReSize(Int_t sz, Bool_t copy=kFALSE)
change the size
Double_t * fElems
pointer on elements
UShort_t * fIndex
Index of stored elems.
virtual void SetToZero(Int_t ind)
set element to 0 if it was already defined
VectorSparse & operator=(const VectorSparse &src)
assignment op-tor
void SortIndices(Bool_t valuesToo=kFALSE)
sort indices in increasing order. Used to fix the row after ILUk decomposition
void Add(Double_t *valc, Int_t *indc, Int_t n)
add indiced array to row. Indices must be in increasing order
GLdouble n
Definition glcorearb.h:1982
GLenum src
Definition glcorearb.h:1767
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...