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;}
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); }
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",
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",
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;}
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); }
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",
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",
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;}
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)
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];
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;}
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);
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);
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);
551 return (const_cast<Element *>(ptr))[index];
594 fMatrix(trc.fMatrix), fRowInd(trc.fRowInd), fNindex(trc.fNindex), fColPtr(trc.fColPtr), fDataPtr(trc.fDataPtr) { }
658 fMatrix(trc.fMatrix), fNdiag(trc.fNdiag), fDataPtr(trc.fDataPtr) { }
Element operator[](Int_t i) const
void Rank1Update(const TVectorT< Element > &vec, Element alpha=1.0)
Perform a rank 1 operation on the matrix: A += alpha * v * v^T.
const TMatrixTSparse< Element > * fMatrix
Element operator()(Int_t i) const
TMatrixTSparseDiag_const< Element > & operator=(const TMatrixTSparseDiag_const< Element > &trc)
virtual const Element * GetMatrixArray() const =0
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
void operator+=(Element val)
Add val to every element of the matrix column.
const Element & operator()(Int_t i) const
virtual ~TMatrixTSparseDiag_const()
void operator*=(Element val)
Multiply every element of the matrix with val.
TMatrixTSparseRow< Element > & operator=(const TMatrixTSparseRow< Element > &r)
TMatrixTSparseDiag_const()
const TMatrixTBase< Element > * fMatrix
TMatrixTFlat_const(const TMatrixTFlat_const< Element > &trc)
void operator+=(Element val)
Assign val to every element of the matrix diagonal.
const Element & operator()(Int_t i) const
void operator*=(Element val)
Multiply every element of the sub matrix by val .
const TMatrixTBase< Element > * GetMatrix() const
Element & operator()(Int_t i)
TMatrixTColumn< Element > & operator=(const TMatrixTColumn< Element > &c)
void operator=(Element val)
Assign val to every element of the matrix diagonal.
const Element & operator[](Int_t i) const
void operator+=(Element val)
Add val to every non-zero (!) element of the matrix row.
Element & operator()(Int_t i)
void operator*=(Element val)
Multiply every element of the matrix row with val.
TMatrixTSparseRow_const< Element > & operator=(const TMatrixTSparseRow_const< Element > &trc)
TMatrixTSub< Element > & operator=(const TMatrixTSub< Element > &s)
const Element & operator()(Int_t rown, Int_t coln) const
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()
Element operator()(Int_t i) 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 & operator[](Int_t i)
void operator*=(Element val)
Multiply every element of the matrix diagonal by val.
const Element & operator()(Int_t i) const
const Element & operator[](Int_t i) const
TMatrixTSparseDiag< Element > & operator=(const TMatrixTSparseDiag< Element > &d)
const Element & operator()(Int_t i) const
Element * GetDataPtr() const
const TMatrixTBase< Element > * GetMatrix() const
void Error(const char *location, const char *msgfmt,...)
virtual ~TMatrixTSub_const()
void operator=(Element val)
Assign val to every element of the matrix column.
void operator=(Element val)
Assign val to every element of the matrix.
TMatrixTDiag< Element > & operator=(const TMatrixTDiag< Element > &d)
const Element * GetDataPtr() const
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 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 Element & operator()(Int_t i) 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)
void operator+=(Element val)
Add val to every element of the sub matrix.
TElementActionT & operator=(const TElementActionT< Element > &)
virtual ~TMatrixTRow_const()
const Element & operator()(Int_t i) const
virtual ~TMatrixTFlat_const()
const TMatrixTBase< Element > * GetMatrix() const
void operator+=(Element val)
Add val to every element of the matrix.
Element & operator[](Int_t i)
TMatrixTRow_const< Element > & operator=(const TMatrixTRow_const< Element > &trc)
void operator=(Element val)
Assign val to every element of the sub matrix.
const Element * GetPtr() const
void operator+=(Element val)
Add val to every element of the matrix diagonal.
TMatrixTRow_const(const TMatrixTRow_const< Element > &trc)
const Element & operator[](Int_t i) const
const Element * GetPtr() const
virtual void Operation(Element &element) const =0
const TMatrixTSparse< Element > * fMatrix
virtual ~TElementActionT()
void operator=(Element val)
Assign val to every element of the matrix row.
const TMatrixTBase< Element > * fMatrix
TMatrixTDiag_const(const TMatrixTDiag_const< Element > &trc)
void operator*=(Element val)
Multiply every element of the matrix row by val.
Element & operator[](Int_t i)
const Element * GetPtr() const
const TMatrixTBase< Element > * GetMatrix() const
const Element * GetPtr() const
void operator*=(Element val)
Multiply every element of the matrix column with val.
virtual ~TMatrixTDiag_const()
const Element * GetDataPtr() const
Element operator()(Int_t i) const
static Element & NaNValue()
void operator=(Element val)
Assign val to every non-zero (!) element of the matrix row.
Element & operator()(Int_t i)
virtual ~TMatrixTColumn_const()
const TMatrixTBase< Element > * fMatrix
void operator*=(Element val)
Assign val to every element of the matrix diagonal.
TMatrixTColumn_const(const TMatrixTColumn_const< Element > &trc)
virtual ~TMatrixTSparseRow_const()
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.
void operator+=(Element val)
Add val to every element of the matrix row.
TMatrixTFlat_const< Element > & operator=(const TMatrixTFlat_const< Element > &trc)
Element & operator[](Int_t i)
TMatrixTFlat< Element > & operator=(const TMatrixTFlat< Element > &f)
void operator=(Element val)
Assign val to every element of the matrix diagonal.
TElementPosActionT< Element > & operator=(const TElementPosActionT< Element > &)
const Element & operator[](Int_t i) const