12#ifndef ROOT_TMatrixTSym
13#define ROOT_TMatrixTSym
32template<
class Element>
class TMatrixT;
34template<
class Element>
class TVectorT;
56#if defined(__clang__) && __clang_major__ < 20
57#pragma clang diagnostic push
58#pragma clang diagnostic ignored "-Wshadow"
61#if defined(__clang__) && __clang_major__ < 20
62#pragma clang diagnostic pop
87 void TMult(
const TMatrixT <Element> &
a);
112 const TMatrixTSym <Element> &
Use (
Int_t row_lwb,
Int_t row_upb,
const Element *data)
const
114 ((
const_cast<TMatrixTSym<Element> *
>(
this))->Use(row_lwb,row_upb,
const_cast<Element *
>(data))); }
115 TMatrixTSym <Element> &
Use (
Int_t nrows,Element *data);
116 const TMatrixTSym <Element> &
Use (
Int_t nrows,
const Element *data)
const;
133 return ResizeTo(
m.GetRowLwb(),
m.GetRowUpb(),
m.GetColLwb(),
m.GetColUpb()); }
154 inline TMatrixTRow <Element>
operator[](
Int_t rown) {
return TMatrixTRow <Element>(*
this,rown); }
161 Error(
"operator=(const TMatrixTSym2 &)",
"matrices not compatible");
206 {
return Use(0,nrows-1,data); }
208 {
return Use(
a.GetRowLwb(),
a.GetRowUpb(),
a.GetMatrixArray()); }
210 {
return Use(
a.GetRowLwb(),
a.GetRowUpb(),
a.GetMatrixArray()); }
216 this->
GetSub(row_lwb,row_upb,col_lwb,col_upb,tmp,option);
225 if (arown >= this->
fNrows || arown < 0) {
226 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->
fNrows);
229 if (acoln >= this->
fNcols || acoln < 0) {
230 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->
fNcols);
241 if (arown >= this->
fNrows || arown < 0) {
242 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->
fNrows);
245 if (acoln >= this->
fNcols || acoln < 0) {
246 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->
fNcols);
256template <
class Element>
262 assert((rown < this->
fNrows && rown >= 0) &&
"SetElement() error: row index outside matrix range");
263 assert((coln < this->
fNcols && coln >= 0) &&
"SetElement() error: column index outside matrix range");
277#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
278#pragma GCC diagnostic push
279#pragma GCC diagnostic ignored "-Weffc++"
283#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
284#pragma GCC diagnostic pop
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
#define ClassDefOverride(name, id)
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
TMatrixTSym< Element > & ElementDiv(TMatrixTSym< Element > &target, const TMatrixTSym< Element > &source)
Multiply target by the source, element-by-element.
TMatrixTSym< Element > operator<(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
source1 < source2
TMatrixTSym< Element > operator+(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
TMatrixTSym< Element > operator-(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
TMatrixTSym< Element > & Add(TMatrixTSym< Element > &target, Element scalar, const TMatrixTSym< Element > &source)
Modify addition: target += scalar * source.
TMatrixTSym< Element > & ElementMult(TMatrixTSym< Element > &target, const TMatrixTSym< Element > &source)
Multiply target by the source, element-by-element.
TMatrixTSym< Element > operator>(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
source1 > source2
TMatrixTSym< Element > operator>=(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
source1 >= source2
TMatrixTSym< Element > operator<=(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
source1 <= source2
TMatrixTSym< Element > operator||(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Logical Or.
TMatrixTSym< Element > operator*(const TMatrixTSym< Element > &source, Element val)
TMatrixTSym< Element > operator&&(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Logical AND.
Bool_t operator==(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Check to see if two matrices are identical.
TClass instances represent classes, structs and namespaces in the ROOT type system.
static Element & NaNValue()
TMatrixTBase< Element > & Apply(const TElementPosActionT< Element > &action) override
Apply action to each element of the matrix.
TMatrixTSym< Element > GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Option_t *option="S") const
Element & operator()(Int_t rown, Int_t coln) override
Access element a_ij where i=rown and j=coln.
TMatrixTBase< Element > & ResizeTo(const TMatrixTSym< Element > &m)
TMatrixTSym< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixTSym(const TMatrixTSym< Element2 > &another)
TMatrixTRow< Element > operator[](Int_t rown)
Access row a_i where i=rown.
const Int_t * GetColIndexArray() const override
void TMult(const TMatrixTSym< Element > &a)
Matrix multiplication, with A symmetric Replace this matrix with C such that C = A' * A = A * A = A *...
TMatrixTSym< Element > & operator+=(Element val)
Add val to every element of the matrix.
TMatrixTBase< Element > & ResizeTo(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t=-1) override
Set size of the matrix to [row_lwb:row_upb] x [col_lwb:col_upb] New dynamic elements are created,...
const TMatrixTSym< Element > & Use(Int_t nrows, const Element *data) const
const TMatrixTSym< Element > & Use(Int_t row_lwb, Int_t row_upb, const Element *data) const
virtual TMatrixTSym< Element > & RandomizePD(Element alpha, Element beta, Double_t &seed)
randomize matrix element values but keep matrix symmetric positive definite
TMatrixTBase< Element > & Randomize(Element alpha, Element beta, Double_t &seed) override
randomize matrix element values but keep matrix symmetric
Int_t * GetRowIndexArray() override
TMatrixTBase< Element > & SetColIndexArray(Int_t *) override
TMatrixTSym< Element > & Transpose(const TMatrixTSym< Element > &source)
Transpose a matrix.
Element * New_m(Int_t size)
return data pointer .
TMatrixTSym< Element > & Use(Int_t nrows, Element *data)
TMatrixTSym< Element > & Use(Int_t row_lwb, Int_t row_upb, Element *data)
const TMatrixTRow_const< Element > operator[](Int_t rown) const
TMatrixTSym< Element > & Rank1Update(const TVectorT< Element > &v, Element alpha=1.0)
Perform a rank 1 operation on the matrix: A += alpha * v * v^T.
TMatrixTSym< Element > & Use(TMatrixTSym< Element > &a)
TMatrixTSym< Element > & T()
void Minus(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Symmetric matrix subtraction. Replace this matrix with C such that C = A - B.
TMatrixTSym(Int_t row_lwb, Int_t row_upb, const Element *data, Option_t *option="")
array elements are copied
void TMult(const TMatrixT< Element > &a)
Replace this matrix with C such that C = A' * A.
TMatrixTSym(EMatrixCreatorsOp1 op, const TMatrixTSym< Element > &prototype)
Create a matrix applying a specific operation to the prototype.
const Int_t * GetRowIndexArray() const override
TMatrixTSym< Element > & Similarity(const TMatrixTSym< Element > &n)
Calculate B * (*this) * B^T , final matrix will be (nrowsb x nrowsb) This is a similarity transform w...
void Delete_m(Int_t size, Element *&)
delete data pointer m, if it was assigned on the heap
Element Similarity(const TVectorT< Element > &v) const
Calculate scalar v * (*this) * v^T.
void Allocate(Int_t nrows, Int_t ncols, Int_t row_lwb=0, Int_t col_lwb=0, Int_t init=0, Int_t=-1)
Allocate new matrix.
Element * GetMatrixArray() override
TMatrixTSym< Element > & GetSub(Int_t row_lwb, Int_t row_upb, TMatrixTSym< Element > &target, Option_t *option="S") const
Get submatrix [row_lwb..row_upb][row_lwb..row_upb]; The indexing range of the returned matrix depends...
Int_t Memcpy_m(Element *newp, const Element *oldp, Int_t copySize, Int_t newSize, Int_t oldSize)
copy copySize doubles from *oldp to *newp .
TMatrixTSym & operator-=(const TMatrixTSym &source)
Subtract the source matrix.
const TMatrixT< Element > EigenVectors(TVectorT< Element > &eigenValues) const
Return a matrix containing the eigen-vectors ordered by descending eigen-values.
TMatrixTSym & operator+=(const TMatrixTSym &source)
Add the source matrix.
TMatrixTSym< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
Bool_t IsSymmetric() const override
Check whether matrix is symmetric.
void Plus(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Symmetric matrix summation. Replace this matrix with C such that C = A + B.
TMatrixTSym(Int_t nrows, const Element *data, Option_t *option="")
option=
Double_t fDataStack[TMatrixTBase< Double_t >::kSizeMax]
TMatrixTSym(const TMatrixTSym< Element > &a, EMatrixCreatorsOp2 op, const TMatrixTSym< Element > &b)
TMatrixTSym(Int_t row_lwb, Int_t row_upb)
TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source) override
Insert matrix source starting at [row_lwb][col_lwb] in a symmetric fashion, thereby overwriting the p...
TMatrixTSym< Element > & InvertFast(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
TMatrixTSym< Element > & SimilarityT(const TMatrixT< Element > &n)
Calculate B^T * (*this) * B , final matrix will be (ncolsb x ncolsb) It is more efficient than applyi...
void SetElement(Int_t rown, Int_t coln, Element val)
Efficiently sets element (rown,coln) equal to val Index bound checks can be deactivated by defining N...
TMatrixTSym(EMatrixCreatorsOp1 op, const TMatrixT< Element > &prototype)
TMatrixTSym< Element > & Similarity(const TMatrixT< Element > &n)
Calculate B * (*this) * B^T , final matrix will be (nrowsb x nrowsb) This is a similarity transform w...
TMatrixTSym< Element > & operator=(const TMatrixTSym< Element > &source)
TMatrixTSym< Element > & SetSub(Int_t row_lwb, const TMatrixTBase< Element > &source)
Insert matrix source starting at [row_lwb][row_lwb], thereby overwriting the part [row_lwb....
TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="") override
Copy array data to matrix .
void Clear(Option_t *="") override
void Mult(const TMatrixTSym< Element > &a)
TMatrixTBase< Element > & GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixTBase< Element > &target, Option_t *option="S") const override
Get submatrix [row_lwb..row_upb][col_lwb..col_upb]; The indexing range of the returned matrix depends...
TMatrixTBase< Element > & Shift(Int_t row_shift, Int_t col_shift) override
Shift the row index by adding row_shift and the column index by adding col_shift, respectively.
TMatrixTBase< Element > & Apply(const TElementActionT< Element > &action) override
Apply action to each matrix element.
void Determinant(Double_t &d1, Double_t &d2) const override
TMatrixTSym(const TMatrixTSym< Element > &another)
TMatrixTSym(const TMatrixTSymLazy< Element > &lazy_constructor)
Double_t Determinant() const override
TMatrixTSym< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant Notice that the LU decomposition is used instead of B...
const TMatrixTSym< Element > & Use(const TMatrixTSym< Element > &a) const
Element operator()(Int_t rown, Int_t coln) const override
const Element * GetMatrixArray() const override
TMatrixTBase< Element > & SetRowIndexArray(Int_t *) override
Int_t * GetColIndexArray() override
TObject & operator=(const TObject &rhs) noexcept
TObject assignment operator.
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Bool_t AreCompatible(const TMatrixTBase< Element1 > &m1, const TMatrixTBase< Element2 > &m2, Int_t verbose=0)
Check that matrice sm1 and m2 areboth valid and have identical shapes .