37 template<class Element>
46 template<
class Element>
49 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb,1);
60 template<
class Element>
70 template<
class Element>
72 const Element *elements,
Option_t *option)
74 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb);
81 template<
class Element>
92 template<
class Element>
103 template<
class Element>
116 template<
class Element>
154 TMult(prototype,prototype);
158 Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
167 template<
class Element>
215 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
224 template<
class Element>
272 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
281 template<
class Element>
329 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
338 template<
class Element>
386 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
393 template<
class Element>
399 lazy_constructor.
FillIn(*
this);
405 template<
class Element>
419 template<
class Element>
422 if (size == 0)
return 0;
427 Element *heap =
new Element[size];
437 template<
class Element>
441 if (copySize == 0 || oldp == newp)
447 for (
Int_t i = copySize-1; i >= 0; i--)
450 for (
Int_t i = 0; i < copySize; i++)
455 memcpy(newp,oldp,copySize*
sizeof(Element));
464 template<
class Element>
477 if (no_rows < 0 || no_cols < 0)
479 Error(
"Allocate",
"no_rows=%d no_cols=%d",no_rows,no_cols);
502 template<
class Element>
507 Error(
"Plus",
"matrices not compatible");
512 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
517 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
525 const Element *
const cp_last = cp+this->
fNelems;
527 while (cp < cp_last) {
536 template<
class Element>
541 Error(
"Plus",
"matrices not compatible");
546 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
551 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
559 const Element *
const cp_last = cp+this->
fNelems;
561 while (cp < cp_last) {
570 template<
class Element>
575 Error(
"Minus",
"matrices not compatible");
580 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
585 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
593 const Element *
const cp_last = cp+this->
fNelems;
595 while (cp < cp_last) {
604 template<
class Element>
609 Error(
"Minus",
"matrices not compatible");
614 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
619 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
627 const Element *
const cp_last = cp+this->
fNelems;
629 while (cp < cp_last) {
638 template<
class Element>
643 Error(
"Mult",
"A rows and B columns incompatible");
648 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
653 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
662 if (
typeid(Element) ==
typeid(
Double_t))
665 else if (
typeid(Element) !=
typeid(
Float_t))
669 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
679 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
687 template<
class Element>
694 Error(
"Mult",
"A rows and B columns incompatible");
699 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
704 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
713 if (
typeid(Element) ==
typeid(
Double_t))
714 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
716 else if (
typeid(Element) !=
typeid(
Float_t))
717 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
720 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
730 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
739 template<
class Element>
746 Error(
"Mult",
"A rows and B columns incompatible");
751 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
756 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
765 if (
typeid(Element) ==
typeid(
Double_t))
766 cblas_dsymm (CblasRowMajor,CblasRight,CblasUpper,
fNrows,
fNcols,1.0,
768 else if (
typeid(Element) !=
typeid(
Float_t))
769 cblas_ssymm (CblasRowMajor,CblasRight,CblasUpper,
fNrows,
fNcols,1.0,
772 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
782 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
791 template<
class Element>
798 Error(
"Mult",
"A rows and B columns incompatible");
803 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
808 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
817 if (
typeid(Element) ==
typeid(
Double_t))
818 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
820 else if (
typeid(Element) !=
typeid(
Float_t))
821 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
824 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
834 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
842 template<
class Element>
849 Error(
"TMult",
"A rows and B columns incompatible");
854 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
859 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
868 if (
typeid(Element) ==
typeid(
Double_t))
871 else if (
typeid(Element) !=
typeid(
Float_t))
875 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
884 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
892 template<
class Element>
899 Error(
"TMult",
"A rows and B columns incompatible");
904 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
909 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
918 if (
typeid(Element) ==
typeid(
Double_t))
921 else if (
typeid(Element) !=
typeid(
Float_t))
925 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
934 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
941 template<
class Element>
949 Error(
"MultT",
"A rows and B columns incompatible");
954 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
959 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
968 if (
typeid(Element) ==
typeid(
Double_t))
971 else if (
typeid(Element) !=
typeid(
Float_t))
975 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
985 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
993 template<
class Element>
1000 Error(
"MultT",
"A rows and B columns incompatible");
1005 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1010 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1019 if (
typeid(Element) ==
typeid(
Double_t))
1022 else if (
typeid(Element) !=
typeid(
Float_t))
1026 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
1036 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1043 template<
class Element>
1048 if (row_upb < row_lwb)
1050 Error(
"Use",
"row_upb=%d < row_lwb=%d",row_upb,row_lwb);
1053 if (col_upb < col_lwb)
1055 Error(
"Use",
"col_upb=%d < col_lwb=%d",col_upb,col_lwb);
1061 this->
fNrows = row_upb-row_lwb+1;
1062 this->
fNcols = col_upb-col_lwb+1;
1079 template<
class Element>
1086 Error(
"GetSub",
"row_lwb out of bounds");
1090 Error(
"GetSub",
"col_lwb out of bounds");
1094 Error(
"GetSub",
"row_upb out of bounds");
1098 Error(
"GetSub",
"col_upb out of bounds");
1101 if (row_upb < row_lwb || col_upb < col_lwb) {
1102 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1111 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1112 const Int_t row_upb_sub = (shift) ? row_upb-row_lwb : row_upb;
1113 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1114 const Int_t col_upb_sub = (shift) ? col_upb-col_lwb : col_upb;
1116 target.
ResizeTo(row_lwb_sub,row_upb_sub,col_lwb_sub,col_upb_sub);
1117 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
1118 const Int_t ncols_sub = col_upb_sub-col_lwb_sub+1;
1121 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1122 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1123 target(irow+row_lwb_sub,icol+col_lwb_sub) = (*this)(row_lwb+irow,col_lwb+icol);
1130 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1131 const Element *ap_sub = ap;
1132 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1146 template<
class Element>
1154 Error(
"SetSub",
"row_lwb outof bounds");
1158 Error(
"SetSub",
"col_lwb outof bounds");
1163 Error(
"SetSub",
"source matrix too large");
1174 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1175 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1176 (*this)(row_lwb+irow,col_lwb+icol) = source(rowlwb_s+irow,collwb_s+icol);
1183 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1184 Element *ap_sub = ap;
1185 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1200 template<
class Element>
1205 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1212 else if (nrows == 0 || ncols == 0) {
1230 memset(elements_new,0,this->
fNelems*
sizeof(Element));
1231 else if (this->
fNelems > nelems_old)
1232 memset(elements_new+nelems_old,0,(this->
fNelems-nelems_old)*
sizeof(Element));
1239 if (ncols_old < this->
fNcols) {
1240 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1241 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1242 nelems_new,nelems_old);
1244 memset(elements_new+i*this->fNcols+ncols_copy,0,(this->fNcols-ncols_copy)*
sizeof(Element));
1247 for (
Int_t i = 0; i < nrows_copy; i++)
1248 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1249 nelems_new,nelems_old);
1265 template<
class Element>
1271 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1275 const Int_t new_nrows = row_upb-row_lwb+1;
1276 const Int_t new_ncols = col_upb-col_lwb+1;
1280 if (this->
fNrows == new_nrows && this->
fNcols == new_ncols &&
1283 else if (new_nrows == 0 || new_ncols == 0) {
1297 Allocate(new_nrows,new_ncols,row_lwb,col_lwb);
1304 memset(elements_new,0,this->
fNelems*
sizeof(Element));
1305 else if (this->
fNelems > nelems_old)
1306 memset(elements_new+nelems_old,0,(this->
fNelems-nelems_old)*
sizeof(Element));
1314 const Int_t nrows_copy = rowUpb_copy-rowLwb_copy+1;
1315 const Int_t ncols_copy = colUpb_copy-colLwb_copy+1;
1317 if (nrows_copy > 0 && ncols_copy > 0) {
1318 const Int_t colOldOff = colLwb_copy-colLwb_old;
1320 if (ncols_old < this->
fNcols) {
1321 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1322 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1324 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1325 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->
fNelems,nelems_old);
1327 memset(elements_new+iRowNew*this->fNcols+colNewOff+ncols_copy,0,
1328 (this->fNcols-ncols_copy)*
sizeof(Element));
1331 for (
Int_t i = 0; i < nrows_copy; i++) {
1332 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1334 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1335 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->
fNelems,nelems_old);
1342 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1);
1351 template<
class Element>
1364 template<
class Element>
1386 template<
class Element>
1400 template<
class Element>
1410 Error(
"Invert()",
"matrix should be square");
1414 Error(
"InvertFast",
"matrix is singular");
1426 TMatrixTCramerInv::Inv2x2<Element>(*
this,det);
1431 TMatrixTCramerInv::Inv3x3<Element>(*
this,det);
1436 TMatrixTCramerInv::Inv4x4<Element>(*
this,det);
1441 TMatrixTCramerInv::Inv5x5<Element>(*
this,det);
1446 TMatrixTCramerInv::Inv6x6<Element>(*
this,det);
1459 template<
class Element>
1472 const Element tmp = ap[off_i+j];
1473 ap[off_i+j] = ap[off_j+i];
1489 const Int_t off = (icol-collwb_old)*ncols_old;
1490 (*this)(irow,icol) = oldElems[off+irow-rowlwb_old];
1499 Error(
"Transpose",
"matrix has wrong shape");
1504 const Element *scp = sp1;
1510 while (tp < tp_last) {
1511 const Element *sp2 = scp++;
1514 while (sp2 < sp1+this->
fNelems) {
1529 template<
class Element>
1536 Error(
"Rank1Update",
"vector too short");
1545 const Element tmp = alpha*pv[i];
1557 template<
class Element>
1565 Error(
"Rank1Update",
"vector v1 too short");
1570 Error(
"Rank1Update",
"vector v2 too short");
1580 const Element tmp = alpha*pv1[i];
1582 *mp++ += tmp*pv2[j];
1591 template<
class Element>
1598 Error(
"Similarity(const TVectorT &)",
"matrix is not square");
1603 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1612 const Element *
const vp_first = vp;
1613 const Element *
const vp_last = vp+v.
GetNrows();
1614 while (vp < vp_last) {
1616 for (
const Element *sp = vp_first; sp < vp_last; )
1617 sum2 += *mp++ * *sp++;
1618 sum1 += sum2 * *vp++;
1632 template<
class Element>
1639 Error(
"NormByColumn",
"vector shorter than matrix column");
1650 const Element *
const mp_last = mp+this->
fNelems;
1653 for ( ; mp < mp_last; pv++) {
1665 for ( ; mp < mp_last; pv++)
1679 template<
class Element>
1686 Error(
"NormByRow",
"vector shorter than matrix column");
1696 const Element *pv = pv0;
1698 const Element *
const mp_last = mp+this->
fNelems;
1701 for ( ; mp < mp_last; pv = pv0 )
1706 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv-pv0));
1711 for ( ; mp < mp_last; pv = pv0 )
1722 template<
class Element>
1726 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1741 template<
class Element>
1745 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1760 template<
class Element>
1766 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1780 for (
Int_t irow = 0; irow < this->
fNrows; irow++ ) {
1782 const Int_t sIndex = pRowIndex[irow];
1783 const Int_t eIndex = pRowIndex[irow+1];
1784 for (
Int_t index = sIndex; index < eIndex; index++)
1785 tp[off+pColIndex[index]] = sp[index];
1795 template<
class Element>
1804 Error(
"operator=(const TMatrixTLazy&)",
"matrix is incompatible with " 1805 "the assigned Lazy matrix");
1809 lazy_constructor.
FillIn(*
this);
1816 template<
class Element>
1822 const Element *
const ep_last = ep+this->
fNelems;
1823 while (ep < ep_last)
1832 template<
class Element>
1838 const Element *
const ep_last = ep+this->
fNelems;
1839 while (ep < ep_last)
1848 template<
class Element>
1854 const Element *
const ep_last = ep+this->
fNelems;
1855 while (ep < ep_last)
1864 template<
class Element>
1870 const Element *
const ep_last = ep+this->
fNelems;
1871 while (ep < ep_last)
1880 template<
class Element>
1884 Error(
"operator+=(const TMatrixT &)",
"matrices not compatible");
1890 const Element *
const tp_last = tp+this->
fNelems;
1891 while (tp < tp_last)
1900 template<
class Element>
1904 Error(
"operator+=(const TMatrixTSym &)",
"matrices not compatible");
1910 const Element *
const tp_last = tp+this->
fNelems;
1911 while (tp < tp_last)
1920 template<
class Element>
1924 Error(
"operator=-(const TMatrixT &)",
"matrices not compatible");
1930 const Element *
const tp_last = tp+this->
fNelems;
1931 while (tp < tp_last)
1940 template<
class Element>
1944 Error(
"operator=-(const TMatrixTSym &)",
"matrices not compatible");
1950 const Element *
const tp_last = tp+this->
fNelems;
1951 while (tp < tp_last)
1962 template<
class Element>
1970 Error(
"operator*=(const TMatrixT &)",
"source matrix has wrong shape");
1989 Element *trp = work;
1991 isAllocated =
kTRUE;
1992 trp =
new Element[this->
fNcols];
1996 const Element *trp0 = cp;
1997 const Element *
const trp0_last = trp0+this->
fNelems;
1998 while (trp0 < trp0_last) {
1999 memcpy(trp,trp0,this->
fNcols*
sizeof(Element));
2000 for (
const Element *scp = sp; scp < sp+this->
fNcols; ) {
2004 cij += trp[j] * *scp;
2014 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2025 template<
class Element>
2032 Error(
"operator*=(const TMatrixTSym &)",
"source matrix has wrong shape");
2051 Element *trp = work;
2053 isAllocated =
kTRUE;
2054 trp =
new Element[this->
fNcols];
2058 const Element *trp0 = cp;
2059 const Element *
const trp0_last = trp0+this->
fNelems;
2060 while (trp0 < trp0_last) {
2061 memcpy(trp,trp0,this->
fNcols*
sizeof(Element));
2062 for (
const Element *scp = sp; scp < sp+this->
fNcols; ) {
2066 cij += trp[j] * *scp;
2076 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2087 template<
class Element>
2094 Error(
"operator*=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2100 const Element *
const mp_last = mp+this->
fNelems;
2102 while (mp < mp_last) {
2103 const Element *dp = diag.
GetPtr();
2117 template<
class Element>
2124 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2130 const Element *
const mp_last = mp+this->
fNelems;
2132 while (mp < mp_last) {
2133 const Element *dp = diag.
GetPtr();
2138 Error(
"operator/=",
"%d-diagonal element is zero",j);
2152 template<
class Element>
2161 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2168 const Element *
const mp_last = mp+this->
fNelems;
2169 const Element *cp = col.
GetPtr();
2171 while (mp < mp_last) {
2185 template<
class Element>
2194 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2201 const Element *
const mp_last = mp+this->
fNelems;
2202 const Element *cp = col.
GetPtr();
2204 while (mp < mp_last) {
2211 Error(
"operator/=",
"%d-row of matrix column is zero",icol);
2224 template<
class Element>
2233 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2240 const Element *
const mp_last = mp+this->
fNelems;
2242 while (mp < mp_last) {
2243 const Element *rp = row.
GetPtr();
2258 template<
class Element>
2266 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2272 const Element *
const mp_last = mp+this->
fNelems;
2274 while (mp < mp_last) {
2275 const Element *rp = row.
GetPtr();
2281 Error(
"operator/=",
"%d-col of matrix row is zero",j);
2297 template<
class Element>
2301 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2311 template<
class Element>
2322 template<
class Element>
2333 template<
class Element>
2342 template<
class Element>
2353 template<
class Element>
2362 template<
class Element>
2373 template<
class Element>
2384 template<
class Element>
2387 return Element(-1.0)*(
operator-(source2,source1));
2393 template<
class Element>
2404 template<
class Element>
2407 return Element(-1.0)*
operator-(source,val);
2413 template<
class Element>
2424 template<
class Element>
2433 template<
class Element>
2443 template<
class Element>
2453 template<
class Element>
2463 template<
class Element>
2473 template<
class Element>
2479 Error(
"operator&&(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2489 while (tp < tp_last)
2490 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2498 template<
class Element>
2504 Error(
"operator&&(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2514 while (tp < tp_last)
2515 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2523 template<
class Element>
2532 template<
class Element>
2538 Error(
"operator||(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2548 while (tp < tp_last)
2549 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2557 template<
class Element>
2563 Error(
"operator||(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2573 while (tp < tp_last)
2574 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2582 template<
class Element>
2591 template<
class Element>
2597 Error(
"operator|(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2607 while (tp < tp_last) {
2608 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2617 template<
class Element>
2623 Error(
"operator>(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2633 while (tp < tp_last) {
2634 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2643 template<
class Element>
2652 template<
class Element>
2658 Error(
"operator>=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2668 while (tp < tp_last) {
2669 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2678 template<
class Element>
2684 Error(
"operator>=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2694 while (tp < tp_last) {
2695 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2704 template<
class Element>
2713 template<
class Element>
2719 Error(
"operator<=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2726 const Element *sp2 = source2.GetMatrixArray();
2729 while (tp < tp_last) {
2730 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2739 template<
class Element>
2745 Error(
"operator<=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2752 const Element *sp2 = source2.GetMatrixArray();
2755 while (tp < tp_last) {
2756 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2765 template<
class Element>
2774 template<
class Element>
2780 Error(
"operator<(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2785 const Element *sp2 = source2.GetMatrixArray();
2788 while (tp < tp_last) {
2789 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2798 template<
class Element>
2804 Error(
"operator<(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2811 const Element *sp2 = source2.GetMatrixArray();
2814 while (tp < tp_last) {
2815 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2824 template<
class Element>
2833 template<
class Element>
2839 Error(
"operator!=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2849 while (tp != tp_last) {
2850 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2859 template<
class Element>
2865 Error(
"operator!=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2875 while (tp != tp_last) {
2876 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2885 template<
class Element>
2895 template<class Element>
2896 TMatrixT<Element> operator!=(const TMatrixT<Element> &source1,Element val)
2898 TMatrixT<Element> target; target.ResizeTo(source1);
2900 const Element *sp = source1.GetMatrixArray();
2901 Element *tp = target.GetMatrixArray();
2902 const Element * const tp_last = tp+target.GetNoElements();
2903 while (tp != tp_last) {
2904 *tp++ = (*sp != val); sp++;
2913 template<class Element>
2914 TMatrixT<Element> operator!=(Element val,const TMatrixT<Element> &source1)
2916 return operator!=(source1,val);
2923 template<
class Element>
2927 ::Error(
"Add(TMatrixT &,Element,const TMatrixT &)",
"matrices not compatible");
2936 *tp++ = scalar * (*sp++);
2937 }
else if (scalar == 1.) {
2942 *tp++ += scalar * (*sp++);
2951 template<
class Element>
2955 ::Error(
"Add(TMatrixT &,Element,const TMatrixTSym &)",
"matrices not compatible");
2963 *tp++ += scalar * (*sp++);
2971 template<
class Element>
2975 ::Error(
"ElementMult(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2991 template<
class Element>
2995 ::Error(
"ElementMult(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3011 template<
class Element>
3015 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3022 while ( tp < ftp ) {
3028 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3039 template<
class Element>
3043 ::Error(
"ElementDiv(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3050 while ( tp < ftp ) {
3056 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3067 template<
class Element>
3069 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3071 const Element *arp0 = ap;
3072 while (arp0 < ap+na) {
3073 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
3074 const Element *arp = arp0;
3076 while (bcp < bp+nb) {
3077 cij += *arp++ * *bcp;
3090 template<
class Element>
3092 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3094 const Element *acp0 = ap;
3095 while (acp0 < ap+ncolsa) {
3096 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
3097 const Element *acp = acp0;
3099 while (bcp < bp+nb) {
3114 template<
class Element>
3116 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3118 const Element *arp0 = ap;
3119 while (arp0 < ap+na) {
3120 const Element *brp0 = bp;
3121 while (brp0 < bp+nb) {
3122 const Element *arp = arp0;
3123 const Element *brp = brp0;
3125 while (brp < brp0+ncolsb)
3126 cij += *arp++ * *brp++;
3137 template<
class Element>
3146 }
else if (R__v == 2) {
3148 TObject::Streamer(R__b);
3158 if (this->fNelems > 0) {
3166 TObject::Streamer(R__b);
3203 #ifndef ROOT_TMatrixFfwd 3206 #ifndef ROOT_TMatrixFSymfwd 3262 #ifndef ROOT_TMatrixDfwd 3265 #ifndef ROOT_TMatrixDSymfwd
TMatrixT< Element > & operator+=(Element val)
Add val to every element of the matrix.
virtual TMatrixTBase< Element > & UnitMatrix()
Make a unit matrix (matrix need not be a square one).
virtual const Element * GetMatrixArray() const =0
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
virtual const Element * GetMatrixArray() const
TMatrixT< Element > & NormByColumn(const TVectorT< Element > &v, Option_t *option="D")
Multiply/divide matrix columns by a vector: option: "D" : b(i,j) = a(i,j)/v(i) i = 0...
template TMatrixD & Add< Double_t >(TMatrixD &target, Double_t scalar, const TMatrixD &source)
const Element * GetPtr() const
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
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.
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
TMatrixT< Element > & Transpose(const TMatrixT< Element > &source)
Transpose matrix source.
TMatrixT< Element > & ElementMult(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Multiply target by the source, element-by-element.
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
Copy array data to matrix .
virtual const Int_t * GetRowIndexArray() const
Bool_t operator!=(Element val) const
Are all matrix elements not equal to val?
TMatrixT< Element > & ElementDiv(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Divide target by the source, element-by-element.
virtual const Element * GetMatrixArray() const
TMatrixT< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
template TMatrixD & ElementDiv< Double_t >(TMatrixD &target, const TMatrixD &source)
template void AtMultB< Float_t >(const Float_t *const ap, Int_t ncolsa, const Float_t *const bp, Int_t nb, Int_t ncolsb, Float_t *cp)
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
void AtMultB(const Element *const ap, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A^T*B.
template TMatrixF & ElementDiv< Float_t >(TMatrixF &target, const TMatrixF &source)
static Bool_t InvertLU(TMatrixD &a, Double_t tol, Double_t *det=0)
Calculate matrix inversion through in place forward/backward substitution.
template TMatrixF & ElementMult< Float_t >(TMatrixF &target, const TMatrixF &source)
Short_t Min(Short_t a, Short_t b)
virtual void Det(Double_t &d1, Double_t &d2)
Calculate determinant det = d1*TMath::Power(2.,d2)
template TMatrixF & Add< Float_t >(TMatrixF &target, Float_t scalar, const TMatrixF &source)
Bool_t operator>(Element val) const
Are all matrix elements > val?
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.
virtual const Element * GetMatrixArray() const
virtual Double_t Determinant() const
Return the matrix determinant.
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1)=0
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
const Element * GetPtr() const
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Int_t GetNoElements() const
Bool_t operator<(Element val) const
Are all matrix elements < val?
template TMatrixF operator<=< Float_t >(const TMatrixF &source1, const TMatrixF &source2)
template void AtMultB< Double_t >(const Double_t *const ap, Int_t ncolsa, const Double_t *const bp, Int_t nb, Int_t ncolsb, Double_t *cp)
template TMatrixD & ElementMult< Double_t >(TMatrixD &target, const TMatrixD &source)
void Minus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Create a matrix C such that C = A - B.
#define templateClassImp(name)
const Element * GetPtr() const
template void AMultB< Float_t >(const Float_t *const ap, Int_t na, Int_t ncolsa, const Float_t *const bp, Int_t nb, Int_t ncolsb, Float_t *cp)
void AMultBt(const Element *const ap, Int_t na, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A*B^T.
void MultT(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B^T.
Bool_t operator>=(Element val) const
Are all matrix elements >= val?
Element * New_m(Int_t size)
Return data pointer .
TMatrixT< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
template void AMultB< Double_t >(const Double_t *const ap, Int_t na, Int_t ncolsa, const Double_t *const bp, Int_t nb, Int_t ncolsb, Double_t *cp)
TMatrixT< Element > & operator/=(const TMatrixTDiag_const< Element > &diag)
Divide a matrix row by the diagonal of another matrix matrix(i,j) /= diag(j)
TObject & operator=(const TObject &rhs)
TObject assignment operator.
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 .
void TMult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
Create a matrix C such that C = A' * B.
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
Element * fElements
data container
Element * GetMatrixArray()
TMatrixT< Element > & Rank1Update(const TVectorT< Element > &v, Element alpha=1.0)
Perform a rank 1 operation on matrix A: A += alpha * v * v^T.
template void AMultBt< Float_t >(const Float_t *const ap, Int_t na, Int_t ncolsa, const Float_t *const bp, Int_t nb, Int_t ncolsb, Float_t *cp)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TMatrixT< Element > & NormByRow(const TVectorT< Element > &v, Option_t *option="D")
Multiply/divide matrix rows with a vector: option: "D" : b(i,j) = a(i,j)/v(j) i = 0...
Int_t GetNoElements() const
virtual TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source)
Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part [row_lwb...
Bool_t operator<=(Element val) const
Are all matrix elements <= val?
R__EXTERN Int_t gMatrixCheck
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
const TMatrixTBase< Element > * GetMatrix() const
virtual const Int_t * GetColIndexArray() const
TMatrixT< Element > operator*(Element val, const TMatrixT< Element > &source)
operation this = val*source
const TMatrixD & GetEigenVectors() const
virtual void FillIn(TMatrixT< Element > &m) const =0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
Element fDataStack[TMatrixTBase< Element >::kSizeMax]
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 .
virtual void Clear(Option_t *="")
TMatrixT< Element > & operator=(const TMatrixT< Element > &source)
Assignment operator.
template void AMultBt< Double_t >(const Double_t *const ap, Int_t na, Int_t ncolsa, const Double_t *const bp, Int_t nb, Int_t ncolsb, Double_t *cp)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
const TMatrixTBase< Element > * GetMatrix() const
TCppObject_t Allocate(TCppType_t type)
TMatrixT< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Element *data)
Use the array data to fill the matrix ([row_lwb..row_upb] x [col_lwb..col_upb])
const TMatrixTBase< Element > * GetMatrix() const
void Plus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Create a matrix C such that C = A + B.
const TVectorD & GetEigenValuesRe() const
template TMatrixD operator<=< Double_t >(const TMatrixD &source1, const TMatrixD &source2)
Short_t Max(Short_t a, Short_t b)
TMatrixT< Element > & InvertFast(Double_t *det=0)
Invert the matrix and calculate its determinant, however upto (6x6) a fast Cramer inversion is used ...
TMatrixT< Element > operator+(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1+source2
TMatrixT< Element > operator-(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1-source2
const TMatrixT< Element > EigenVectors(TVectorT< Element > &eigenValues) const
Return a matrix containing the eigen-vectors ordered by descending values of Re^2+Im^2 of the complex...
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B.
TMatrixT< Element > operator||(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical OR.
Element SetTol(Element tol)
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
Get submatrix [row_lwb..row_upb] x [col_lwb..col_upb]; The indexing range of the returned matrix depe...
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual const Int_t * GetColIndexArray() const =0
TMatrixT< Element > operator &&(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical AND.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual const Int_t * GetRowIndexArray() const =0
void AMultB(const Element *const ap, Int_t na, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A*B.
virtual Int_t ReadArray(Bool_t *&b)=0