41template<
class Element>
44 const int incs[] = {1,5,19,41,109,209,505,929,2161,3905,8929,16001,
INT_MAX};
58 const Element tmp =
data[k];
65 first [
j] = first [
j-
inc];
66 second[
j] = second[
j-
inc];
80template<
class Element>
84 const int incs[] = {1,5,19,41,109,209,505,929,2161,3905,8929,16001,
INT_MAX};
131 second[
j] = second[
j-
inc];
187template<
class Element>
195 Element *
elem = GetMatrixArray();
215template<
class Element>
220 if ((fNrows != fNcols) || (fRowLwb != fColLwb))
223 const Element *
const elem = GetMatrixArray();
244template<
class Element>
252 const Element *
const elem = GetMatrixArray();
270template<
class Element>
279 Error(
"InsertRow",
"row %d out of matrix range",
rown);
284 Error(
"InsertRow",
"column %d out of matrix range",
coln);
289 Error(
"InsertRow",
"row length %d out of range",
nr);
295 Element *
const elem = GetMatrixArray()+off;
304template<
class Element>
313 Error(
"ExtractRow",
"row %d out of matrix range",
rown);
318 Error(
"ExtractRow",
"column %d out of matrix range",
coln);
323 Error(
"ExtractRow",
"row length %d out of range",
nr);
329 const Element *
const elem = GetMatrixArray()+off;
338template<
class Element>
350template<
class Element>
354 memset(this->GetMatrixArray(),0,fNelems*
sizeof(Element));
362template<
class Element>
367 Element *
ep = this->GetMatrixArray();
368 const Element *
const fp =
ep+fNelems;
380template<
class Element>
385 Element *
ep = this->GetMatrixArray();
386 const Element *
const fp =
ep+fNelems;
398template<
class Element>
403 Element *
ep = this->GetMatrixArray();
404 const Element *
const fp =
ep+fNelems;
416template<
class Element>
421 Element *
ep = this->GetMatrixArray();
422 memset(
ep,0,fNelems*
sizeof(Element));
423 for (
Int_t i = fRowLwb; i <= fRowLwb+fNrows-1; i++)
424 for (
Int_t j = fColLwb;
j <= fColLwb+fNcols-1;
j++)
425 *
ep++ = (i==
j ? 1.0 : 0.0);
435template<
class Element>
443 if (
v.GetNoElements() <
nMax) {
444 Error(
"NormByDiag",
"vector shorter than matrix diagonal");
453 const Element *
pV =
v.GetMatrixArray();
454 Element *
mp = this->GetMatrixArray();
464 Error(
"NormbyDiag",
"vector element %d is zero",
icol);
469 Error(
"NormbyDiag",
"vector element %d is zero",
irow);
489template<
class Element>
494 const Element *
ep = GetMatrixArray();
495 const Element *
const fp =
ep+fNelems;
516template<
class Element>
521 const Element *
ep = GetMatrixArray();
522 const Element *
const fp =
ep+fNcols;
529 for (
Int_t i = 0; i < fNrows; i++,
ep += fNcols)
543template<
class Element>
548 const Element *
ep = GetMatrixArray();
549 const Element *
const fp =
ep+fNelems;
552 for ( ;
ep < fp;
ep++)
553 sum += (*
ep) * (*ep);
561template<
class Element>
567 const Element *
ep = this->GetMatrixArray();
568 const Element *
const fp =
ep+fNelems;
578template<
class Element>
584 const Element *
ep = this->GetMatrixArray();
585 const Element *
const fp =
ep+fNelems;
595template<
class Element>
600 const Element *
const ep = this->GetMatrixArray();
608template<
class Element>
613 const Element *
const ep = this->GetMatrixArray();
622template<
class Element>
625 gROOT->ProcessLine(
Form(
"THistPainter::PaintSpecialObjects((TObject*)0x%zx,\"%s\");",
635template<
class Element>
639 Error(
"Print",
"Matrix is invalid");
644 const char *
format =
"%11.4g ";
662 printf(
"\n%dx%d matrix is as follows",fNrows,fNcols);
678 if (fNelems <= 0)
continue;
692template<
class Element>
697 if (val == 0. && fNelems == 0)
700 const Element *
ep = GetMatrixArray();
701 const Element *
const fp =
ep+fNelems;
702 for (;
ep < fp;
ep++)
712template<
class Element>
717 if (val == 0. && fNelems == 0)
720 const Element *
ep = GetMatrixArray();
721 const Element *
const fp =
ep+fNelems;
722 for (;
ep < fp;
ep++)
732template<
class Element>
737 const Element *
ep = GetMatrixArray();
738 const Element *
const fp =
ep+fNelems;
739 for (;
ep < fp;
ep++)
749template<
class Element>
754 const Element *
ep = GetMatrixArray();
755 const Element *
const fp =
ep+fNelems;
756 for (;
ep < fp;
ep++)
766template<
class Element>
771 const Element *
ep = GetMatrixArray();
772 const Element *
const fp =
ep+fNelems;
773 for (;
ep < fp;
ep++)
783template<
class Element>
788 const Element *
ep = GetMatrixArray();
789 const Element *
const fp =
ep+fNelems;
790 for (;
ep < fp;
ep++)
800template<
class Element>
805 Element *
ep = this->GetMatrixArray();
806 const Element *
const ep_last =
ep+fNelems;
817template<
class Element>
822 Element *
ep = this->GetMatrixArray();
835template<
class Element>
840 const Element
scale = beta-alpha;
841 const Element shift = alpha/
scale;
843 Element *
ep = GetMatrixArray();
844 const Element *
const fp =
ep+fNelems;
854template<
class Element>
858 return (
memcmp(m1.GetMatrixArray(),m2.GetMatrixArray(),
859 m1.GetNoElements()*
sizeof(Element)) == 0);
865template<
class Element>
869 ::Error(
"E2Norm",
"matrices not compatible");
873 const Element *
mp1 = m1.GetMatrixArray();
874 const Element *
mp2 = m2.GetMatrixArray();
875 const Element *
const fmp1 =
mp1+m1.GetNoElements();
887template<
class Element1,
class Element2>
892 ::Error(
"AreCompatible",
"matrix 1 not valid");
897 ::Error(
"AreCompatible",
"matrix 2 not valid");
901 if (m1.GetNrows() != m2.GetNrows() || m1.GetNcols() != m2.GetNcols() ||
902 m1.GetRowLwb() != m2.GetRowLwb() || m1.GetColLwb() != m2.GetColLwb()) {
904 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
914template<
class Element>
918 Error(
"Compare(const TMatrixTBase<Element> &,const TMatrixTBase<Element> &)",
"matrices are incompatible");
922 printf(
"\n\nComparison of two TMatrices:\n");
931 for (
Int_t i = m1.GetRowLwb(); i <= m1.GetRowUpb(); i++) {
932 for (
Int_t j = m1.GetColLwb();
j < m1.GetColUpb();
j++) {
933 const Element
mv1 = m1(i,
j);
934 const Element
mv2 = m2(i,
j);
952 printf(
"\n Matrix 1 element is \t\t%g",
mv1);
953 printf(
"\n Matrix 2 element is \t\t%g",
mv2);
955 printf(
"\n Relative error\t\t\t\t%g\n",
961 printf(
"\n||Matrix1-Matrix2||/sqrt(||Matrix1|| ||Matrix2||)\t%g\n\n",
968template<
class Element>
981 maxDevAllow = std::numeric_limits<Element>::epsilon();
983 for (
Int_t i =
m.GetRowLwb(); i <=
m.GetRowUpb(); i++) {
984 for (
Int_t j =
m.GetColLwb();
j <=
m.GetColUpb();
j++) {
1011template<
class Element>
1018 if (m1 == 0 && m2 == 0)
1026 maxDevAllow = std::numeric_limits<Element>::epsilon();
1028 for (
Int_t i = m1.GetRowLwb(); i <= m1.GetRowUpb(); i++) {
1029 for (
Int_t j = m1.GetColLwb();
j <= m1.GetColUpb();
j++) {
1043 printf(
"Largest dev for (%d,%d); dev = |%g - %g| = %g\n",
1057template<
class Element>
1060 if (
R__b.IsReading()) {
1066 Error(
"TMatrixTBase<Element>::Streamer",
"Unknown version number: %d",
R__v);
1069 if (
R__v < 4) MakeValid();
1076template<
class Element>
1085template<
class Element>
1096template Bool_t TMatrixTAutoloadOps::AreCompatible<Float_t,Float_t>
1098template Bool_t TMatrixTAutoloadOps::AreCompatible<Float_t,Double_t>
1111template Bool_t TMatrixTAutoloadOps::AreCompatible<Double_t,Double_t>
1113template Bool_t TMatrixTAutoloadOps::AreCompatible<Double_t,Float_t>
#define templateClassImp(name)
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)