Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMatrixT.h
Go to the documentation of this file.
1// @(#)root/matrix:$Id$
2// Authors: Fons Rademakers, Eddy Offermann Nov 2003
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TMatrixT
13#define ROOT_TMatrixT
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TMatrixT //
18// //
19// Template class of a general matrix in the linear algebra package //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TMatrixTBase.h"
24#include "TMatrixTUtils.h"
25
26#ifdef CBLAS
27#include <vecLib/vBLAS.h>
28//#include <cblas.h>
29#endif
30
31#include "Rtypes.h"
32#include "TError.h"
33
34#include <cassert>
35
36template<class Element> class TMatrixTSym;
37template<class Element> class TMatrixTSparse;
38template<class Element> class TMatrixTLazy;
39
40template<class Element> class TMatrixT : public TMatrixTBase<Element> {
41
42protected:
43
44 Element fDataStack[TMatrixTBase<Element>::kSizeMax]; //! data container
45 Element *fElements; //[fNelems] elements themselves
46
47 Element *New_m (Int_t size);
48 void Delete_m(Int_t size,Element*&);
49 Int_t Memcpy_m(Element *newp,const Element *oldp,Int_t copySize,
50 Int_t newSize,Int_t oldSize);
51 void Allocate(Int_t nrows,Int_t ncols,Int_t row_lwb = 0,Int_t col_lwb = 0,Int_t init = 0,
52 Int_t /*nr_nonzeros*/ = -1);
53
54
55public:
56
57
58 enum {kWorkMax = 100};
61
62 TMatrixT(): fDataStack(), fElements(nullptr) { }
63 TMatrixT(Int_t nrows,Int_t ncols);
64 TMatrixT(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb);
65 TMatrixT(Int_t nrows,Int_t ncols,const Element *data,Option_t *option="");
66 TMatrixT(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,const Element *data,Option_t *option="");
67 TMatrixT(const TMatrixT <Element> &another);
68 TMatrixT(const TMatrixTSym <Element> &another);
69 TMatrixT(const TMatrixTSparse<Element> &another);
70 template <class Element2> TMatrixT(const TMatrixT<Element2> &another): fElements(nullptr)
71 {
72 R__ASSERT(another.IsValid());
73 Allocate(another.GetNrows(),another.GetNcols(),another.GetRowLwb(),another.GetColLwb());
74 *this = another;
75 }
76
78 TMatrixT(const TMatrixT <Element> &a,EMatrixCreatorsOp2 op,const TMatrixT <Element> &b);
79 TMatrixT(const TMatrixT <Element> &a,EMatrixCreatorsOp2 op,const TMatrixTSym<Element> &b);
80 TMatrixT(const TMatrixTSym <Element> &a,EMatrixCreatorsOp2 op,const TMatrixT <Element> &b);
81 TMatrixT(const TMatrixTSym <Element> &a,EMatrixCreatorsOp2 op,const TMatrixTSym<Element> &b);
82 TMatrixT(const TMatrixTLazy<Element> &lazy_constructor);
83
84 ~TMatrixT() override { TMatrixT::Clear(); }
85
86 // Elementary constructors
87
88 void Plus (const TMatrixT <Element> &a,const TMatrixT <Element> &b);
89 void Plus (const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
90 void Plus (const TMatrixTSym<Element> &a,const TMatrixT <Element> &b) { Plus(b,a); }
91
92 void Minus(const TMatrixT <Element> &a,const TMatrixT <Element> &b);
93 void Minus(const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
94 void Minus(const TMatrixTSym<Element> &a,const TMatrixT <Element> &b) { Minus(b,a); }
95
96 void Mult (const TMatrixT <Element> &a,const TMatrixT <Element> &b);
97 void Mult (const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
98 void Mult (const TMatrixTSym<Element> &a,const TMatrixT <Element> &b);
100
101 void TMult(const TMatrixT <Element> &a,const TMatrixT <Element> &b);
102 void TMult(const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
103 void TMult(const TMatrixTSym<Element> &a,const TMatrixT <Element> &b) { Mult(a,b); }
105
106 void MultT(const TMatrixT <Element> &a,const TMatrixT <Element> &b);
107 void MultT(const TMatrixT <Element> &a,const TMatrixTSym<Element> &b) { Mult(a,b); }
108 void MultT(const TMatrixTSym<Element> &a,const TMatrixT <Element> &b);
110
111 inline void SetElement(Int_t rown, Int_t coln, Element val);
112
113 const Element *GetMatrixArray () const override;
114 Element *GetMatrixArray () override;
115 const Int_t *GetRowIndexArray() const override { return nullptr; }
116 Int_t *GetRowIndexArray() override { return nullptr; }
117 const Int_t *GetColIndexArray() const override { return nullptr; }
118 Int_t *GetColIndexArray() override { return nullptr; }
119
120 TMatrixTBase<Element> &SetRowIndexArray(Int_t * /*data*/) override { MayNotUse("SetRowIndexArray(Int_t *)"); return *this; }
121 TMatrixTBase<Element> &SetColIndexArray(Int_t * /*data*/) override { MayNotUse("SetColIndexArray(Int_t *)"); return *this; }
122
123 void Clear(Option_t * /*option*/ ="") override
124 {
125 if (this->fIsOwner)
126 Delete_m(this->fNelems, fElements);
127 else
128 fElements = nullptr;
129 this->fNelems = 0;
130 }
131
132 TMatrixT <Element> &Use (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,Element *data);
133 const TMatrixT <Element> &Use (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,const Element *data) const
134 { return (const TMatrixT<Element>&)
135 ((const_cast<TMatrixT<Element> *>(this))->Use(row_lwb,row_upb,col_lwb,col_upb, const_cast<Element *>(data))); }
136 TMatrixT <Element> &Use (Int_t nrows,Int_t ncols,Element *data);
137 const TMatrixT <Element> &Use (Int_t nrows,Int_t ncols,const Element *data) const;
138 TMatrixT <Element> &Use (TMatrixT<Element> &a);
139 const TMatrixT <Element> &Use (const TMatrixT<Element> &a) const;
140
141 TMatrixTBase<Element> &GetSub (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,
142 TMatrixTBase<Element> &target,Option_t *option="S") const override;
143 TMatrixT <Element> GetSub (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,Option_t *option="S") const;
144 TMatrixTBase<Element> &SetSub (Int_t row_lwb,Int_t col_lwb,const TMatrixTBase<Element> &source) override;
145
146 TMatrixTBase<Element> &ResizeTo(Int_t nrows,Int_t ncols,Int_t /*nr_nonzeros*/ =-1) override;
147 TMatrixTBase<Element> &ResizeTo(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,Int_t /*nr_nonzeros*/ =-1) override;
149 return ResizeTo(m.GetRowLwb(),m.GetRowUpb(),m.GetColLwb(),m.GetColUpb());
150 }
151
152 Double_t Determinant () const override;
153 void Determinant (Double_t &d1,Double_t &d2) const override;
154
155 TMatrixT<Element> &Invert (Double_t *det = nullptr);
156 TMatrixT<Element> &InvertFast (Double_t *det = nullptr);
158 inline TMatrixT<Element> &T () { return this->Transpose(*this); }
159 TMatrixT<Element> &Rank1Update (const TVectorT<Element> &v,Element alpha=1.0);
160 TMatrixT<Element> &Rank1Update (const TVectorT<Element> &v1,const TVectorT<Element> &v2,Element alpha=1.0);
161 Element Similarity (const TVectorT<Element> &v) const;
162
165
166 // Either access a_ij as a(i,j)
167 inline Element operator()(Int_t rown,Int_t coln) const override;
168 inline Element &operator()(Int_t rown,Int_t coln) override;
169
170 // or as a[i][j]
171 inline const TMatrixTRow_const<Element> operator[](Int_t rown) const { return TMatrixTRow_const<Element>(*this,rown); }
172 inline TMatrixTRow <Element> operator[](Int_t rown) { return TMatrixTRow <Element>(*this,rown); }
173
174 TMatrixT<Element> &operator= (const TMatrixT <Element> &source);
175 TMatrixT<Element> &operator= (const TMatrixTSym <Element> &source);
177 TMatrixT<Element> &operator= (const TMatrixTLazy <Element> &source);
178 template <class Element2> TMatrixT<Element> &operator= (const TMatrixT<Element2> &source)
179 {
180 if (!AreCompatible(*this,source)) {
181 Error("operator=(const TMatrixT2 &)","matrices not compatible");
182 return *this;
183 }
184
185 TObject::operator=(source);
186 const Element2 * const ps = source.GetMatrixArray();
187 Element * const pt = this->GetMatrixArray();
188 for (Int_t i = 0; i < this->fNelems; i++)
189 pt[i] = ps[i];
190 this->fTol = source.GetTol();
191 return *this;
192 }
193
194 TMatrixT<Element> &operator= (Element val);
195 TMatrixT<Element> &operator-=(Element val);
196 TMatrixT<Element> &operator+=(Element val);
197 TMatrixT<Element> &operator*=(Element val);
198
199 TMatrixT<Element> &operator+=(const TMatrixT <Element> &source);
201 TMatrixT<Element> &operator-=(const TMatrixT <Element> &source);
203
204 TMatrixT<Element> &operator*=(const TMatrixT <Element> &source);
205 TMatrixT<Element> &operator*=(const TMatrixTSym <Element> &source);
206 TMatrixT<Element> &operator*=(const TMatrixTDiag_const <Element> &diag);
207 TMatrixT<Element> &operator/=(const TMatrixTDiag_const <Element> &diag);
208 TMatrixT<Element> &operator*=(const TMatrixTRow_const <Element> &row);
209 TMatrixT<Element> &operator/=(const TMatrixTRow_const <Element> &row);
212
213 const TMatrixT<Element> EigenVectors(TVectorT<Element> &eigenValues) const;
214
215 ClassDefOverride(TMatrixT,4) // Template of General Matrix class
216};
217
218// When building with -fmodules, it instantiates all pending instantiations,
219// instead of delaying them until the end of the translation unit.
220// We 'got away with' probably because the use and the definition of the
221// explicit specialization do not occur in the same TU.
222//
223// In case we are building with -fmodules, we need to forward declare the
224// specialization in order to compile the dictionary G__Matrix.cxx.
226
227
228template <class Element> inline const Element *TMatrixT<Element>::GetMatrixArray() const { return fElements; }
229template <class Element> inline Element *TMatrixT<Element>::GetMatrixArray() { return fElements; }
230
231template <class Element> inline TMatrixT<Element> &TMatrixT<Element>::Use (Int_t nrows,Int_t ncols,Element *data)
232 { return Use(0,nrows-1,0,ncols-1,data); }
233template <class Element> inline const TMatrixT<Element> &TMatrixT<Element>::Use (Int_t nrows,Int_t ncols,const Element *data) const
234 { return Use(0,nrows-1,0,ncols-1,data); }
235template <class Element> inline TMatrixT<Element> &TMatrixT<Element>::Use (TMatrixT &a)
236 {
237 R__ASSERT(a.IsValid());
238 return Use(a.GetRowLwb(),a.GetRowUpb(),
239 a.GetColLwb(),a.GetColUpb(),a.GetMatrixArray());
240 }
241template <class Element> inline const TMatrixT<Element> &TMatrixT<Element>::Use (const TMatrixT &a) const
242 {
243 R__ASSERT(a.IsValid());
244 return Use(a.GetRowLwb(),a.GetRowUpb(),
245 a.GetColLwb(),a.GetColUpb(),a.GetMatrixArray());
246 }
247
248template <class Element> inline TMatrixT<Element> TMatrixT<Element>::GetSub (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,
249 Option_t *option) const
250 {
251 TMatrixT tmp;
252 this->GetSub(row_lwb,row_upb,col_lwb,col_upb,tmp,option);
253 return tmp;
254 }
255
256template <class Element> inline Element TMatrixT<Element>::operator()(Int_t rown,Int_t coln) const
257{
258 R__ASSERT(this->IsValid());
259 const Int_t arown = rown-this->fRowLwb;
260 const Int_t acoln = coln-this->fColLwb;
261 if (arown >= this->fNrows || arown < 0) {
262 Error("operator()","Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->fNrows);
264 }
265 if (acoln >= this->fNcols || acoln < 0) {
266 Error("operator()","Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->fNcols);
268
269 }
270 return (fElements[arown*this->fNcols+acoln]);
271}
272
273template <class Element> inline Element &TMatrixT<Element>::operator()(Int_t rown,Int_t coln)
274{
275 R__ASSERT(this->IsValid());
276 const Int_t arown = rown-this->fRowLwb;
277 const Int_t acoln = coln-this->fColLwb;
278 if (arown >= this->fNrows || arown < 0) {
279 Error("operator()","Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->fNrows);
281 }
282 if (acoln >= this->fNcols || acoln < 0) {
283 Error("operator()","Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->fNcols);
285 }
286 return (fElements[arown*this->fNcols+acoln]);
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// Efficiently sets element (rown,coln) equal to val
291/// Index bound checks can be deactivated by defining NDEBUG
292
293template <class Element>
294inline void TMatrixT<Element>::SetElement(Int_t rown, Int_t coln, Element val)
295{
296 assert(this->IsValid());
297 rown = rown - this->fRowLwb;
298 coln = coln - this->fColLwb;
299 assert((rown < this->fNrows && rown >= 0) && "SetElement() error: row index outside matrix range");
300 assert((coln < this->fNcols && coln >= 0) && "SetElement() error: column index outside matrix range");
301 fElements[rown * this->fNcols + coln] = val;
302}
303
304inline namespace TMatrixTAutoloadOps {
305
306template <class Element> TMatrixT<Element> operator+ (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
307template <class Element> TMatrixT<Element> operator+ (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
308template <class Element> TMatrixT<Element> operator+ (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
309template <class Element> TMatrixT<Element> operator+ (const TMatrixT <Element> &source , Element val );
310template <class Element> TMatrixT<Element> operator+ ( Element val ,const TMatrixT <Element> &source );
311template <class Element> TMatrixT<Element> operator- (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
312template <class Element> TMatrixT<Element> operator- (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
313template <class Element> TMatrixT<Element> operator- (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
314template <class Element> TMatrixT<Element> operator- (const TMatrixT <Element> &source , Element val );
315template <class Element> TMatrixT<Element> operator- ( Element val ,const TMatrixT <Element> &source );
316template <class Element> TMatrixT<Element> operator* ( Element val ,const TMatrixT <Element> &source );
317template <class Element> TMatrixT<Element> operator* (const TMatrixT <Element> &source , Element val );
318template <class Element> TMatrixT<Element> operator* (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
319template <class Element> TMatrixT<Element> operator* (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
320template <class Element> TMatrixT<Element> operator* (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
321template <class Element> TMatrixT<Element> operator* (const TMatrixTSym<Element> &source1,const TMatrixTSym<Element> &source2);
322// Preventing warnings with -Weffc++ in GCC since overloading the || and && operators was a design choice.
323#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
324#pragma GCC diagnostic push
325#pragma GCC diagnostic ignored "-Weffc++"
326#endif
327template <class Element> TMatrixT<Element> operator&& (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
328template <class Element> TMatrixT<Element> operator&& (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
329template <class Element> TMatrixT<Element> operator&& (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
330template <class Element> TMatrixT<Element> operator|| (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
331template <class Element> TMatrixT<Element> operator|| (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
332template <class Element> TMatrixT<Element> operator|| (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
333#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
334#pragma GCC diagnostic pop
335#endif
336template <class Element> TMatrixT<Element> operator> (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
337template <class Element> TMatrixT<Element> operator> (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
338template <class Element> TMatrixT<Element> operator> (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
339template <class Element> TMatrixT<Element> operator>= (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
340template <class Element> TMatrixT<Element> operator>= (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
341template <class Element> TMatrixT<Element> operator>= (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
342template <class Element> TMatrixT<Element> operator<= (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
343template <class Element> TMatrixT<Element> operator<= (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
344template <class Element> TMatrixT<Element> operator<= (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
345template <class Element> TMatrixT<Element> operator< (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
346template <class Element> TMatrixT<Element> operator< (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
347template <class Element> TMatrixT<Element> operator< (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
348template <class Element> TMatrixT<Element> operator!= (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
349template <class Element> TMatrixT<Element> operator!= (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
350template <class Element> TMatrixT<Element> operator!= (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
351
352template <class Element> TMatrixT<Element> &Add (TMatrixT<Element> &target, Element scalar,const TMatrixT <Element> &source);
353template <class Element> TMatrixT<Element> &Add (TMatrixT<Element> &target, Element scalar,const TMatrixTSym<Element> &source);
354template <class Element> TMatrixT<Element> &ElementMult(TMatrixT<Element> &target,const TMatrixT <Element> &source);
355template <class Element> TMatrixT<Element> &ElementMult(TMatrixT<Element> &target,const TMatrixTSym<Element> &source);
356template <class Element> TMatrixT<Element> &ElementDiv (TMatrixT<Element> &target,const TMatrixT <Element> &source);
357template <class Element> TMatrixT<Element> &ElementDiv (TMatrixT<Element> &target,const TMatrixTSym<Element> &source);
358
359template <class Element> void AMultB (const Element * const ap,Int_t na,Int_t ncolsa,
360 const Element * const bp,Int_t nb,Int_t ncolsb,Element *cp);
361template <class Element> void AtMultB(const Element * const ap,Int_t ncolsa,
362 const Element * const bp,Int_t nb,Int_t ncolsb,Element *cp);
363template <class Element> void AMultBt(const Element * const ap,Int_t na,Int_t ncolsa,
364 const Element * const bp,Int_t nb,Int_t ncolsb,Element *cp);
365} // inline namespace TMatrixTAutoloadOps
366#endif
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TMatrixTBase.
Int_t GetNrows() const
Int_t GetRowLwb() const
Int_t GetColLwb() const
static Element & NaNValue()
Bool_t IsValid() const
Int_t GetNcols() const
Element GetTol() const
Templates of Lazy Matrix classes.
TMatrixTSparse.
TMatrixTSym.
Definition TMatrixTSym.h:36
TMatrixT.
Definition TMatrixT.h:40
TMatrixTBase< Element > & GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixTBase< Element > &target, Option_t *option="S") const override
Get submatrix [row_lwb..row_upb] x [col_lwb..col_upb]; The indexing range of the returned matrix depe...
void MultT(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Definition TMatrixT.h:109
TMatrixT< Element > & Rank1Update(const TVectorT< Element > &v, Element alpha=1.0)
Perform a rank 1 operation on matrix A: A += alpha * v * v^T.
const TMatrixT< Element > & Use(Int_t nrows, Int_t ncols, const Element *data) const
Definition TMatrixT.h:233
void TMult(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Definition TMatrixT.h:103
TMatrixT< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Element *data)
Use the array data to fill the matrix ([row_lwb..row_upb] x [col_lwb..col_upb])
Int_t * GetColIndexArray() override
Definition TMatrixT.h:118
const TMatrixTRow_const< Element > operator[](Int_t rown) const
Definition TMatrixT.h:171
void Clear(Option_t *="") override
Definition TMatrixT.h:123
void Delete_m(Int_t size, Element *&)
Delete data pointer m, if it was assigned on the heap.
Definition TMatrixT.cxx:406
void SetElement(Int_t rown, Int_t coln, Element val)
Efficiently sets element (rown,coln) equal to val Index bound checks can be deactivated by defining N...
Definition TMatrixT.h:294
TMatrixT< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
const Int_t * GetRowIndexArray() const override
Definition TMatrixT.h:115
TMatrixT< Element > GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Option_t *option="S") const
Definition TMatrixT.h:248
Element fDataStack[TMatrixTBase< Element >::kSizeMax]
Definition TMatrixT.h:44
TMatrixT(const TMatrixT< Element2 > &another)
Definition TMatrixT.h:70
TMatrixT< Element > & Use(TMatrixT< Element > &a)
Definition TMatrixT.h:235
Element & operator()(Int_t rown, Int_t coln) override
Definition TMatrixT.h:273
TMatrixT< Element > & T()
Definition TMatrixT.h:158
TMatrixT< Element > & operator=(const TMatrixT< Element > &source)
Assignment operator.
const TMatrixT< Element > & Use(const TMatrixT< Element > &a) const
Definition TMatrixT.h:241
TMatrixT< Element > & NormByRow(const TVectorT< Element > &v, Option_t *option="D")
Multiply/divide matrix rows with a vector: option: "D" : b(i,j) = a(i,j)/v(j) i = 0,...
const Int_t * GetColIndexArray() const override
Definition TMatrixT.h:117
const Element * GetMatrixArray() const override
Definition TMatrixT.h:228
void MultT(const TMatrixT< Element > &a, const TMatrixTSym< Element > &b)
Definition TMatrixT.h:107
EMatrixCreatorsOp2
Definition TMatrixT.h:60
@ kMultTranspose
Definition TMatrixT.h:60
@ kTransposeMult
Definition TMatrixT.h:60
@ kInvMult
Definition TMatrixT.h:60
void Minus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix subtraction. Replace this matrix with C such that C = A - B.
Definition TMatrixT.cxx:576
Element Similarity(const TVectorT< Element > &v) const
Calculate scalar v * (*this) * v^T.
TMatrixT< Element > & Use(Int_t nrows, Int_t ncols, Element *data)
Definition TMatrixT.h:231
void Plus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Replace this matrix with C such that C = A + B.
Definition TMatrixT.cxx:508
TMatrixTBase< Element > & ResizeTo(const TMatrixT< Element > &m)
Definition TMatrixT.h:148
void Minus(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Definition TMatrixT.h:94
Element operator()(Int_t rown, Int_t coln) const override
Definition TMatrixT.h:256
TMatrixT< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
Double_t Determinant() const override
Return the matrix determinant.
TMatrixT< Element > & Transpose(const TMatrixT< Element > &source)
Transpose matrix source.
TMatrixTBase< Element > & SetRowIndexArray(Int_t *) override
Definition TMatrixT.h:120
void MultT(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Replace this matrix with C such that C = A * B^T.
Definition TMatrixT.cxx:947
TMatrixT< Element > & InvertFast(Double_t *det=nullptr)
Invert the matrix and calculate its determinant, however upto (6x6) a fast Cramer inversion is used .
void TMult(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Definition TMatrixT.h:104
@ kWorkMax
Definition TMatrixT.h:58
TMatrixTBase< Element > & SetColIndexArray(Int_t *) override
Definition TMatrixT.h:121
TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source) override
Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part [row_lwb....
Element * New_m(Int_t size)
Return data pointer .
Definition TMatrixT.cxx:420
EMatrixCreatorsOp1
Definition TMatrixT.h:59
@ kInverted
Definition TMatrixT.h:59
@ kTransposed
Definition TMatrixT.h:59
~TMatrixT() override
Definition TMatrixT.h:84
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixT< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
TMatrixTRow< Element > operator[](Int_t rown)
Definition TMatrixT.h:172
Int_t * GetRowIndexArray() override
Definition TMatrixT.h:116
void Allocate(Int_t nrows, Int_t ncols, Int_t row_lwb=0, Int_t col_lwb=0, Int_t init=0, Int_t=-1)
Allocate new matrix.
Definition TMatrixT.cxx:464
TMatrixT()
Definition TMatrixT.h:62
void Plus(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Definition TMatrixT.h:90
TMatrixT< Element > & operator+=(Element val)
Add val to every element of the matrix.
TMatrixT< Element > & NormByColumn(const TVectorT< Element > &v, Option_t *option="D")
Multiply/divide matrix columns by a vector: option: "D" : b(i,j) = a(i,j)/v(i) i = 0,...
void TMult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
Replace this matrix with C such that C = A' * B.
Definition TMatrixT.cxx:848
const TMatrixT< Element > EigenVectors(TVectorT< Element > &eigenValues) const
Return a matrix containing the eigen-vectors ordered by descending values of Re^2+Im^2 of the complex...
static TClass * Class()
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Replace this matrix with C such that C = A * B.
Definition TMatrixT.cxx:644
Element * fElements
data container
Definition TMatrixT.h:45
Int_t Memcpy_m(Element *newp, const Element *oldp, Int_t copySize, Int_t newSize, Int_t oldSize)
Copy copySize doubles from *oldp to *newp .
Definition TMatrixT.cxx:439
TMatrixT< Element > & operator/=(const TMatrixTDiag_const< Element > &diag)
Divide a matrix row by the diagonal of another matrix matrix(i,j) /= diag(j)
const TMatrixT< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, const Element *data) const
Definition TMatrixT.h:133
Element * GetMatrixArray() override
Definition TMatrixT.h:229
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition TObject.h:296
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition TObject.cxx:1058
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005
TVectorT.
Definition TVectorT.h:29
TPaveText * pt
TMatrixT< Element > operator!=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 != source2
void AMultBt(const Element *const ap, Int_t na, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A*B^T.
void AMultB(const Element *const ap, Int_t na, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A*B.
TMatrixT< Element > operator+(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1+source2
void AtMultB(const Element *const ap, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A^T*B.
TMatrixT< Element > operator>=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 >= source2
TMatrixT< Element > & ElementMult(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Multiply target by the source, element-by-element.
TMatrixT< Element > operator||(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical OR.
TMatrixT< Element > operator<(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 < source2
TMatrixT< Element > operator>(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 > source2
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
TMatrixT< Element > & ElementDiv(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Divide target by the source, element-by-element.
TMatrixT< Element > operator-(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1-source2
TMatrixT< Element > operator<=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 <= source2
TMatrixT< Element > operator&&(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical AND.
TMatrixT< Element > operator*(Element val, const TMatrixT< Element > &source)
operation this = val*source
Bool_t AreCompatible(const TMatrixTBase< Element1 > &m1, const TMatrixTBase< Element2 > &m2, Int_t verbose=0)
Check that matrice sm1 and m2 areboth valid and have identical shapes .
TMarker m
Definition textangle.C:8