38 template<
class Element>
47 template<
class Element>
50 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb,1);
61 template<
class Element>
71 template<
class Element>
73 const Element *elements,
Option_t *option)
75 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb);
82 template<
class Element>
93 template<
class Element>
104 template<
class Element>
117 template<
class Element>
147 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
155 TMult(prototype,prototype);
159 Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
168 template<
class Element>
194 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
216 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
225 template<
class Element>
251 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
273 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
282 template<
class Element>
308 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
330 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
339 template<
class Element>
365 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
387 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
394 template<
class Element>
400 lazy_constructor.
FillIn(*
this);
406 template<
class Element>
420 template<
class Element>
423 if (size == 0)
return 0;
428 Element *heap =
new Element[size];
438 template<
class Element>
442 if (copySize == 0 || oldp == newp)
448 for (
Int_t i = copySize-1; i >= 0; i--)
451 for (
Int_t i = 0; i < copySize; i++)
456 memcpy(newp,oldp,copySize*
sizeof(Element));
465 template<
class Element>
478 if (no_rows < 0 || no_cols < 0)
480 Error(
"Allocate",
"no_rows=%d no_cols=%d",no_rows,no_cols);
495 Error(
"Allocate",
"too large: no_rows=%d no_cols=%d",no_rows,no_cols);
511 template<
class Element>
516 Error(
"Plus",
"matrices not compatible");
521 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
526 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
534 const Element *
const cp_last = cp+this->
fNelems;
536 while (cp < cp_last) {
545 template<
class Element>
550 Error(
"Plus",
"matrices not compatible");
555 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
560 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
568 const Element *
const cp_last = cp+this->
fNelems;
570 while (cp < cp_last) {
579 template<
class Element>
584 Error(
"Minus",
"matrices not compatible");
589 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
594 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
602 const Element *
const cp_last = cp+this->
fNelems;
604 while (cp < cp_last) {
613 template<
class Element>
618 Error(
"Minus",
"matrices not compatible");
623 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
628 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
636 const Element *
const cp_last = cp+this->
fNelems;
638 while (cp < cp_last) {
647 template<
class Element>
652 Error(
"Mult",
"A rows and B columns incompatible");
657 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
662 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
671 if (
typeid(Element) ==
typeid(
Double_t))
674 else if (
typeid(Element) !=
typeid(
Float_t))
678 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
688 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
696 template<
class Element>
703 Error(
"Mult",
"A rows and B columns incompatible");
708 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
713 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
722 if (
typeid(Element) ==
typeid(
Double_t))
723 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
725 else if (
typeid(Element) !=
typeid(
Float_t))
726 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
729 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
739 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
748 template<
class Element>
755 Error(
"Mult",
"A rows and B columns incompatible");
760 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
765 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
774 if (
typeid(Element) ==
typeid(
Double_t))
775 cblas_dsymm (CblasRowMajor,CblasRight,CblasUpper,
fNrows,
fNcols,1.0,
777 else if (
typeid(Element) !=
typeid(
Float_t))
778 cblas_ssymm (CblasRowMajor,CblasRight,CblasUpper,
fNrows,
fNcols,1.0,
781 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
791 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
800 template<
class Element>
807 Error(
"Mult",
"A rows and B columns incompatible");
812 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
817 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
826 if (
typeid(Element) ==
typeid(
Double_t))
827 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
829 else if (
typeid(Element) !=
typeid(
Float_t))
830 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
833 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
843 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
851 template<
class Element>
858 Error(
"TMult",
"A rows and B columns incompatible");
863 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
868 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
877 if (
typeid(Element) ==
typeid(
Double_t))
880 else if (
typeid(Element) !=
typeid(
Float_t))
884 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
893 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
901 template<
class Element>
908 Error(
"TMult",
"A rows and B columns incompatible");
913 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
918 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
927 if (
typeid(Element) ==
typeid(
Double_t))
930 else if (
typeid(Element) !=
typeid(
Float_t))
934 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
943 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
950 template<
class Element>
958 Error(
"MultT",
"A rows and B columns incompatible");
963 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
968 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
977 if (
typeid(Element) ==
typeid(
Double_t))
980 else if (
typeid(Element) !=
typeid(
Float_t))
984 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
994 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1002 template<
class Element>
1009 Error(
"MultT",
"A rows and B columns incompatible");
1014 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1019 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1028 if (
typeid(Element) ==
typeid(
Double_t))
1031 else if (
typeid(Element) !=
typeid(
Float_t))
1035 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
1045 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1052 template<
class Element>
1057 if (row_upb < row_lwb)
1059 Error(
"Use",
"row_upb=%d < row_lwb=%d",row_upb,row_lwb);
1062 if (col_upb < col_lwb)
1064 Error(
"Use",
"col_upb=%d < col_lwb=%d",col_upb,col_lwb);
1070 this->
fNrows = row_upb-row_lwb+1;
1071 this->
fNcols = col_upb-col_lwb+1;
1088 template<
class Element>
1095 Error(
"GetSub",
"row_lwb out of bounds");
1099 Error(
"GetSub",
"col_lwb out of bounds");
1103 Error(
"GetSub",
"row_upb out of bounds");
1107 Error(
"GetSub",
"col_upb out of bounds");
1110 if (row_upb < row_lwb || col_upb < col_lwb) {
1111 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1120 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1121 const Int_t row_upb_sub = (shift) ? row_upb-row_lwb : row_upb;
1122 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1123 const Int_t col_upb_sub = (shift) ? col_upb-col_lwb : col_upb;
1125 target.
ResizeTo(row_lwb_sub,row_upb_sub,col_lwb_sub,col_upb_sub);
1126 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
1127 const Int_t ncols_sub = col_upb_sub-col_lwb_sub+1;
1130 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1131 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1132 target(irow+row_lwb_sub,icol+col_lwb_sub) = (*this)(row_lwb+irow,col_lwb+icol);
1139 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1140 const Element *ap_sub = ap;
1141 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1155 template<
class Element>
1163 Error(
"SetSub",
"row_lwb outof bounds");
1167 Error(
"SetSub",
"col_lwb outof bounds");
1172 Error(
"SetSub",
"source matrix too large");
1183 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1184 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1185 (*this)(row_lwb+irow,col_lwb+icol) = source(rowlwb_s+irow,collwb_s+icol);
1192 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1193 Element *ap_sub = ap;
1194 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1209 template<
class Element>
1214 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1221 else if (nrows == 0 || ncols == 0) {
1239 memset(elements_new,0,this->
fNelems*
sizeof(Element));
1240 else if (this->
fNelems > nelems_old)
1241 memset(elements_new+nelems_old,0,(this->
fNelems-nelems_old)*
sizeof(Element));
1248 if (ncols_old < this->
fNcols) {
1249 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1250 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1251 nelems_new,nelems_old);
1253 memset(elements_new+i*this->fNcols+ncols_copy,0,(this->fNcols-ncols_copy)*
sizeof(Element));
1256 for (
Int_t i = 0; i < nrows_copy; i++)
1257 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1258 nelems_new,nelems_old);
1274 template<
class Element>
1280 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1284 const Int_t new_nrows = row_upb-row_lwb+1;
1285 const Int_t new_ncols = col_upb-col_lwb+1;
1289 if (this->
fNrows == new_nrows && this->
fNcols == new_ncols &&
1292 else if (new_nrows == 0 || new_ncols == 0) {
1306 Allocate(new_nrows,new_ncols,row_lwb,col_lwb);
1313 memset(elements_new,0,this->
fNelems*
sizeof(Element));
1314 else if (this->
fNelems > nelems_old)
1315 memset(elements_new+nelems_old,0,(this->
fNelems-nelems_old)*
sizeof(Element));
1323 const Int_t nrows_copy = rowUpb_copy-rowLwb_copy+1;
1324 const Int_t ncols_copy = colUpb_copy-colLwb_copy+1;
1326 if (nrows_copy > 0 && ncols_copy > 0) {
1327 const Int_t colOldOff = colLwb_copy-colLwb_old;
1329 if (ncols_old < this->
fNcols) {
1330 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1331 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1333 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1334 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->
fNelems,nelems_old);
1336 memset(elements_new+iRowNew*this->fNcols+colNewOff+ncols_copy,0,
1337 (this->fNcols-ncols_copy)*
sizeof(Element));
1340 for (
Int_t i = 0; i < nrows_copy; i++) {
1341 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1343 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1344 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->
fNelems,nelems_old);
1351 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1);
1360 template<
class Element>
1373 template<
class Element>
1395 template<
class Element>
1409 template<
class Element>
1419 Error(
"Invert()",
"matrix should be square");
1423 Error(
"InvertFast",
"matrix is singular");
1435 TMatrixTCramerInv::Inv2x2<Element>(*
this,det);
1440 TMatrixTCramerInv::Inv3x3<Element>(*
this,det);
1445 TMatrixTCramerInv::Inv4x4<Element>(*
this,det);
1450 TMatrixTCramerInv::Inv5x5<Element>(*
this,det);
1455 TMatrixTCramerInv::Inv6x6<Element>(*
this,det);
1468 template<
class Element>
1481 const Element tmp = ap[off_i+j];
1482 ap[off_i+j] = ap[off_j+i];
1498 const Int_t off = (icol-collwb_old)*ncols_old;
1499 (*this)(irow,icol) = oldElems[off+irow-rowlwb_old];
1508 Error(
"Transpose",
"matrix has wrong shape");
1513 const Element *scp = sp1;
1519 while (tp < tp_last) {
1520 const Element *sp2 = scp++;
1523 while (sp2 < sp1+this->
fNelems) {
1538 template<
class Element>
1545 Error(
"Rank1Update",
"vector too short");
1554 const Element tmp = alpha*pv[i];
1566 template<
class Element>
1574 Error(
"Rank1Update",
"vector v1 too short");
1579 Error(
"Rank1Update",
"vector v2 too short");
1589 const Element tmp = alpha*pv1[i];
1591 *mp++ += tmp*pv2[j];
1600 template<
class Element>
1607 Error(
"Similarity(const TVectorT &)",
"matrix is not square");
1612 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1621 const Element *
const vp_first = vp;
1622 const Element *
const vp_last = vp+v.
GetNrows();
1623 while (vp < vp_last) {
1625 for (
const Element *sp = vp_first; sp < vp_last; )
1626 sum2 += *mp++ * *sp++;
1627 sum1 += sum2 * *vp++;
1641 template<
class Element>
1648 Error(
"NormByColumn",
"vector shorter than matrix column");
1659 const Element *
const mp_last = mp+this->
fNelems;
1662 for ( ; mp < mp_last; pv++) {
1674 for ( ; mp < mp_last; pv++)
1688 template<
class Element>
1695 Error(
"NormByRow",
"vector shorter than matrix column");
1705 const Element *pv = pv0;
1707 const Element *
const mp_last = mp+this->
fNelems;
1710 for ( ; mp < mp_last; pv = pv0 )
1715 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv-pv0));
1720 for ( ; mp < mp_last; pv = pv0 )
1731 template<
class Element>
1735 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1750 template<
class Element>
1754 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1769 template<
class Element>
1775 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1789 for (
Int_t irow = 0; irow < this->
fNrows; irow++ ) {
1791 const Int_t sIndex = pRowIndex[irow];
1792 const Int_t eIndex = pRowIndex[irow+1];
1793 for (
Int_t index = sIndex; index < eIndex; index++)
1794 tp[off+pColIndex[index]] = sp[index];
1804 template<
class Element>
1813 Error(
"operator=(const TMatrixTLazy&)",
"matrix is incompatible with " 1814 "the assigned Lazy matrix");
1818 lazy_constructor.
FillIn(*
this);
1825 template<
class Element>
1831 const Element *
const ep_last = ep+this->
fNelems;
1832 while (ep < ep_last)
1841 template<
class Element>
1847 const Element *
const ep_last = ep+this->
fNelems;
1848 while (ep < ep_last)
1857 template<
class Element>
1863 const Element *
const ep_last = ep+this->
fNelems;
1864 while (ep < ep_last)
1873 template<
class Element>
1879 const Element *
const ep_last = ep+this->
fNelems;
1880 while (ep < ep_last)
1889 template<
class Element>
1893 Error(
"operator+=(const TMatrixT &)",
"matrices not compatible");
1899 const Element *
const tp_last = tp+this->
fNelems;
1900 while (tp < tp_last)
1909 template<
class Element>
1913 Error(
"operator+=(const TMatrixTSym &)",
"matrices not compatible");
1919 const Element *
const tp_last = tp+this->
fNelems;
1920 while (tp < tp_last)
1929 template<
class Element>
1933 Error(
"operator=-(const TMatrixT &)",
"matrices not compatible");
1939 const Element *
const tp_last = tp+this->
fNelems;
1940 while (tp < tp_last)
1949 template<
class Element>
1953 Error(
"operator=-(const TMatrixTSym &)",
"matrices not compatible");
1959 const Element *
const tp_last = tp+this->
fNelems;
1960 while (tp < tp_last)
1971 template<
class Element>
1979 Error(
"operator*=(const TMatrixT &)",
"source matrix has wrong shape");
1998 Element *trp = work;
2000 isAllocated =
kTRUE;
2001 trp =
new Element[this->
fNcols];
2005 const Element *trp0 = cp;
2006 const Element *
const trp0_last = trp0+this->
fNelems;
2007 while (trp0 < trp0_last) {
2008 memcpy(trp,trp0,this->
fNcols*
sizeof(Element));
2009 for (
const Element *scp = sp; scp < sp+this->
fNcols; ) {
2013 cij += trp[j] * *scp;
2023 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2034 template<
class Element>
2041 Error(
"operator*=(const TMatrixTSym &)",
"source matrix has wrong shape");
2060 Element *trp = work;
2062 isAllocated =
kTRUE;
2063 trp =
new Element[this->
fNcols];
2067 const Element *trp0 = cp;
2068 const Element *
const trp0_last = trp0+this->
fNelems;
2069 while (trp0 < trp0_last) {
2070 memcpy(trp,trp0,this->
fNcols*
sizeof(Element));
2071 for (
const Element *scp = sp; scp < sp+this->
fNcols; ) {
2075 cij += trp[j] * *scp;
2085 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2096 template<
class Element>
2103 Error(
"operator*=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2109 const Element *
const mp_last = mp+this->
fNelems;
2111 while (mp < mp_last) {
2112 const Element *dp = diag.
GetPtr();
2126 template<
class Element>
2133 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2139 const Element *
const mp_last = mp+this->
fNelems;
2141 while (mp < mp_last) {
2142 const Element *dp = diag.
GetPtr();
2147 Error(
"operator/=",
"%d-diagonal element is zero",j);
2161 template<
class Element>
2170 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2177 const Element *
const mp_last = mp+this->
fNelems;
2178 const Element *cp = col.
GetPtr();
2180 while (mp < mp_last) {
2194 template<
class Element>
2203 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2210 const Element *
const mp_last = mp+this->
fNelems;
2211 const Element *cp = col.
GetPtr();
2213 while (mp < mp_last) {
2220 Error(
"operator/=",
"%d-row of matrix column is zero",icol);
2233 template<
class Element>
2242 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2249 const Element *
const mp_last = mp+this->
fNelems;
2251 while (mp < mp_last) {
2252 const Element *rp = row.
GetPtr();
2267 template<
class Element>
2275 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2281 const Element *
const mp_last = mp+this->
fNelems;
2283 while (mp < mp_last) {
2284 const Element *rp = row.
GetPtr();
2290 Error(
"operator/=",
"%d-col of matrix row is zero",j);
2306 template<
class Element>
2310 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2320 template<
class Element>
2331 template<
class Element>
2342 template<
class Element>
2351 template<
class Element>
2362 template<
class Element>
2371 template<
class Element>
2382 template<
class Element>
2393 template<
class Element>
2396 return Element(-1.0)*(
operator-(source2,source1));
2402 template<
class Element>
2413 template<
class Element>
2416 return Element(-1.0)*
operator-(source,val);
2422 template<
class Element>
2433 template<
class Element>
2442 template<
class Element>
2452 template<
class Element>
2462 template<
class Element>
2472 template<
class Element>
2482 template<
class Element>
2488 Error(
"operator&&(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2498 while (tp < tp_last)
2499 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2507 template<
class Element>
2513 Error(
"operator&&(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2523 while (tp < tp_last)
2524 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2532 template<
class Element>
2541 template<
class Element>
2547 Error(
"operator||(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2557 while (tp < tp_last)
2558 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2566 template<
class Element>
2572 Error(
"operator||(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2582 while (tp < tp_last)
2583 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2591 template<
class Element>
2600 template<
class Element>
2606 Error(
"operator|(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2616 while (tp < tp_last) {
2617 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2626 template<
class Element>
2632 Error(
"operator>(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2642 while (tp < tp_last) {
2643 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2652 template<
class Element>
2661 template<
class Element>
2667 Error(
"operator>=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2677 while (tp < tp_last) {
2678 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2687 template<
class Element>
2693 Error(
"operator>=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2703 while (tp < tp_last) {
2704 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2713 template<
class Element>
2722 template<
class Element>
2728 Error(
"operator<=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2735 const Element *sp2 = source2.GetMatrixArray();
2738 while (tp < tp_last) {
2739 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2748 template<
class Element>
2754 Error(
"operator<=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2761 const Element *sp2 = source2.GetMatrixArray();
2764 while (tp < tp_last) {
2765 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2774 template<
class Element>
2783 template<
class Element>
2789 Error(
"operator<(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2794 const Element *sp2 = source2.GetMatrixArray();
2797 while (tp < tp_last) {
2798 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2807 template<
class Element>
2813 Error(
"operator<(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2820 const Element *sp2 = source2.GetMatrixArray();
2823 while (tp < tp_last) {
2824 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2833 template<
class Element>
2842 template<
class Element>
2848 Error(
"operator!=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2858 while (tp != tp_last) {
2859 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2868 template<
class Element>
2874 Error(
"operator!=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2884 while (tp != tp_last) {
2885 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2894 template<
class Element>
2904 template<class Element>
2905 TMatrixT<Element> operator!=(const TMatrixT<Element> &source1,Element val)
2907 TMatrixT<Element> target; target.ResizeTo(source1);
2909 const Element *sp = source1.GetMatrixArray();
2910 Element *tp = target.GetMatrixArray();
2911 const Element * const tp_last = tp+target.GetNoElements();
2912 while (tp != tp_last) {
2913 *tp++ = (*sp != val); sp++;
2922 template<class Element>
2923 TMatrixT<Element> operator!=(Element val,const TMatrixT<Element> &source1)
2925 return operator!=(source1,val);
2932 template<
class Element>
2936 ::Error(
"Add(TMatrixT &,Element,const TMatrixT &)",
"matrices not compatible");
2945 *tp++ = scalar * (*sp++);
2946 }
else if (scalar == 1.) {
2951 *tp++ += scalar * (*sp++);
2960 template<
class Element>
2964 ::Error(
"Add(TMatrixT &,Element,const TMatrixTSym &)",
"matrices not compatible");
2972 *tp++ += scalar * (*sp++);
2980 template<
class Element>
2984 ::Error(
"ElementMult(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3000 template<
class Element>
3004 ::Error(
"ElementMult(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3020 template<
class Element>
3024 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3031 while ( tp < ftp ) {
3037 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3048 template<
class Element>
3052 ::Error(
"ElementDiv(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3059 while ( tp < ftp ) {
3065 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3076 template<
class Element>
3078 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3080 const Element *arp0 = ap;
3081 while (arp0 < ap+na) {
3082 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
3083 const Element *arp = arp0;
3085 while (bcp < bp+nb) {
3086 cij += *arp++ * *bcp;
3099 template<
class Element>
3101 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3103 const Element *acp0 = ap;
3104 while (acp0 < ap+ncolsa) {
3105 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
3106 const Element *acp = acp0;
3108 while (bcp < bp+nb) {
3123 template<
class Element>
3125 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3127 const Element *arp0 = ap;
3128 while (arp0 < ap+na) {
3129 const Element *brp0 = bp;
3130 while (brp0 < bp+nb) {
3131 const Element *arp = arp0;
3132 const Element *brp = brp0;
3134 while (brp < brp0+ncolsb)
3135 cij += *arp++ * *brp++;
3146 template<
class Element>
3155 }
else if (R__v == 2) {
3157 TObject::Streamer(R__b);
3167 if (this->fNelems > 0) {
3175 TObject::Streamer(R__b);
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
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)
Templates of Lazy Matrix classes.
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 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