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;}
135 inline const Element *
GetPtr ()
const {
return fPtr; }
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); }
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());
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);
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;}
235 inline const Element *
GetPtr ()
const {
return fPtr; }
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); }
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());
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);
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; }
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); }
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);
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];
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; }
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); }
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);
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);
472 void operator*=(Element val);
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};
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];
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; }
622 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
631 void operator*=(Element val);
662 fMatrix(trc.fMatrix), fNdiag(trc.fNdiag), fDataPtr(trc.fDataPtr) { }
668 inline const Element *
GetDataPtr()
const {
return fDataPtr; }
684 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
693 void operator*=(Element val);
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)
TRObject operator()(const T1 &t1) const
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
#define ClassDef(name, id)
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
void Error(const char *location, const char *msgfmt,...)
virtual ~TMatrixTSub_const()
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)
std::string & operator+=(std::string &left, const TString &right)
TElementPosActionT< Element > & operator=(const TElementPosActionT< Element > &)