12 #ifndef ROOT_TMatrixTUtils 13 #define ROOT_TMatrixTUtils 38 #include <initializer_list> 40 template<
class Element>
class TVectorT;
41 template<
class Element>
class TMatrixT;
68 virtual void Operation(Element &element)
const = 0;
100 virtual void Operation(Element &element)
const = 0;
127 fMatrix(trc.fMatrix), fRowInd(trc.fRowInd), fInc(trc.fInc), fPtr(trc.fPtr) { }
129 if(
this != &trc) { fMatrix=trc.
fMatrix; fRowInd=trc.
fRowInd; fInc=trc.
fInc; fPtr=trc.
fPtr; }
return *
this;}
134 inline Int_t
GetInc ()
const {
return fInc; }
135 inline const Element *
GetPtr ()
const {
return fPtr; }
136 inline const Element &operator ()(Int_t i)
const {
139 const Int_t acoln = i-fMatrix->
GetColLwb();
140 if (acoln < fMatrix->GetNcols() && acoln >= 0)
143 Error(
"operator()",
"Request col(%d) outside matrix range of %d - %d",
161 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
165 R__ASSERT(this->fMatrix->IsValid());
166 const Int_t acoln = i-this->fMatrix->GetColLwb();
167 if (acoln < this->fMatrix->GetNcols() || acoln >= 0)
168 return (this->fPtr)[acoln];
170 Error(
"operator()",
"Request col(%d) outside matrix range of %d - %d",
171 i,this->fMatrix->GetColLwb(),this->fMatrix->GetColLwb()+this->fMatrix->GetNcols());
177 R__ASSERT(this->fMatrix->IsValid());
178 const Int_t acoln = i-this->fMatrix->GetColLwb();
179 if (acoln < this->fMatrix->GetNcols() && acoln >= 0)
180 return (const_cast<Element *>(this->fPtr))[acoln];
182 Error(
"operator()",
"Request col(%d) outside matrix range of %d - %d",
183 i,this->fMatrix->GetColLwb(),this->fMatrix->GetColLwb()+this->fMatrix->GetNcols());
191 void Assign (Element val);
192 void operator= (std::initializer_list<Element> l);
193 void operator+=(Element val);
194 void operator*=(Element val);
227 fMatrix(trc.fMatrix), fColInd(trc.fColInd), fInc(trc.fInc), fPtr(trc.fPtr) { }
229 if(
this != &trc) { fMatrix=trc.
fMatrix; fColInd=trc.
fColInd; fInc=trc.
fInc; fPtr=trc.
fPtr; }
return *
this;}
234 inline Int_t
GetInc ()
const {
return fInc; }
235 inline const Element *
GetPtr ()
const {
return fPtr; }
236 inline const Element &operator ()(Int_t i)
const {
239 const Int_t arown = i-fMatrix->
GetRowLwb();
240 if (arown < fMatrix->GetNrows() && arown >= 0)
241 return fPtr[arown*fInc];
243 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
261 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
265 R__ASSERT(this->fMatrix->IsValid());
266 const Int_t arown = i-this->fMatrix->GetRowLwb();
267 if (arown < this->fMatrix->GetNrows() && arown >= 0)
268 return (this->fPtr)[arown*this->fInc];
270 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
271 i,this->fMatrix->GetRowLwb(),this->fMatrix->GetRowLwb()+this->fMatrix->GetNrows());
277 R__ASSERT(this->fMatrix->IsValid());
278 const Int_t arown = i-this->fMatrix->GetRowLwb();
280 if (arown < this->fMatrix->GetNrows() && arown >= 0)
281 return (const_cast<Element *>(this->fPtr))[arown*this->fInc];
283 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
284 i,this->fMatrix->GetRowLwb(),this->fMatrix->GetRowLwb()+this->fMatrix->GetNrows());
291 void Assign (Element val);
294 void operator= (std::initializer_list<Element> l);
295 void operator+=(Element val);
296 void operator*=(Element val);
329 fMatrix(trc.fMatrix), fInc(trc.fInc), fNdiag(trc.fNdiag), fPtr(trc.fPtr) { }
331 if(
this != &trc) { fMatrix=trc.
fMatrix; fInc=trc.
fInc; fNdiag=trc.
fNdiag; fPtr=trc.
fPtr; }
return *
this;}
335 inline const Element *
GetPtr ()
const {
return fPtr; }
336 inline Int_t
GetInc ()
const {
return fInc; }
337 inline const Element &operator ()(Int_t i)
const {
339 if (i < fNdiag && i >= 0)
342 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,fNdiag);
361 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
364 R__ASSERT(this->fMatrix->IsValid());
365 if (i < this->fNdiag && i >= 0)
366 return (this->fPtr)[i*this->fInc];
368 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,this->fNdiag);
373 R__ASSERT(this->fMatrix->IsValid());
374 if (i < this->fNdiag && i >= 0)
375 return (const_cast<Element *>(this->fPtr))[i*this->fInc];
377 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,this->fNdiag);
378 return (const_cast<Element *>(this->fPtr))[0];
385 void operator+=(Element val);
386 void operator*=(Element val);
418 fMatrix(trc.fMatrix), fNelems(trc.fNelems), fPtr(trc.fPtr) { }
420 if(
this != &trc) { fMatrix=trc.
fMatrix; fNelems=trc.
fNelems; fPtr=trc.
fPtr; }
return *
this;}
424 inline const Element *
GetPtr ()
const {
return fPtr; }
425 inline const Element &operator ()(Int_t i)
const {
427 if (i < fNelems && i >= 0)
430 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,fNelems);
447 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
450 R__ASSERT(this->fMatrix->IsValid());
451 if (i < this->fNelems && i >= 0)
452 return (this->fPtr)[i];
454 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,this->fNelems);
459 R__ASSERT(this->fMatrix->IsValid());
460 if (i < this->fNelems && i >= 0)
461 return (const_cast<Element *>(this->fPtr))[i];
463 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,this->fNelems);
471 void operator+=(Element val);
472 void operator*=(Element val);
510 inline Int_t
GetNrows ()
const {
return fNrowsSub; }
511 inline Int_t
GetNcols ()
const {
return fNcolsSub; }
512 inline const Element &operator ()(Int_t rown,Int_t coln)
const {
516 if (rown >= fNrowsSub || rown < 0) {
517 Error(
"operator()",
"Request row(%d) outside matrix range of 0 - %d",rown,fNrowsSub);
520 if (coln >= fNcolsSub || coln < 0) {
521 Error(
"operator()",
"Request column(%d) outside matrix range of 0 - %d",coln,fNcolsSub);
524 const Int_t index = (rown+fRowOff)*fMatrix->
GetNcols()+coln+fColOff;
535 enum {kWorkMax = 100};
543 R__ASSERT(this->fMatrix->IsValid());
545 const Element *ptr = this->fMatrix->GetMatrixArray();
546 if (rown >= this->fNrowsSub || rown < 0) {
547 Error(
"operator()",
"Request row(%d) outside matrix range of 0 - %d",rown,this->fNrowsSub);
550 if (coln >= this->fNcolsSub || coln < 0) {
551 Error(
"operator()",
"Request column(%d) outside matrix range of 0 - %d",coln,this->fNcolsSub);
554 const Int_t index = (rown+this->fRowOff)*this->fMatrix->GetNcols()+coln+this->fColOff;
555 return (const_cast<Element *>(ptr))[index];
561 void operator+=(Element val);
562 void operator*=(Element val);
598 fMatrix(trc.fMatrix), fRowInd(trc.fRowInd), fNindex(trc.fNindex), fColPtr(trc.fColPtr), fDataPtr(trc.fDataPtr) { }
604 inline const Element *
GetDataPtr ()
const {
return fDataPtr; }
605 inline const Int_t *
GetColPtr ()
const {
return fColPtr; }
609 Element operator()(Int_t i)
const;
622 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
624 Element operator()(Int_t i)
const;
625 Element &operator()(Int_t i);
630 void operator+=(Element val);
631 void operator*=(Element val);
662 fMatrix(trc.fMatrix), fNdiag(trc.fNdiag), fDataPtr(trc.fDataPtr) { }
668 inline const Element *
GetDataPtr()
const {
return fDataPtr; }
671 Element operator ()(Int_t i)
const;
684 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
686 Element operator()(Int_t i)
const;
687 Element &operator()(Int_t i);
692 void operator+=(Element val);
693 void operator*=(Element val);
705 Double_t
Drand(Double_t &ix);
const TMatrixTSparse< Element > * fMatrix
TMatrixTSparseDiag_const< Element > & operator=(const TMatrixTSparseDiag_const< Element > &trc)
virtual const Element * GetMatrixArray() const =0
const TMatrixTBase< Element > * GetMatrix() const
const Element * GetPtr() const
Element & operator()(Int_t i)
Int_t GetRowIndex() const
virtual ~TMatrixTSparseDiag_const()
TMatrixTSparseRow< Element > & operator=(const TMatrixTSparseRow< Element > &r)
TMatrixTSparseDiag_const()
const TMatrixTBase< Element > * fMatrix
TMatrixTFlat_const(const TMatrixTFlat_const< Element > &trc)
Element & operator()(Int_t i)
TMatrixTColumn< Element > & operator=(const TMatrixTColumn< Element > &c)
const Element & operator()(Int_t i) const
Element & operator()(Int_t i)
const Element & operator[](Int_t i) const
const Element * GetPtr() const
TMatrixTSparseRow_const< Element > & operator=(const TMatrixTSparseRow_const< Element > &trc)
TMatrixTSub< Element > & operator=(const TMatrixTSub< Element > &s)
Element operator[](Int_t i) const
Element & operator()(Int_t rown, Int_t coln)
TMatrixTDiag_const< Element > & operator=(const TMatrixTDiag_const< Element > &trc)
virtual ~TElementPosActionT()
const Element * GetPtr() const
const Element & operator()(Int_t i) const
TMatrixTSparseRow_const()
virtual void Operation(Element &element) const =0
TMatrixTSparseDiag_const(const TMatrixTSparseDiag_const< Element > &trc)
const TMatrixTBase< Element > * fMatrix
Element & operator[](Int_t i)
const Element * GetDataPtr() const
const Element * GetPtr() const
Element * GetDataPtr() const
Element operator[](Int_t i) const
TMatrixTSparseDiag< Element > & operator=(const TMatrixTSparseDiag< Element > &d)
Int_t GetRowIndex() const
const Element * GetDataPtr() const
const Element & operator[](Int_t i) const
virtual ~TMatrixTSub_const()
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t Int_t m
Element * GetDataPtr() const
TMatrixTDiag< Element > & operator=(const TMatrixTDiag< Element > &d)
Element & operator[](Int_t i)
const Element & operator()(Int_t i) const
TMatrixTColumn_const< Element > & operator=(const TMatrixTColumn_const< Element > &trc)
TMatrixTSparseRow_const(const TMatrixTSparseRow_const< Element > &trc)
const Element & operator()(Int_t i) const
Element & operator[](Int_t i)
const TMatrixTBase< Element > * fMatrix
TMatrixTRow< Element > & operator=(const TMatrixTRow< Element > &r)
TElementActionT & operator=(const TElementActionT< Element > &)
const TMatrixTBase< Element > * GetMatrix() const
virtual ~TMatrixTRow_const()
Element operator[](Int_t i) const
const Int_t * GetColPtr() const
virtual ~TMatrixTFlat_const()
const TMatrixTBase< Element > * GetMatrix() const
Element & operator[](Int_t i)
TMatrixTRow_const< Element > & operator=(const TMatrixTRow_const< Element > &trc)
TMatrixTRow_const(const TMatrixTRow_const< Element > &trc)
const TMatrixTBase< Element > * GetMatrix() const
const TMatrixTSparse< Element > * fMatrix
virtual ~TElementActionT()
const TMatrixTBase< Element > * fMatrix
const TMatrixTBase< Element > * GetMatrix() const
TMatrixTDiag_const(const TMatrixTDiag_const< Element > &trc)
Element & operator[](Int_t i)
Int_t GetColIndex() const
const Element & operator[](Int_t i) const
virtual ~TMatrixTDiag_const()
static Element & NaNValue()
Element & operator()(Int_t i)
virtual ~TMatrixTColumn_const()
const TMatrixTBase< Element > * fMatrix
TMatrixTColumn_const(const TMatrixTColumn_const< Element > &trc)
virtual ~TMatrixTSparseRow_const()
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.
const Element & operator[](Int_t i) const
TMatrixTFlat_const< Element > & operator=(const TMatrixTFlat_const< Element > &trc)
const TMatrixTBase< Element > * GetMatrix() const
Element & operator[](Int_t i)
const TMatrixTBase< Element > * GetMatrix() const
TMatrixTFlat< Element > & operator=(const TMatrixTFlat< Element > &f)
TElementPosActionT< Element > & operator=(const TElementPosActionT< Element > &)