Project
Loading...
Searching...
No Matches
MatrixSq.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_MATRIXSQ_H
17#define ALICEO2_FWDALIGN_MATRIXSQ_H
18
19#include <TMatrixDBase.h>
20#include <TVectorD.h>
21
22namespace o2
23{
24namespace fwdalign
25{
26
28class MatrixSq : public TMatrixDBase
29{
30
31 public:
32 MatrixSq() : fSymmetric(kFALSE) {}
33 MatrixSq(const MatrixSq& src);
34 ~MatrixSq() override = default;
35
38
39 virtual Int_t GetSize() const { return fNcols; }
40 virtual Float_t GetDensity() const = 0;
41
42 void Clear(Option_t* option = "") override = 0;
43
44 virtual Double_t Query(Int_t rown, Int_t coln) const { return operator()(rown, coln); }
45 Double_t operator()(Int_t rown, Int_t coln) const override = 0;
46 Double_t& operator()(Int_t rown, Int_t coln) override = 0;
47
48 virtual Double_t QueryDiag(Int_t rc) const { return DiagElem(rc); }
49 virtual Double_t DiagElem(Int_t r) const = 0;
50 virtual Double_t& DiagElem(Int_t r) = 0;
51 virtual void AddToRow(Int_t r, Double_t* valc, Int_t* indc, Int_t n) = 0;
52
53 void Print(Option_t* option = "") const override = 0;
54 virtual void Reset() = 0;
55
57 virtual void PrintCOO() const;
58
60 virtual void MultiplyByVec(const Double_t* vecIn, Double_t* vecOut) const;
61
62 virtual void MultiplyByVec(const TVectorD& vecIn, TVectorD& vecOut) const;
63
64 Bool_t IsSymmetric() const override { return fSymmetric; }
65 void SetSymmetric(Bool_t v = kTRUE) { fSymmetric = v; }
66
67 // ---------------------------------- Dummy methods of MatrixBase
68 const Double_t* GetMatrixArray() const override
69 {
70 Error("GetMatrixArray", "Dummy");
71 return nullptr;
72 };
73 Double_t* GetMatrixArray() override
74 {
75 Error("GetMatrixArray", "Dummy");
76 return nullptr;
77 };
78 const Int_t* GetRowIndexArray() const override
79 {
80 Error("GetRowIndexArray", "Dummy");
81 return nullptr;
82 };
83 Int_t* GetRowIndexArray() override
84 {
85 Error("GetRowIndexArray", "Dummy");
86 return nullptr;
87 };
88 const Int_t* GetColIndexArray() const override
89 {
90 Error("GetColIndexArray", "Dummy");
91 return nullptr;
92 };
93 Int_t* GetColIndexArray() override
94 {
95 Error("GetColIndexArray", "Dummy");
96 return nullptr;
97 };
99 {
100 Error("SetRowIndexArray", "Dummy");
101 return *this;
102 }
104 {
105 Error("SetColIndexArray", "Dummy");
106 return *this;
107 }
108 TMatrixDBase& GetSub(Int_t, Int_t, Int_t, Int_t, TMatrixDBase&, Option_t*) const override
109 {
110 Error("GetSub", "Dummy");
111 return *((TMatrixDBase*)this);
112 }
113 TMatrixDBase& SetSub(Int_t, Int_t, const TMatrixDBase&) override
114 {
115 Error("GetSub", "Dummy");
116 return *this;
117 }
118 TMatrixDBase& ResizeTo(Int_t, Int_t, Int_t) override
119 {
120 Error("ResizeTo", "Dummy");
121 return *this;
122 }
123 TMatrixDBase& ResizeTo(Int_t, Int_t, Int_t, Int_t, Int_t) override
124 {
125 Error("ResizeTo", "Dummy");
126 return *this;
127 }
128 virtual void Allocate(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
129 {
130 Error("Allocate", "Dummy");
131 return;
132 }
133
134 static Bool_t IsZero(Double_t x, Double_t thresh = 1e-64) { return x > 0 ? (x < thresh) : (x > -thresh); }
135
136 protected:
137 void Swap(int& r, int& c) const
138 {
139 int t = r;
140 r = c;
141 c = t;
142 }
143
144 protected:
145 Bool_t fSymmetric;
146
148};
149
150//___________________________________________________________
151inline void MatrixSq::MultiplyByVec(const TVectorD& vecIn, TVectorD& vecOut) const
152{
153 MultiplyByVec(vecIn.GetMatrixArray(), vecOut.GetMatrixArray());
154}
155
156} // namespace fwdalign
157} // namespace o2
158
159#endif
uint32_t c
Definition RawData.h:2
void Print(Option_t *option="") const override=0
void Swap(int &r, int &c) const
Definition MatrixSq.h:137
static Bool_t IsZero(Double_t x, Double_t thresh=1e-64)
Definition MatrixSq.h:134
Bool_t IsSymmetric() const override
Definition MatrixSq.h:64
Int_t * GetColIndexArray() override
Definition MatrixSq.h:93
ClassDefOverride(MatrixSq, 1)
TMatrixDBase & SetSub(Int_t, Int_t, const TMatrixDBase &) override
Definition MatrixSq.h:113
virtual Int_t GetSize() const
Definition MatrixSq.h:39
const Int_t * GetRowIndexArray() const override
Definition MatrixSq.h:78
TMatrixDBase & ResizeTo(Int_t, Int_t, Int_t) override
Definition MatrixSq.h:118
Double_t * GetMatrixArray() override
Definition MatrixSq.h:73
TMatrixDBase & GetSub(Int_t, Int_t, Int_t, Int_t, TMatrixDBase &, Option_t *) const override
Definition MatrixSq.h:108
TMatrixDBase & SetColIndexArray(Int_t *) override
Definition MatrixSq.h:103
const Int_t * GetColIndexArray() const override
Definition MatrixSq.h:88
virtual void Allocate(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
Definition MatrixSq.h:128
virtual Double_t Query(Int_t rown, Int_t coln) const
Definition MatrixSq.h:44
virtual void AddToRow(Int_t r, Double_t *valc, Int_t *indc, Int_t n)=0
const Double_t * GetMatrixArray() const override
Definition MatrixSq.h:68
void Clear(Option_t *option="") override=0
Bool_t fSymmetric
is the matrix symmetric? Only lower triangle is filled
Definition MatrixSq.h:145
Double_t & operator()(Int_t rown, Int_t coln) override=0
virtual void PrintCOO() const
print matrix in COO sparse format
Definition MatrixSq.cxx:57
virtual Float_t GetDensity() const =0
virtual Double_t QueryDiag(Int_t rc) const
Definition MatrixSq.h:48
virtual void MultiplyByVec(const Double_t *vecIn, Double_t *vecOut) const
fill vecOut by matrix * vecIn (vector should be of the same size as the matrix)
Definition MatrixSq.cxx:46
virtual void Reset()=0
virtual Double_t & DiagElem(Int_t r)=0
virtual Double_t DiagElem(Int_t r) const =0
MatrixSq & operator=(const MatrixSq &src)
= operator
Definition MatrixSq.cxx:35
~MatrixSq() override=default
void SetSymmetric(Bool_t v=kTRUE)
Definition MatrixSq.h:65
TMatrixDBase & SetRowIndexArray(Int_t *) override
Definition MatrixSq.h:98
TMatrixDBase & ResizeTo(Int_t, Int_t, Int_t, Int_t, Int_t) override
Definition MatrixSq.h:123
Double_t operator()(Int_t rown, Int_t coln) const override=0
Int_t * GetRowIndexArray() override
Definition MatrixSq.h:83
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLboolean r
Definition glcorearb.h:1233
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...