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// clang++ <v20 (-Wshadow) complains about shadowing TAttMarker.h global enum EMarkerStyle. Let's silence warning:
62#if defined(__clang__) && __clang_major__ < 20
63#pragma clang diagnostic push
64#pragma clang diagnostic ignored "-Wshadow"
65#endif
67#if defined(__clang__) && __clang_major__ < 20
68#pragma clang diagnostic pop
69#endif
71
72 TMatrixT(): fDataStack(), fElements(nullptr) { }
73 TMatrixT(Int_t nrows,Int_t ncols);
74 TMatrixT(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb);
75 TMatrixT(Int_t nrows,Int_t ncols,const Element *data,Option_t *option="");
76 TMatrixT(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,const Element *data,Option_t *option="");
77 TMatrixT(const TMatrixT <Element> &another);
78 TMatrixT(const TMatrixTSym <Element> &another);
80 template <class Element2> TMatrixT(const TMatrixT<Element2> &another): fElements(nullptr)
81 {
82 R__ASSERT(another.IsValid());
83 Allocate(another.GetNrows(),another.GetNcols(),another.GetRowLwb(),another.GetColLwb());
84 *this = another;
85 }
86
88 TMatrixT(const TMatrixT <Element> &a,EMatrixCreatorsOp2 op,const TMatrixT <Element> &b);
89 TMatrixT(const TMatrixT <Element> &a,EMatrixCreatorsOp2 op,const TMatrixTSym<Element> &b);
90 TMatrixT(const TMatrixTSym <Element> &a,EMatrixCreatorsOp2 op,const TMatrixT <Element> &b);
91 TMatrixT(const TMatrixTSym <Element> &a,EMatrixCreatorsOp2 op,const TMatrixTSym<Element> &b);
92 TMatrixT(const TMatrixTLazy<Element> &lazy_constructor);
93
94 ~TMatrixT() override { TMatrixT::Clear(); }
95
96 // Elementary constructors
97
98 void Plus (const TMatrixT <Element> &a,const TMatrixT <Element> &b);
99 void Plus (const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
100 void Plus (const TMatrixTSym<Element> &a,const TMatrixT <Element> &b) { Plus(b,a); }
101
102 void Minus(const TMatrixT <Element> &a,const TMatrixT <Element> &b);
103 void Minus(const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
104 void Minus(const TMatrixTSym<Element> &a,const TMatrixT <Element> &b) { Minus(b,a); }
105
106 void Mult (const TMatrixT <Element> &a,const TMatrixT <Element> &b);
107 void Mult (const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
108 void Mult (const TMatrixTSym<Element> &a,const TMatrixT <Element> &b);
110
111 void TMult(const TMatrixT <Element> &a,const TMatrixT <Element> &b);
112 void TMult(const TMatrixT <Element> &a,const TMatrixTSym<Element> &b);
113 void TMult(const TMatrixTSym<Element> &a,const TMatrixT <Element> &b) { Mult(a,b); }
115
116 void MultT(const TMatrixT <Element> &a,const TMatrixT <Element> &b);
117 void MultT(const TMatrixT <Element> &a,const TMatrixTSym<Element> &b) { Mult(a,b); }
118 void MultT(const TMatrixTSym<Element> &a,const TMatrixT <Element> &b);
120
121 inline void SetElement(Int_t rown, Int_t coln, Element val);
122
123 const Element *GetMatrixArray () const override;
124 Element *GetMatrixArray () override;
125 const Int_t *GetRowIndexArray() const override { return nullptr; }
126 Int_t *GetRowIndexArray() override { return nullptr; }
127 const Int_t *GetColIndexArray() const override { return nullptr; }
128 Int_t *GetColIndexArray() override { return nullptr; }
129
130 TMatrixTBase<Element> &SetRowIndexArray(Int_t * /*data*/) override { MayNotUse("SetRowIndexArray(Int_t *)"); return *this; }
131 TMatrixTBase<Element> &SetColIndexArray(Int_t * /*data*/) override { MayNotUse("SetColIndexArray(Int_t *)"); return *this; }
132
133 void Clear(Option_t * /*option*/ ="") override
134 {
135 if (this->fIsOwner)
136 Delete_m(this->fNelems, fElements);
137 else
138 fElements = nullptr;
139 this->fNelems = 0;
140 }
141
142 TMatrixT <Element> &Use (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,Element *data);
143 const TMatrixT <Element> &Use (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,const Element *data) const
144 { return (const TMatrixT<Element>&)
145 ((const_cast<TMatrixT<Element> *>(this))->Use(row_lwb,row_upb,col_lwb,col_upb, const_cast<Element *>(data))); }
146 TMatrixT <Element> &Use (Int_t nrows,Int_t ncols,Element *data);
147 const TMatrixT <Element> &Use (Int_t nrows,Int_t ncols,const Element *data) const;
148 TMatrixT <Element> &Use (TMatrixT<Element> &a);
149 const TMatrixT <Element> &Use (const TMatrixT<Element> &a) const;
150
151 TMatrixTBase<Element> &GetSub (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,
152 TMatrixTBase<Element> &target,Option_t *option="S") const override;
153 TMatrixT <Element> GetSub (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,Option_t *option="S") const;
154 TMatrixTBase<Element> &SetSub (Int_t row_lwb,Int_t col_lwb,const TMatrixTBase<Element> &source) override;
155
156 TMatrixTBase<Element> &ResizeTo(Int_t nrows,Int_t ncols,Int_t /*nr_nonzeros*/ =-1) override;
157 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;
159 return ResizeTo(m.GetRowLwb(),m.GetRowUpb(),m.GetColLwb(),m.GetColUpb());
160 }
161
162 Double_t Determinant () const override;
163 void Determinant (Double_t &d1,Double_t &d2) const override;
164
168 inline TMatrixT<Element> &T () { return this->Transpose(*this); }
171 Element Similarity (const TVectorT<Element> &v) const;
172
175
176 // Either access a_ij as a(i,j)
177 inline Element operator()(Int_t rown,Int_t coln) const override;
178 inline Element &operator()(Int_t rown,Int_t coln) override;
179
180 // or as a[i][j]
181 inline const TMatrixTRow_const<Element> operator[](Int_t rown) const { return TMatrixTRow_const<Element>(*this,rown); }
182 inline TMatrixTRow <Element> operator[](Int_t rown) { return TMatrixTRow <Element>(*this,rown); }
183
184 TMatrixT<Element> &operator= (const TMatrixT <Element> &source);
185 TMatrixT<Element> &operator= (const TMatrixTSym <Element> &source);
187 TMatrixT<Element> &operator= (const TMatrixTLazy <Element> &source);
188 template <class Element2> TMatrixT<Element> &operator= (const TMatrixT<Element2> &source)
189 {
190 if (!AreCompatible(*this,source)) {
191 Error("operator=(const TMatrixT2 &)","matrices not compatible");
192 return *this;
193 }
194
195 TObject::operator=(source);
196 const Element2 * const ps = source.GetMatrixArray();
197 Element * const pt = this->GetMatrixArray();
198 for (Int_t i = 0; i < this->fNelems; i++)
199 pt[i] = ps[i];
200 this->fTol = source.GetTol();
201 return *this;
202 }
203
208
209 TMatrixT<Element> &operator+=(const TMatrixT <Element> &source);
211 TMatrixT<Element> &operator-=(const TMatrixT <Element> &source);
213
214 TMatrixT<Element> &operator*=(const TMatrixT <Element> &source);
215 TMatrixT<Element> &operator*=(const TMatrixTSym <Element> &source);
216 TMatrixT<Element> &operator*=(const TMatrixTDiag_const <Element> &diag);
217 TMatrixT<Element> &operator/=(const TMatrixTDiag_const <Element> &diag);
218 TMatrixT<Element> &operator*=(const TMatrixTRow_const <Element> &row);
219 TMatrixT<Element> &operator/=(const TMatrixTRow_const <Element> &row);
222
224
225 ClassDefOverride(TMatrixT,4) // Template of General Matrix class
226};
227
228// When building with -fmodules, it instantiates all pending instantiations,
229// instead of delaying them until the end of the translation unit.
230// We 'got away with' probably because the use and the definition of the
231// explicit specialization do not occur in the same TU.
232//
233// In case we are building with -fmodules, we need to forward declare the
234// specialization in order to compile the dictionary G__Matrix.cxx.
236
237
238template <class Element> inline const Element *TMatrixT<Element>::GetMatrixArray() const { return fElements; }
239template <class Element> inline Element *TMatrixT<Element>::GetMatrixArray() { return fElements; }
240
241template <class Element> inline TMatrixT<Element> &TMatrixT<Element>::Use (Int_t nrows,Int_t ncols,Element *data)
242 { return Use(0,nrows-1,0,ncols-1,data); }
243template <class Element> inline const TMatrixT<Element> &TMatrixT<Element>::Use (Int_t nrows,Int_t ncols,const Element *data) const
244 { return Use(0,nrows-1,0,ncols-1,data); }
245template <class Element> inline TMatrixT<Element> &TMatrixT<Element>::Use (TMatrixT &a)
246 {
247 R__ASSERT(a.IsValid());
248 return Use(a.GetRowLwb(),a.GetRowUpb(),
249 a.GetColLwb(),a.GetColUpb(),a.GetMatrixArray());
250 }
251template <class Element> inline const TMatrixT<Element> &TMatrixT<Element>::Use (const TMatrixT &a) const
252 {
253 R__ASSERT(a.IsValid());
254 return Use(a.GetRowLwb(),a.GetRowUpb(),
255 a.GetColLwb(),a.GetColUpb(),a.GetMatrixArray());
256 }
257
258template <class Element> inline TMatrixT<Element> TMatrixT<Element>::GetSub (Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,
259 Option_t *option) const
260 {
261 TMatrixT tmp;
262 this->GetSub(row_lwb,row_upb,col_lwb,col_upb,tmp,option);
263 return tmp;
264 }
265
266template <class Element> inline Element TMatrixT<Element>::operator()(Int_t rown,Int_t coln) const
267{
268 R__ASSERT(this->IsValid());
269 const Int_t arown = rown-this->fRowLwb;
270 const Int_t acoln = coln-this->fColLwb;
271 if (arown >= this->fNrows || arown < 0) {
272 Error("operator()","Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->fNrows);
274 }
275 if (acoln >= this->fNcols || acoln < 0) {
276 Error("operator()","Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->fNcols);
278
279 }
280 return (fElements[arown*this->fNcols+acoln]);
281}
282
283template <class Element> inline Element &TMatrixT<Element>::operator()(Int_t rown,Int_t coln)
284{
285 R__ASSERT(this->IsValid());
286 const Int_t arown = rown-this->fRowLwb;
287 const Int_t acoln = coln-this->fColLwb;
288 if (arown >= this->fNrows || arown < 0) {
289 Error("operator()","Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->fNrows);
291 }
292 if (acoln >= this->fNcols || acoln < 0) {
293 Error("operator()","Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->fNcols);
295 }
296 return (fElements[arown*this->fNcols+acoln]);
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Efficiently sets element (rown,coln) equal to val
301/// Index bound checks can be deactivated by defining NDEBUG
302
303template <class Element>
304inline void TMatrixT<Element>::SetElement(Int_t rown, Int_t coln, Element val)
305{
306 assert(this->IsValid());
307 rown = rown - this->fRowLwb;
308 coln = coln - this->fColLwb;
309 assert((rown < this->fNrows && rown >= 0) && "SetElement() error: row index outside matrix range");
310 assert((coln < this->fNcols && coln >= 0) && "SetElement() error: column index outside matrix range");
311 fElements[rown * this->fNcols + coln] = val;
312}
313
314inline namespace TMatrixTAutoloadOps {
315
316template <class Element> TMatrixT<Element> operator+ (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
317template <class Element> TMatrixT<Element> operator+ (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
318template <class Element> TMatrixT<Element> operator+ (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
319template <class Element> TMatrixT<Element> operator+ (const TMatrixT <Element> &source , Element val );
320template <class Element> TMatrixT<Element> operator+ ( Element val ,const TMatrixT <Element> &source );
321template <class Element> TMatrixT<Element> operator- (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
322template <class Element> TMatrixT<Element> operator- (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
323template <class Element> TMatrixT<Element> operator- (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
324template <class Element> TMatrixT<Element> operator- (const TMatrixT <Element> &source , Element val );
325template <class Element> TMatrixT<Element> operator- ( Element val ,const TMatrixT <Element> &source );
326template <class Element> TMatrixT<Element> operator* ( Element val ,const TMatrixT <Element> &source );
327template <class Element> TMatrixT<Element> operator* (const TMatrixT <Element> &source , Element val );
328template <class Element> TMatrixT<Element> operator* (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
329template <class Element> TMatrixT<Element> operator* (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
330template <class Element> TMatrixT<Element> operator* (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
331template <class Element> TMatrixT<Element> operator* (const TMatrixTSym<Element> &source1,const TMatrixTSym<Element> &source2);
332// Preventing warnings with -Weffc++ in GCC since overloading the || and && operators was a design choice.
333#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
334#pragma GCC diagnostic push
335#pragma GCC diagnostic ignored "-Weffc++"
336#endif
337template <class Element> TMatrixT<Element> operator&& (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
338template <class Element> TMatrixT<Element> operator&& (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
339template <class Element> TMatrixT<Element> operator&& (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
340template <class Element> TMatrixT<Element> operator|| (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
341template <class Element> TMatrixT<Element> operator|| (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
342template <class Element> TMatrixT<Element> operator|| (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
343#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
344#pragma GCC diagnostic pop
345#endif
346template <class Element> TMatrixT<Element> operator> (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
347template <class Element> TMatrixT<Element> operator> (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
348template <class Element> TMatrixT<Element> operator> (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
349template <class Element> TMatrixT<Element> operator>= (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
350template <class Element> TMatrixT<Element> operator>= (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
351template <class Element> TMatrixT<Element> operator>= (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
352template <class Element> TMatrixT<Element> operator<= (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
353template <class Element> TMatrixT<Element> operator<= (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
354template <class Element> TMatrixT<Element> operator<= (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
355template <class Element> TMatrixT<Element> operator< (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
356template <class Element> TMatrixT<Element> operator< (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
357template <class Element> TMatrixT<Element> operator< (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
358template <class Element> TMatrixT<Element> operator!= (const TMatrixT <Element> &source1,const TMatrixT <Element> &source2);
359template <class Element> TMatrixT<Element> operator!= (const TMatrixT <Element> &source1,const TMatrixTSym<Element> &source2);
360template <class Element> TMatrixT<Element> operator!= (const TMatrixTSym<Element> &source1,const TMatrixT <Element> &source2);
361
362template <class Element> TMatrixT<Element> &Add (TMatrixT<Element> &target, Element scalar,const TMatrixT <Element> &source);
363template <class Element> TMatrixT<Element> &Add (TMatrixT<Element> &target, Element scalar,const TMatrixTSym<Element> &source);
364template <class Element> TMatrixT<Element> &ElementMult(TMatrixT<Element> &target,const TMatrixT <Element> &source);
365template <class Element> TMatrixT<Element> &ElementMult(TMatrixT<Element> &target,const TMatrixTSym<Element> &source);
366template <class Element> TMatrixT<Element> &ElementDiv (TMatrixT<Element> &target,const TMatrixT <Element> &source);
367template <class Element> TMatrixT<Element> &ElementDiv (TMatrixT<Element> &target,const TMatrixTSym<Element> &source);
368
369template <class Element> void AMultB (const Element * const ap,Int_t na,Int_t ncolsa,
370 const Element * const bp,Int_t nb,Int_t ncolsb,Element *cp);
371template <class Element> void AtMultB(const Element * const ap,Int_t ncolsa,
372 const Element * const bp,Int_t nb,Int_t ncolsb,Element *cp);
373template <class Element> void AMultBt(const Element * const ap,Int_t na,Int_t ncolsa,
374 const Element * const bp,Int_t nb,Int_t ncolsb,Element *cp);
375} // inline namespace TMatrixTAutoloadOps
376#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
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
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
TMatrixT< Element > & operator*=(const TMatrixTSym< Element > &source)
Compute target = target * source inplace.
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:119
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:243
void TMult(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Definition TMatrixT.h:113
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:128
const TMatrixTRow_const< Element > operator[](Int_t rown) const
Definition TMatrixT.h:181
void Clear(Option_t *="") override
Definition TMatrixT.h:133
TMatrixT(const TMatrixTSym< Element > &a, EMatrixCreatorsOp2 op, const TMatrixTSym< Element > &b)
Constructor of matrix applying a specific operation to two prototypes.
Definition TMatrixT.cxx:342
void Delete_m(Int_t size, Element *&)
Delete data pointer m, if it was assigned on the heap.
Definition TMatrixT.cxx:405
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:304
TMatrixT< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
const Int_t * GetRowIndexArray() const override
Definition TMatrixT.h:125
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:258
TMatrixT(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb)
Constructor for ([row_lwb..row_upb] x [col_lwb..col_upb]) matrix.
Definition TMatrixT.cxx:48
TMatrixT< Element > & operator/=(const TMatrixTColumn_const< Element > &col)
Divide a matrix by the column of another matrix matrix(i,j) /= another(i,k) for fixed k.
Float_t fDataStack[TMatrixTBase< Float_t >::kSizeMax]
Definition TMatrixT.h:44
TMatrixT(const TMatrixT< Element2 > &another)
Definition TMatrixT.h:80
TMatrixT< Element > & Use(TMatrixT< Element > &a)
Definition TMatrixT.h:245
void Determinant(Double_t &d1, Double_t &d2) const override
Return the matrix determinant as d1,d2 where det = d1*TMathPower(2.0,d2).
Element & operator()(Int_t rown, Int_t coln) override
Definition TMatrixT.h:283
TMatrixT< Element > & T()
Definition TMatrixT.h:168
void Plus(const TMatrixT< Element > &a, const TMatrixTSym< Element > &b)
General matrix summation. Replace this matrix with C such that C = A + B.
Definition TMatrixT.cxx:541
TMatrixT< Element > & operator=(const TMatrixT< Element > &source)
Assignment operator.
const TMatrixT< Element > & Use(const TMatrixT< Element > &a) const
Definition TMatrixT.h:251
void MultT(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Matrix multiplication, with A symmetric and B general.
Definition TMatrixT.cxx:998
TMatrixT< Element > & operator*=(const TMatrixTRow_const< Element > &row)
Multiply a matrix by the row of another matrix matrix(i,j) *= another(k,j) for fixed k.
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,...
TMatrixT< Element > & operator-=(const TMatrixT< Element > &source)
Subtract the source matrix.
const Int_t * GetColIndexArray() const override
Definition TMatrixT.h:127
const Element * GetMatrixArray() const override
Definition TMatrixT.h:238
void MultT(const TMatrixT< Element > &a, const TMatrixTSym< Element > &b)
Definition TMatrixT.h:117
EMatrixCreatorsOp2
Definition TMatrixT.h:60
@ kMultTranspose
Definition TMatrixT.h:60
@ kTransposeMult
Definition TMatrixT.h:60
@ kInvMult
Definition TMatrixT.h:60
void Mult(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Matrix multiplication, with A symmetric and B general.
Definition TMatrixT.cxx:692
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:575
TMatrixT< Element > & operator+=(const TMatrixTSym< Element > &source)
Add the source matrix.
Element Similarity(const TVectorT< Element > &v) const
Calculate scalar v * (*this) * v^T.
TMatrixT(const TMatrixT< Element > &another)
Copy constructor.
Definition TMatrixT.cxx:83
TMatrixT< Element > & operator+=(const TMatrixT< Element > &source)
Add the source matrix.
void TMult(const TMatrixT< Element > &a, const TMatrixTSym< Element > &b)
Replace this matrix with C such that C = A' * B.
Definition TMatrixT.cxx:897
TMatrixT(const TMatrixTSym< Element > &a, EMatrixCreatorsOp2 op, const TMatrixT< Element > &b)
Constructor of matrix applying a specific operation to two prototypes.
Definition TMatrixT.cxx:280
TMatrixT< Element > & Use(Int_t nrows, Int_t ncols, Element *data)
Definition TMatrixT.h:241
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:507
TMatrixTBase< Element > & ResizeTo(const TMatrixT< Element > &m)
Definition TMatrixT.h:158
void Minus(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Definition TMatrixT.h:104
Element operator()(Int_t rown, Int_t coln) const override
Definition TMatrixT.h:266
void Mult(const TMatrixT< Element > &a, const TMatrixTSym< Element > &b)
Matrix multiplication, with A general and B symmetric.
Definition TMatrixT.cxx:744
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:130
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:946
TMatrixT(Int_t nrows, Int_t ncols, const Element *data, Option_t *option="")
option="F": array elements contains the matrix stored column-wise like in Fortran,...
Definition TMatrixT.cxx:62
TMatrixT(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, const Element *data, Option_t *option="")
array elements are copied
Definition TMatrixT.cxx:72
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:114
TMatrixTBase< Element > & SetColIndexArray(Int_t *) override
Definition TMatrixT.h:131
void Minus(const TMatrixT< Element > &a, const TMatrixTSym< Element > &b)
General matrix subtraction. Replace this matrix with C such that C = A - B.
Definition TMatrixT.cxx:609
TMatrixT(const TMatrixTLazy< Element > &lazy_constructor)
Constructor using the TMatrixTLazy class.
Definition TMatrixT.cxx:393
void Mult(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Matrix multiplication, with A symmetric and B symmetric.
Definition TMatrixT.cxx:796
TMatrixT< Element > & operator*=(const TMatrixTDiag_const< Element > &diag)
Multiply a matrix row by the diagonal of another matrix matrix(i,j) *= diag(j), j=0,...
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:419
TMatrixT< Element > & operator-=(const TMatrixTSym< Element > &source)
Subtract the source matrix.
TMatrixT(const TMatrixTSym< Element > &another)
Copy constructor of a symmetric matrix.
Definition TMatrixT.cxx:94
EMatrixCreatorsOp1
Definition TMatrixT.h:59
@ kInverted
Definition TMatrixT.h:59
@ kTransposed
Definition TMatrixT.h:59
~TMatrixT() override
Definition TMatrixT.h:94
TMatrixT< Element > & operator*=(const TMatrixTColumn_const< Element > &col)
Multiply a matrix by the column of another matrix matrix(i,j) *= another(i,k) for fixed k.
TMatrixTBase< Element > & ResizeTo(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t=-1) override
Set size of the matrix to [row_lwb:row_upb] x [col_lwb:col_upb] New dynamic elements are created,...
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:182
Int_t * GetRowIndexArray() override
Definition TMatrixT.h:126
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:463
TMatrixT< Element > & operator/=(const TMatrixTRow_const< Element > &row)
Divide a matrix by the row of another matrix matrix(i,j) /= another(k,j) for fixed k.
TMatrixT()
Definition TMatrixT.h:72
TMatrixT< Element > & Rank1Update(const TVectorT< Element > &v1, const TVectorT< Element > &v2, Element alpha=1.0)
Perform a rank 1 operation on matrix A: A += alpha * v1 * v2^T.
TMatrixT(const TMatrixT< Element > &a, EMatrixCreatorsOp2 op, const TMatrixT< Element > &b)
Constructor of matrix applying a specific operation to two prototypes.
Definition TMatrixT.cxx:164
TMatrixT(const TMatrixT< Element > &a, EMatrixCreatorsOp2 op, const TMatrixTSym< Element > &b)
Constructor of matrix applying a specific operation to two prototypes.
Definition TMatrixT.cxx:226
TMatrixT(EMatrixCreatorsOp1 op, const TMatrixT< Element > &prototype)
Constructor of matrix applying a specific operation to the prototype.
Definition TMatrixT.cxx:118
void Plus(const TMatrixTSym< Element > &a, const TMatrixT< Element > &b)
Definition TMatrixT.h:100
TMatrixT(const TMatrixTSparse< Element > &another)
Copy constructor of a sparse matrix.
Definition TMatrixT.cxx:105
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:847
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...
TMatrixT(Int_t nrows, Int_t ncols)
Constructor for (nrows x ncols) matrix.
Definition TMatrixT.cxx:39
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:643
Float_t * fElements
Definition TMatrixT.h:45
TMatrixT< Element > & operator*=(const TMatrixT< Element > &source)
Compute target = target * source inplace.
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:438
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:143
Element * GetMatrixArray() override
Definition TMatrixT.h:239
TObject & operator=(const TObject &rhs) noexcept
TObject assignment operator.
Definition TObject.h:305
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:1160
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
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