12 #ifndef ROOT_TMatrixTUtils 13 #define ROOT_TMatrixTUtils 38 template<
class Element>
class TVectorT;
39 template<
class Element>
class TMatrixT;
66 virtual void Operation(Element &element)
const = 0;
98 virtual void Operation(Element &element)
const = 0;
125 fMatrix(trc.fMatrix), fRowInd(trc.fRowInd), fInc(trc.fInc), fPtr(trc.fPtr) { }
127 if(
this != &trc) { fMatrix=trc.
fMatrix; fRowInd=trc.
fRowInd; fInc=trc.
fInc; fPtr=trc.
fPtr; }
return *
this;}
133 inline const Element *
GetPtr ()
const {
return fPtr; }
134 inline const Element &operator ()(
Int_t i)
const {
138 if (acoln < fMatrix->GetNcols() && acoln >= 0)
141 Error(
"operator()",
"Request col(%d) outside matrix range of %d - %d",
159 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
164 const Int_t acoln = i-this->fMatrix->GetColLwb();
165 if (acoln < this->fMatrix->GetNcols() || acoln >= 0)
166 return (this->fPtr)[acoln];
168 Error(
"operator()",
"Request col(%d) outside matrix range of %d - %d",
169 i,this->fMatrix->GetColLwb(),this->fMatrix->GetColLwb()+this->fMatrix->GetNcols());
176 const Int_t acoln = i-this->fMatrix->GetColLwb();
177 if (acoln < this->fMatrix->GetNcols() && acoln >= 0)
178 return (const_cast<Element *>(this->fPtr))[acoln];
180 Error(
"operator()",
"Request col(%d) outside matrix range of %d - %d",
181 i,this->fMatrix->GetColLwb(),this->fMatrix->GetColLwb()+this->fMatrix->GetNcols());
189 void Assign (Element val);
190 void operator= (std::initializer_list<Element>
l);
192 void operator*=(Element val);
196 void operator=(
const TVectorT <Element> &vec);
225 fMatrix(trc.fMatrix), fColInd(trc.fColInd), fInc(trc.fInc), fPtr(trc.fPtr) { }
227 if(
this != &trc) { fMatrix=trc.
fMatrix; fColInd=trc.
fColInd; fInc=trc.
fInc; fPtr=trc.
fPtr; }
return *
this;}
233 inline const Element *
GetPtr ()
const {
return fPtr; }
234 inline const Element &operator ()(
Int_t i)
const {
238 if (arown < fMatrix->GetNrows() && arown >= 0)
239 return fPtr[arown*fInc];
241 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
259 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
264 const Int_t arown = i-this->fMatrix->GetRowLwb();
265 if (arown < this->fMatrix->GetNrows() && arown >= 0)
266 return (this->fPtr)[arown*this->fInc];
268 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
269 i,this->fMatrix->GetRowLwb(),this->fMatrix->GetRowLwb()+this->fMatrix->GetNrows());
276 const Int_t arown = i-this->fMatrix->GetRowLwb();
278 if (arown < this->fMatrix->GetNrows() && arown >= 0)
279 return (const_cast<Element *>(this->fPtr))[arown*this->fInc];
281 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
282 i,this->fMatrix->GetRowLwb(),this->fMatrix->GetRowLwb()+this->fMatrix->GetNrows());
289 void Assign (Element val);
292 void operator= (std::initializer_list<Element>
l);
294 void operator*=(Element val);
298 void operator=(
const TVectorT <Element> &vec);
327 fMatrix(trc.fMatrix), fInc(trc.fInc), fNdiag(trc.fNdiag), fPtr(trc.fPtr) { }
329 if(
this != &trc) { fMatrix=trc.
fMatrix; fInc=trc.
fInc; fNdiag=trc.
fNdiag; fPtr=trc.
fPtr; }
return *
this;}
333 inline const Element *
GetPtr ()
const {
return fPtr; }
337 if (i < fNdiag && i >= 0)
340 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,fNdiag);
359 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
363 if (i < this->fNdiag && i >= 0)
364 return (this->fPtr)[i*this->fInc];
366 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,this->fNdiag);
372 if (i < this->fNdiag && i >= 0)
373 return (const_cast<Element *>(this->fPtr))[i*this->fInc];
375 Error(
"operator()",
"Request diagonal(%d) outside matrix range of 0 - %d",i,this->fNdiag);
376 return (const_cast<Element *>(this->fPtr))[0];
384 void operator*=(Element val);
388 void operator=(
const TVectorT <Element> &vec);
416 fMatrix(trc.fMatrix), fNelems(trc.fNelems), fPtr(trc.fPtr) { }
418 if(
this != &trc) { fMatrix=trc.
fMatrix; fNelems=trc.
fNelems; fPtr=trc.
fPtr; }
return *
this;}
422 inline const Element *
GetPtr ()
const {
return fPtr; }
425 if (i < fNelems && i >= 0)
428 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,fNelems);
445 inline Element *
GetPtr()
const {
return const_cast<Element *
>(this->fPtr); }
449 if (i < this->fNelems && i >= 0)
450 return (this->fPtr)[i];
452 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,this->fNelems);
458 if (i < this->fNelems && i >= 0)
459 return (const_cast<Element *>(this->fPtr))[i];
461 Error(
"operator()",
"Request element(%d) outside matrix range of 0 - %d",i,this->fNelems);
470 void operator*=(Element val);
474 void operator=(
const TVectorT <Element> &vec);
514 if (rown >= fNrowsSub || rown < 0) {
515 Error(
"operator()",
"Request row(%d) outside matrix range of 0 - %d",rown,fNrowsSub);
518 if (coln >= fNcolsSub || coln < 0) {
519 Error(
"operator()",
"Request column(%d) outside matrix range of 0 - %d",coln,fNcolsSub);
522 const Int_t index = (rown+fRowOff)*fMatrix->
GetNcols()+coln+fColOff;
533 enum {kWorkMax = 100};
543 const Element *ptr = this->fMatrix->GetMatrixArray();
544 if (rown >= this->fNrowsSub || rown < 0) {
545 Error(
"operator()",
"Request row(%d) outside matrix range of 0 - %d",rown,this->fNrowsSub);
548 if (coln >= this->fNcolsSub || coln < 0) {
549 Error(
"operator()",
"Request column(%d) outside matrix range of 0 - %d",coln,this->fNcolsSub);
552 const Int_t index = (rown+this->fRowOff)*this->fMatrix->GetNcols()+coln+this->fColOff;
553 return (const_cast<Element *>(ptr))[index];
560 void operator*=(Element val);
564 void operator=(
const TMatrixTBase <Element> &
m);
568 void operator+=(
const TMatrixTBase <Element> &m);
569 void operator*=(
const TMatrixT <Element> &m);
570 void operator*=(
const TMatrixTSym <Element> &m);
596 fMatrix(trc.fMatrix), fRowInd(trc.fRowInd), fNindex(trc.fNindex), fColPtr(trc.fColPtr), fDataPtr(trc.fDataPtr) { }
602 inline const Element *
GetDataPtr ()
const {
return fDataPtr; }
620 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
629 void operator*=(Element val);
633 void operator=(
const TVectorT <Element> &vec);
660 fMatrix(trc.fMatrix), fNdiag(trc.fNdiag), fDataPtr(trc.fDataPtr) { }
666 inline const Element *
GetDataPtr()
const {
return fDataPtr; }
682 inline Element *
GetDataPtr()
const {
return const_cast<Element *
>(this->fDataPtr); }
691 void operator*=(Element val);
695 void operator=(
const TVectorT <Element> &vec);
const TMatrixTSparse< Element > * fMatrix
TMatrixTSparseDiag_const< Element > & operator=(const TMatrixTSparseDiag_const< Element > &trc)
const Element & operator[](Int_t i) const
const Element & operator()(Int_t i) const
const Element & operator[](Int_t i) const
Element & operator()(Int_t i)
Int_t GetRowIndex() const
virtual const Element * GetMatrixArray() const =0
const Element & operator()(Int_t i) const
virtual ~TMatrixTSparseDiag_const()
TMatrixTSparseRow< Element > & operator=(const TMatrixTSparseRow< Element > &r)
TMatrixTSparseDiag_const()
const TMatrixTBase< Element > * fMatrix
TMatrixTFlat_const(const TMatrixTFlat_const< Element > &trc)
const TMatrixTBase< Element > * GetMatrix() const
Element & operator()(Int_t i)
TMatrixTColumn< Element > & operator=(const TMatrixTColumn< Element > &c)
Element & operator()(Int_t i)
TMatrixTSparseRow_const< Element > & operator=(const TMatrixTSparseRow_const< Element > &trc)
TMatrixTSub< Element > & operator=(const TMatrixTSub< Element > &s)
const TMatrixTBase< Element > * GetMatrix() const
Element & operator()(Int_t rown, Int_t coln)
Element operator[](Int_t i) const
TMatrixTDiag_const< Element > & operator=(const TMatrixTDiag_const< Element > &trc)
virtual ~TElementPosActionT()
#define ClassDef(name, id)
TMatrixTSparseRow_const()
TMatrixTSparseDiag_const(const TMatrixTSparseDiag_const< Element > &trc)
const TMatrixTBase< Element > * fMatrix
Element & operator[](Int_t i)
const Element & operator()(Int_t i) const
const Element & operator[](Int_t i) const
TMatrixTSparseDiag< Element > & operator=(const TMatrixTSparseDiag< Element > &d)
Element * GetDataPtr() const
const TMatrixTBase< Element > * GetMatrix() const
void Error(const char *location, const char *msgfmt,...)
virtual ~TMatrixTSub_const()
TMatrixTDiag< Element > & operator=(const TMatrixTDiag< Element > &d)
const Element * GetDataPtr() const
Element & operator[](Int_t i)
TMatrixTColumn_const< Element > & operator=(const TMatrixTColumn_const< Element > &trc)
TMatrixTSparseRow_const(const TMatrixTSparseRow_const< Element > &trc)
const TMatrixTBase< Element > * GetMatrix() const
Element operator[](Int_t i) const
Element operator[](Int_t i) const
const Int_t * GetColPtr() const
Element * GetDataPtr() const
Int_t GetColIndex() const
const Element & operator()(Int_t i) const
const TMatrixTBase< Element > * GetMatrix() const
Element & operator[](Int_t i)
const TMatrixTBase< Element > * fMatrix
Int_t GetRowIndex() const
TMatrixTRow< Element > & operator=(const TMatrixTRow< Element > &r)
TElementActionT & operator=(const TElementActionT< Element > &)
virtual void Operation(Element &element) const =0
virtual ~TMatrixTRow_const()
virtual ~TMatrixTFlat_const()
const TMatrixTBase< Element > * GetMatrix() const
Element & operator[](Int_t i)
TRObject operator()(const T1 &t1) const
TMatrixTRow_const< Element > & operator=(const TMatrixTRow_const< Element > &trc)
const Element * GetPtr() const
TMatrixTRow_const(const TMatrixTRow_const< Element > &trc)
const Element & operator[](Int_t i) const
const Element * GetPtr() const
const TMatrixTSparse< Element > * fMatrix
virtual ~TElementActionT()
const TMatrixTBase< Element > * fMatrix
TMatrixTDiag_const(const TMatrixTDiag_const< Element > &trc)
Element & operator[](Int_t i)
const Element * GetPtr() const
const TMatrixTBase< Element > * GetMatrix() const
const Element * GetPtr() const
virtual ~TMatrixTDiag_const()
const Element * GetDataPtr() 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.
TMatrixTFlat_const< Element > & operator=(const TMatrixTFlat_const< Element > &trc)
Element & operator[](Int_t i)
TMatrixTFlat< Element > & operator=(const TMatrixTFlat< Element > &f)
std::string & operator+=(std::string &left, const TString &right)
TElementPosActionT< Element > & operator=(const TElementPosActionT< Element > &)