12 #ifndef ROOT_TMatrixTBase 13 #define ROOT_TMatrixTBase 83 template<
class Element>
class TMatrixTBase :
public TObject {
101 static void DoubleLexSort (Int_t n,Int_t *first,Int_t *second,Element *data);
103 Int_t *second,Int_t swapSecond,Int_t *index);
115 fNrows(0), fNcols(0), fRowLwb(0), fColLwb(0), fNelems(0), fNrowIndex(0),
116 fTol(0), fIsOwner(kTRUE) { }
121 inline Int_t
GetRowUpb ()
const {
return fNrows+fRowLwb-1; }
124 inline Int_t
GetColUpb ()
const {
return fNcols+fColLwb-1; }
139 inline Element
SetTol (Element tol);
141 virtual void Clear (Option_t *option=
"") = 0;
155 virtual void ExtractRow (Int_t row,Int_t col, Element *v,Int_t n = -1)
const;
161 virtual Double_t
Determinant()
const { AbstractMethod(
"Determinant()");
return 0.; }
162 virtual void Determinant(Double_t &d1,Double_t &d2)
const { AbstractMethod(
"Determinant()"); d1 = 0.; d2 = 0.; }
172 virtual Element
RowNorm ()
const;
173 virtual Element
ColNorm ()
const;
174 virtual Element
E2Norm ()
const;
178 virtual Element
Sum ()
const;
179 virtual Element
Min ()
const;
180 virtual Element
Max ()
const;
182 void Draw (Option_t *option=
"");
183 void Print(Option_t *name =
"")
const;
185 virtual Element
operator()(Int_t rown,Int_t coln)
const = 0;
186 virtual Element &
operator()(Int_t rown,Int_t coln) = 0;
220 const Element oldTol =
fTol;
228 template<
class Element1,
class Element2>
236 Int_t verbose,Element maxDevAllow);
242 Int_t verbose,Element maxDevAllow);
virtual TMatrixTBase< Element > & UnitMatrix()
Make a unit matrix (matrix need not be a square one).
virtual const Element * GetMatrixArray() const =0
virtual TMatrixTBase< Element > & Sqrt()
Take square root of all elements.
virtual void Clear(Option_t *option="")=0
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
virtual TMatrixTBase< Element > & Shift(Int_t row_shift, Int_t col_shift)
Shift the row index by adding row_shift and the column index by adding col_shift, respectively...
virtual Int_t NonZeros() const
Compute the number of elements != 0.0.
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
Copy array data to matrix .
virtual TMatrixTBase< Element > & Zero()
Set matrix elements to zero.
Bool_t operator!=(Element val) const
Are all matrix elements not equal to val?
virtual TMatrixTBase< Element > & SetColIndexArray(Int_t *data)=0
Bool_t VerifyMatrixValue(const TMatrixTBase< Element > &m, Element val, Int_t verbose, Element maxDevAllow)
Validate that all elements of matrix have value val within maxDevAllow.
virtual TMatrixTBase< Element > & Sqr()
Square each element of the matrix.
Bool_t operator>(Element val) const
Are all matrix elements > val?
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1)=0
virtual TMatrixTBase< Element > & SetRowIndexArray(Int_t *data)=0
double beta(double x, double y)
Calculates the beta function.
Int_t GetNoElements() const
Bool_t operator<(Element val) const
Are all matrix elements < val?
Bool_t VerifyMatrixIdentity(const TMatrixTBase< Element > &m1, const TMatrixTBase< Element > &m2, Int_t verbose, Element maxDevAllow)
Verify that elements of the two matrices are equal within MaxDevAllow .
static void DoubleLexSort(Int_t n, Int_t *first, Int_t *second, Element *data)
default kTRUE, when Use array kFALSE
virtual Double_t Determinant() const
Bool_t operator>=(Element val) const
Are all matrix elements >= val?
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 .
virtual Element operator()(Int_t rown, Int_t coln) const =0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t Int_t m
virtual TMatrixTBase< Element > & Apply(const TElementActionT< Element > &action)
Apply action to each matrix element.
virtual TMatrixTBase< Element > & NormByDiag(const TVectorT< Element > &v, Option_t *option="D")
option:
virtual void Determinant(Double_t &d1, Double_t &d2) const
virtual TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source)=0
virtual void ExtractRow(Int_t row, Int_t col, Element *v, Int_t n=-1) const
Store in array v, n matrix elements of row rown starting at column coln.
virtual TMatrixTBase< Element > & InsertRow(Int_t row, Int_t col, const Element *v, Int_t n=-1)
Copy n elements from array v to row rown starting at column coln.
virtual void GetMatrix2Array(Element *data, Option_t *option="") const
Copy matrix data to array .
virtual Element Min() const
return minimum matrix element value
virtual TMatrixTBase< Element > & Randomize(Element alpha, Element beta, Double_t &seed)
Randomize matrix element values.
Bool_t operator<=(Element val) const
Are all matrix elements <= val?
R__EXTERN Int_t gMatrixCheck
virtual Element RowNorm() const
Row matrix norm, MAX{ SUM{ |M(i,j)|, over j}, over i}.
virtual Element E2Norm() const
Square of the Euclidian norm, SUM{ m(i,j)^2 }.
virtual Element Sum() const
Compute sum of elements.
void Compare(const TMatrixTBase< Element > &m1, const TMatrixTBase< Element > &m2)
Compare two matrices and print out the result of the comparison.
void Print(Option_t *name="") const
Print the matrix as a table of elements.
void Draw(Option_t *option="")
Draw this matrix The histogram is named "TMatrixT" by default and no title.
static void IndexedLexSort(Int_t n, Int_t *first, Int_t swapFirst, Int_t *second, Int_t swapSecond, Int_t *index)
Lexical sort on array data using indices first and second.
Bool_t operator==(Element val) const
Are all matrix elements equal to val?
static Element & NaNValue()
virtual Element ColNorm() const
Column matrix norm, MAX{ SUM{ |M(i,j)|, over i}, over j}.
virtual 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 =0
virtual Element Max() const
return maximum vector element value
Element SetTol(Element tol)
virtual const Int_t * GetColIndexArray() const =0
virtual const Int_t * GetRowIndexArray() const =0
virtual TMatrixTBase< Element > & Abs()
Take an absolute value of a matrix, i.e. apply Abs() to each element.