12 #ifndef ROOT_TMatrixTUtils 13 #define ROOT_TMatrixTUtils 36 #ifndef ROOT_TMatrixTBase 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; }
136 inline const Element &operator ()(
Int_t i)
const {
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());
192 void operator+=(Element val);
193 void operator*=(Element val);
226 fMatrix(trc.fMatrix), fColInd(trc.fColInd), fInc(trc.fInc), fPtr(trc.fPtr) { }
228 if(
this != &trc) { fMatrix=trc.
fMatrix; fColInd=trc.
fColInd; fInc=trc.
fInc; fPtr=trc.
fPtr; }
return *
this;}
234 inline const Element *
GetPtr ()
const {
return fPtr; }
235 inline const Element &operator ()(
Int_t i)
const {
239 if (arown < fMatrix->GetNrows() && arown >= 0)
240 return fPtr[arown*fInc];
242 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
260 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
265 const Int_t arown = i-this->fMatrix->GetRowLwb();
266 if (arown < this->fMatrix->GetNrows() && arown >= 0)
267 return (this->fPtr)[arown*this->fInc];
269 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
270 i,this->fMatrix->GetRowLwb(),this->fMatrix->GetRowLwb()+this->fMatrix->GetNrows());
277 const Int_t arown = i-this->fMatrix->GetRowLwb();
279 if (arown < this->fMatrix->GetNrows() && arown >= 0)
280 return (const_cast<Element *>(this->fPtr))[arown*this->fInc];
282 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
283 i,this->fMatrix->GetRowLwb(),this->fMatrix->GetRowLwb()+this->fMatrix->GetNrows());
291 void operator+=(Element val);
292 void operator*=(Element val);
325 fMatrix(trc.fMatrix), fInc(trc.fInc), fNdiag(trc.fNdiag), fPtr(trc.fPtr) { }
327 if(
this != &trc) { fMatrix=trc.
fMatrix; fInc=trc.
fInc; fNdiag=trc.
fNdiag; fPtr=trc.
fPtr; }
return *
this;}
331 inline const Element *
GetPtr ()
const {
return fPtr; }
333 inline const Element &operator ()(
Int_t i)
const {
335 if (i < fNdiag && i >= 0)
338 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,fNdiag);
357 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
361 if (i < this->fNdiag && i >= 0)
362 return (this->fPtr)[i*this->fInc];
364 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,this->fNdiag);
370 if (i < this->fNdiag && i >= 0)
371 return (const_cast<Element *>(this->fPtr))[i*this->fInc];
373 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,this->fNdiag);
374 return (const_cast<Element *>(this->fPtr))[0];
381 void operator+=(Element val);
382 void operator*=(Element val);
414 fMatrix(trc.fMatrix), fNelems(trc.fNelems), fPtr(trc.fPtr) { }
416 if(
this != &trc) { fMatrix=trc.
fMatrix; fNelems=trc.
fNelems; fPtr=trc.
fPtr; }
return *
this;}
420 inline const Element *
GetPtr ()
const {
return fPtr; }
421 inline const Element &operator ()(
Int_t i)
const {
423 if (i < fNelems && i >= 0)
426 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,fNelems);
443 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
447 if (i < this->fNelems && i >= 0)
448 return (this->fPtr)[i];
450 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,this->fNelems);
456 if (i < this->fNelems && i >= 0)
457 return (const_cast<Element *>(this->fPtr))[i];
459 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,this->fNelems);
467 void operator+=(Element val);
468 void operator*=(Element val);
508 inline const Element &operator ()(
Int_t rown,
Int_t coln)
const {
512 if (rown >= fNrowsSub || rown < 0) {
513 Error(
"operator()",
"Request row(%d) outside matrix range of 0 - %d",rown,fNrowsSub);
516 if (coln >= fNcolsSub || coln < 0) {
517 Error(
"operator()",
"Request column(%d) outside matrix range of 0 - %d",coln,fNcolsSub);
520 const Int_t index = (rown+fRowOff)*fMatrix->
GetNcols()+coln+fColOff;
531 enum {kWorkMax = 100};
541 const Element *ptr = this->fMatrix->GetMatrixArray();
542 if (rown >= this->fNrowsSub || rown < 0) {
543 Error(
"operator()",
"Request row(%d) outside matrix range of 0 - %d",rown,this->fNrowsSub);
546 if (coln >= this->fNcolsSub || coln < 0) {
547 Error(
"operator()",
"Request column(%d) outside matrix range of 0 - %d",coln,this->fNcolsSub);
550 const Int_t index = (rown+this->fRowOff)*this->fMatrix->GetNcols()+coln+this->fColOff;
551 return (const_cast<Element *>(ptr))[index];
557 void operator+=(Element val);
558 void operator*=(Element val);
594 fMatrix(trc.fMatrix), fRowInd(trc.fRowInd), fNindex(trc.fNindex), fColPtr(trc.fColPtr), fDataPtr(trc.fDataPtr) { }
600 inline const Element *
GetDataPtr ()
const {
return fDataPtr; }
605 Element operator()(
Int_t i)
const;
618 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
620 Element operator()(
Int_t i)
const;
621 Element &operator()(
Int_t i);
626 void operator+=(Element val);
627 void operator*=(Element val);
658 fMatrix(trc.fMatrix), fNdiag(trc.fNdiag), fDataPtr(trc.fDataPtr) { }
664 inline const Element *
GetDataPtr()
const {
return fDataPtr; }
667 Element operator ()(
Int_t i)
const;
680 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
682 Element operator()(
Int_t i)
const;
683 Element &operator()(
Int_t i);
688 void operator+=(Element val);
689 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)
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)
TElementPosActionT< Element > & operator=(const TElementPosActionT< Element > &)