40template<
class Element>
43 const int incs[] = {1,5,19,41,109,209,505,929,2161,3905,8929,16001,
INT_MAX};
57 const Element tmp =
data[k];
64 first [
j] = first [
j-
inc];
65 second[
j] = second[
j-
inc];
79template<
class Element>
83 const int incs[] = {1,5,19,41,109,209,505,929,2161,3905,8929,16001,
INT_MAX};
130 second[
j] = second[
j-
inc];
147 first[
j] = first[
j-
inc];
164 first [
j] = first [
j-
inc];
186template<
class Element>
194 Element *
elem = GetMatrixArray();
214template<
class Element>
219 if ((fNrows != fNcols) || (fRowLwb != fColLwb))
222 const Element *
const elem = GetMatrixArray();
243template<
class Element>
251 const Element *
const elem = GetMatrixArray();
269template<
class Element>
278 Error(
"InsertRow",
"row %d out of matrix range",
rown);
283 Error(
"InsertRow",
"column %d out of matrix range",
coln);
288 Error(
"InsertRow",
"row length %d out of range",
nr);
294 Element *
const elem = GetMatrixArray()+off;
303template<
class Element>
312 Error(
"ExtractRow",
"row %d out of matrix range",
rown);
317 Error(
"ExtractRow",
"column %d out of matrix range",
coln);
322 Error(
"ExtractRow",
"row length %d out of range",
nr);
328 const Element *
const elem = GetMatrixArray()+off;
337template<
class Element>
349template<
class Element>
353 memset(this->GetMatrixArray(),0,fNelems*
sizeof(Element));
361template<
class Element>
366 Element *
ep = this->GetMatrixArray();
367 const Element *
const fp =
ep+fNelems;
379template<
class Element>
384 Element *
ep = this->GetMatrixArray();
385 const Element *
const fp =
ep+fNelems;
397template<
class Element>
402 Element *
ep = this->GetMatrixArray();
403 const Element *
const fp =
ep+fNelems;
415template<
class Element>
420 Element *
ep = this->GetMatrixArray();
421 memset(
ep,0,fNelems*
sizeof(Element));
422 for (
Int_t i = fRowLwb; i <= fRowLwb+fNrows-1; i++)
423 for (
Int_t j = fColLwb;
j <= fColLwb+fNcols-1;
j++)
424 *
ep++ = (i==
j ? 1.0 : 0.0);
434template<
class Element>
442 if (
v.GetNoElements() <
nMax) {
443 Error(
"NormByDiag",
"vector shorter than matrix diagonal");
452 const Element *
pV =
v.GetMatrixArray();
453 Element *
mp = this->GetMatrixArray();
463 Error(
"NormbyDiag",
"vector element %d is zero",
icol);
468 Error(
"NormbyDiag",
"vector element %d is zero",
irow);
488template<
class Element>
493 const Element *
ep = GetMatrixArray();
494 const Element *
const fp =
ep+fNelems;
515template<
class Element>
520 const Element *
ep = GetMatrixArray();
521 const Element *
const fp =
ep+fNcols;
528 for (
Int_t i = 0; i < fNrows; i++,
ep += fNcols)
542template<
class Element>
547 const Element *
ep = GetMatrixArray();
548 const Element *
const fp =
ep+fNelems;
551 for ( ;
ep < fp;
ep++)
552 sum += (*
ep) * (*ep);
560template<
class Element>
566 const Element *
ep = this->GetMatrixArray();
567 const Element *
const fp =
ep+fNelems;
577template<
class Element>
583 const Element *
ep = this->GetMatrixArray();
584 const Element *
const fp =
ep+fNelems;
594template<
class Element>
599 const Element *
const ep = this->GetMatrixArray();
607template<
class Element>
612 const Element *
const ep = this->GetMatrixArray();
621template<
class Element>
624 gROOT->ProcessLine(
Form(
"THistPainter::PaintSpecialObjects((TObject*)0x%zx,\"%s\");",
634template<
class Element>
638 Error(
"Print",
"Matrix is invalid");
643 const char *
format =
"%11.4g ";
661 printf(
"\n%dx%d matrix is as follows",fNrows,fNcols);
677 if (fNelems <= 0)
continue;
691template<
class Element>
696 if (val == 0. && fNelems == 0)
699 const Element *
ep = GetMatrixArray();
700 const Element *
const fp =
ep+fNelems;
701 for (;
ep < fp;
ep++)
711template<
class Element>
716 if (val == 0. && fNelems == 0)
719 const Element *
ep = GetMatrixArray();
720 const Element *
const fp =
ep+fNelems;
721 for (;
ep < fp;
ep++)
731template<
class Element>
736 const Element *
ep = GetMatrixArray();
737 const Element *
const fp =
ep+fNelems;
738 for (;
ep < fp;
ep++)
748template<
class Element>
753 const Element *
ep = GetMatrixArray();
754 const Element *
const fp =
ep+fNelems;
755 for (;
ep < fp;
ep++)
765template<
class Element>
770 const Element *
ep = GetMatrixArray();
771 const Element *
const fp =
ep+fNelems;
772 for (;
ep < fp;
ep++)
782template<
class Element>
787 const Element *
ep = GetMatrixArray();
788 const Element *
const fp =
ep+fNelems;
789 for (;
ep < fp;
ep++)
799template<
class Element>
804 Element *
ep = this->GetMatrixArray();
805 const Element *
const ep_last =
ep+fNelems;
816template<
class Element>
821 Element *
ep = this->GetMatrixArray();
834template<
class Element>
839 const Element
scale = beta-alpha;
840 const Element shift = alpha/
scale;
842 Element *
ep = GetMatrixArray();
843 const Element *
const fp =
ep+fNelems;
853template<
class Element>
857 return (
memcmp(m1.GetMatrixArray(),m2.GetMatrixArray(),
858 m1.GetNoElements()*
sizeof(Element)) == 0);
864template<
class Element>
868 ::Error(
"E2Norm",
"matrices not compatible");
872 const Element *
mp1 = m1.GetMatrixArray();
873 const Element *
mp2 = m2.GetMatrixArray();
874 const Element *
const fmp1 =
mp1+m1.GetNoElements();
886template<
class Element1,
class Element2>
891 ::Error(
"AreCompatible",
"matrix 1 not valid");
896 ::Error(
"AreCompatible",
"matrix 2 not valid");
900 if (m1.GetNrows() != m2.GetNrows() || m1.GetNcols() != m2.GetNcols() ||
901 m1.GetRowLwb() != m2.GetRowLwb() || m1.GetColLwb() != m2.GetColLwb()) {
903 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
913template<
class Element>
917 Error(
"Compare(const TMatrixTBase<Element> &,const TMatrixTBase<Element> &)",
"matrices are incompatible");
921 printf(
"\n\nComparison of two TMatrices:\n");
930 for (
Int_t i = m1.GetRowLwb(); i <= m1.GetRowUpb(); i++) {
931 for (
Int_t j = m1.GetColLwb();
j < m1.GetColUpb();
j++) {
932 const Element
mv1 = m1(i,
j);
933 const Element
mv2 = m2(i,
j);
951 printf(
"\n Matrix 1 element is \t\t%g",
mv1);
952 printf(
"\n Matrix 2 element is \t\t%g",
mv2);
954 printf(
"\n Relative error\t\t\t\t%g\n",
960 printf(
"\n||Matrix1-Matrix2||/sqrt(||Matrix1|| ||Matrix2||)\t%g\n\n",
967template<
class Element>
980 maxDevAllow = std::numeric_limits<Element>::epsilon();
982 for (
Int_t i =
m.GetRowLwb(); i <=
m.GetRowUpb(); i++) {
983 for (
Int_t j =
m.GetColLwb();
j <=
m.GetColUpb();
j++) {
1010template<
class Element>
1017 if (m1 == 0 && m2 == 0)
1025 maxDevAllow = std::numeric_limits<Element>::epsilon();
1027 for (
Int_t i = m1.GetRowLwb(); i <= m1.GetRowUpb(); i++) {
1028 for (
Int_t j = m1.GetColLwb();
j <= m1.GetColUpb();
j++) {
1042 printf(
"Largest dev for (%d,%d); dev = |%g - %g| = %g\n",
1056template<
class Element>
1059 if (
R__b.IsReading()) {
1065 Error(
"TMatrixTBase<Element>::Streamer",
"Unknown version number: %d",
R__v);
1068 if (
R__v < 4) MakeValid();
1075template<
class Element>
1084template<
class Element>
1095template Bool_t TMatrixTAutoloadOps::AreCompatible<Float_t,Float_t>
1097template Bool_t TMatrixTAutoloadOps::AreCompatible<Float_t,Double_t>
1110template Bool_t TMatrixTAutoloadOps::AreCompatible<Double_t,Double_t>
1112template Bool_t TMatrixTAutoloadOps::AreCompatible<Double_t,Float_t>
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
short Version_t
Class version identifier (short)
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
R__EXTERN Int_t gMatrixCheck
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Buffer base class used for serializing objects.
virtual Element Sum() const
Compute sum of elements.
virtual Element RowNorm() const
Row matrix norm, MAX{ SUM{ |M(i,j)|, over j}, over i}.
virtual Element ColNorm() const
Column matrix norm, MAX{ SUM{ |M(i,j)|, over i}, over j}.
virtual TMatrixTBase< Element > & Randomize(Element alpha, Element beta, Double_t &seed)
Randomize matrix element values.
virtual TMatrixTBase< Element > & Sqr()
Square each element of the matrix.
virtual TMatrixTBase< Element > & UnitMatrix()
Make a unit matrix (matrix need not be a square one).
Bool_t operator!=(Element val) const
Are all matrix elements not equal to val?
virtual TMatrixTBase< Element > & Zero()
Set matrix elements to zero.
void Print(Option_t *name="") const override
Print the matrix as a table of elements.
virtual Int_t NonZeros() const
Compute the number of elements != 0.0.
virtual Element E2Norm() const
Square of the Euclidean norm, SUM{ m(i,j)^2 }.
virtual TMatrixTBase< Element > & Apply(const TElementActionT< Element > &action)
Apply action to each matrix element.
virtual Element Min() const
return minimum matrix element value
virtual Element Max() const
return maximum vector element value
virtual void GetMatrix2Array(Element *data, Option_t *option="") const
Copy matrix data to array .
Bool_t operator<(Element val) const
Are all matrix elements < val?
void Draw(Option_t *option="") override
Draw this matrix The histogram is named "TMatrixT" by default and no title.
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.
static Element & NaNValue()
static void DoubleLexSort(Int_t n, Int_t *first, Int_t *second, Element *data)
default kTRUE, when Use array kFALSE
Bool_t operator>(Element val) const
Are all matrix elements > val?
virtual TMatrixTBase< Element > & Sqrt()
Take square root of all elements.
Bool_t operator==(Element val) const
Are all matrix elements equal to val?
virtual TMatrixTBase< Element > & Abs()
Take an absolute value of a matrix, i.e. apply Abs() to each element.
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.
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 <= val?
void Streamer(TBuffer &) override
Stream an object of class TMatrixTBase<Element>.
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
Copy array data to matrix .
Bool_t operator>=(Element val) const
Are all matrix elements >= val?
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 > & NormByDiag(const TVectorT< Element > &v, Option_t *option="D")
option:
void ToUpper()
Change string to upper case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Long64_t LocMin(Long64_t n, const T *a)
Returns index of array with the minimum element.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Long64_t LocMax(Long64_t n, const T *a)
Returns index of array with the maximum element.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
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 .
void Compare(const TMatrixTBase< Element > &m1, const TMatrixTBase< Element > &m2)
Compare two matrices and print out the result of the comparison.
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.
Bool_t operator==(const TMatrixTBase< Element > &m1, const TMatrixTBase< Element > &m2)
Check to see if two matrices are identical.
Element E2Norm(const TMatrixTBase< Element > &m1, const TMatrixTBase< Element > &m2)
Square of the Euclidean norm of the difference between two matrices.
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 .
static uint64_t sum(uint64_t i)