39 template<
class Element>
47 template<
class Element>
50 const Int_t no_rows = row_upb-row_lwb+1;
51 Allocate(no_rows,no_rows,row_lwb,row_lwb,1);
63 template<
class Element>
67 SetMatrixArray(elements,option);
68 if (!this->IsSymmetric()) {
69 Error(
"TMatrixTSym(Int_t,Element*,Option_t*)",
"matrix not symmetric");
76 template<
class Element>
79 const Int_t no_rows = row_upb-row_lwb+1;
80 Allocate(no_rows,no_rows,row_lwb,row_lwb);
81 SetMatrixArray(elements,option);
82 if (!this->IsSymmetric()) {
83 Error(
"TMatrixTSym(Int_t,Int_t,Element*,Option_t*)",
"matrix not symmetric");
89 template<
class Element>
102 template<
class Element>
132 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
144 Error(
"TMatrixTSym(EMatrixCreatorOp1,const TMatrixTSym)",
145 "operation %d not yet implemented", op);
151 template<
class Element>
163 Error(
"TMatrixTSym(EMatrixCreatorOp1,const TMatrixT)",
164 "operation %d not yet implemented", op);
170 template<
class Element>
192 Error(
"TMatrixTSym(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
198 template<
class Element>
204 lazy_constructor.
FillIn(*
this);
206 Error(
"TMatrixTSym(TMatrixTSymLazy)",
"matrix not symmetric");
213 template<
class Element>
227 template<
class Element>
230 if (size == 0)
return 0;
235 Element *heap =
new Element[size];
245 template<
class Element>
249 if (copySize == 0 || oldp == newp)
255 for (
Int_t i = copySize-1; i >= 0; i--)
258 for (
Int_t i = 0; i < copySize; i++)
263 memcpy(newp,oldp,copySize*
sizeof(Element));
272 template<
class Element>
285 if (no_rows < 0 || no_cols < 0)
287 Error(
"Allocate",
"no_rows=%d no_cols=%d",no_rows,no_cols);
310 template<
class Element>
315 Error(
"Plus",
"matrices not compatible");
320 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
325 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
333 const Element *
const cp_last = cp+this->
fNelems;
335 while (cp < cp_last) {
344 template<
class Element>
349 Error(
"Minus",
"matrices not compatible");
354 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
359 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
367 const Element *
const cp_last = cp+this->
fNelems;
369 while (cp < cp_last) {
379 template<
class Element>
387 if (
typeid(Element) ==
typeid(
Double_t))
390 else if (
typeid(Element) !=
typeid(
Float_t))
394 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
398 const Int_t ncolsb = ncolsa;
400 const Element *
const bp = ap;
403 const Element *acp0 = ap;
405 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
406 const Element *acp = acp0;
408 while (bcp < bp+nb) {
427 template<
class Element>
435 if (
typeid(Element) ==
typeid(
Double_t))
436 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,this->
fNrows,this->
fNcols,1.0,
438 else if (
typeid(Element) !=
typeid(
Float_t))
439 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,
fNrows,
fNcols,1.0,
442 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
446 const Int_t ncolsb = ncolsa;
448 const Element *
const bp = ap;
451 const Element *acp0 = ap;
453 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
454 const Element *acp = acp0;
456 while (bcp < bp+nb) {
473 template<
class Element>
478 Error(
"Use",
"row_upb=%d < row_lwb=%d",row_upb,row_lwb);
483 this->
fNrows = row_upb-row_lwb+1;
501 template<
class Element>
508 Error(
"GetSub",
"row_lwb out of bounds");
512 Error(
"GetSub",
"row_upb out of bounds");
515 if (row_upb < row_lwb) {
516 Error(
"GetSub",
"row_upb < row_lwb");
529 row_upb_sub = row_upb-row_lwb;
531 row_lwb_sub = row_lwb;
532 row_upb_sub = row_upb;
535 target.
ResizeTo(row_lwb_sub,row_upb_sub,row_lwb_sub,row_upb_sub);
536 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
539 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
540 for (
Int_t icol = 0; icol < nrows_sub; icol++) {
541 target(irow+row_lwb_sub,icol+row_lwb_sub) = (*this)(row_lwb+irow,row_lwb+icol);
548 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
549 const Element *ap_sub = ap;
550 for (
Int_t icol = 0; icol < nrows_sub; icol++) {
567 template<
class Element>
574 Error(
"GetSub",
"row_lwb out of bounds");
578 Error(
"GetSub",
"col_lwb out of bounds");
582 Error(
"GetSub",
"row_upb out of bounds");
586 Error(
"GetSub",
"col_upb out of bounds");
589 if (row_upb < row_lwb || col_upb < col_lwb) {
590 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
599 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
600 const Int_t row_upb_sub = (shift) ? row_upb-row_lwb : row_upb;
601 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
602 const Int_t col_upb_sub = (shift) ? col_upb-col_lwb : col_upb;
604 target.
ResizeTo(row_lwb_sub,row_upb_sub,col_lwb_sub,col_upb_sub);
605 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
606 const Int_t ncols_sub = col_upb_sub-col_lwb_sub+1;
609 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
610 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
611 target(irow+row_lwb_sub,icol+col_lwb_sub) = (*this)(row_lwb+irow,col_lwb+icol);
618 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
619 const Element *ap_sub = ap;
620 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
634 template<
class Element>
642 Error(
"SetSub",
"source matrix is not symmetric");
646 Error(
"SetSub",
"row_lwb outof bounds");
650 Error(
"SetSub",
"source matrix too large");
659 for (
Int_t irow = 0; irow < nRows_source; irow++) {
660 for (
Int_t icol = 0; icol < nRows_source; icol++) {
661 (*this)(row_lwb+irow,row_lwb+icol) = source(rowlwb_s+irow,rowlwb_s+icol);
668 for (
Int_t irow = 0; irow < nRows_source; irow++) {
669 Element *ap_sub = ap;
670 for (
Int_t icol = 0; icol < nRows_source; icol++) {
684 template<
class Element>
692 Error(
"SetSub",
"row_lwb out of bounds");
696 Error(
"SetSub",
"col_lwb out of bounds");
701 Error(
"SetSub",
"source matrix too large");
705 Error(
"SetSub",
"source matrix too large");
715 if (row_lwb >= col_lwb) {
718 for (irow = 0; irow < nRows_source; irow++) {
719 for (
Int_t icol = 0; col_lwb+icol <= row_lwb+irow &&
720 icol < nCols_source; icol++) {
721 (*this)(row_lwb+irow,col_lwb+icol) = source(irow+rowlwb_s,icol+collwb_s);
726 for (irow = 0; irow < nCols_source; irow++) {
727 for (
Int_t icol = nRows_source-1; row_lwb+icol > irow+col_lwb &&
729 (*this)(col_lwb+irow,row_lwb+icol) = source(icol+rowlwb_s,irow+collwb_s);
741 template<
class Element>
746 Error(
"SetMatrixArray",
"Matrix is not symmetric after Set");
754 template<
class Element>
757 if (row_shift != col_shift) {
758 Error(
"Shift",
"row_shift != col_shift");
769 template<
class Element>
774 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
778 if (nrows != ncols) {
779 Error(
"ResizeTo(Int_t,Int_t)",
"nrows != ncols");
786 else if (nrows == 0 || ncols == 0) {
804 memset(elements_new,0,this->
fNelems*
sizeof(Element));
805 else if (this->
fNelems > nelems_old)
806 memset(elements_new+nelems_old,0,(this->
fNelems-nelems_old)*
sizeof(Element));
813 if (ncols_old < this->
fNcols) {
814 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
815 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
816 nelems_new,nelems_old);
818 memset(elements_new+i*this->fNcols+ncols_copy,0,(this->fNcols-ncols_copy)*
sizeof(Element));
821 for (
Int_t i = 0; i < nrows_copy; i++)
822 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
823 nelems_new,nelems_old);
839 template<
class Element>
845 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
849 if (row_lwb != col_lwb) {
850 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"row_lwb != col_lwb");
853 if (row_upb != col_upb) {
854 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"row_upb != col_upb");
858 const Int_t new_nrows = row_upb-row_lwb+1;
859 const Int_t new_ncols = col_upb-col_lwb+1;
863 if (this->
fNrows == new_nrows && this->
fNcols == new_ncols &&
866 else if (new_nrows == 0 || new_ncols == 0) {
880 Allocate(new_nrows,new_ncols,row_lwb,col_lwb);
887 memset(elements_new,0,this->
fNelems*
sizeof(Element));
888 else if (this->
fNelems > nelems_old)
889 memset(elements_new+nelems_old,0,(this->
fNelems-nelems_old)*
sizeof(Element));
897 const Int_t nrows_copy = rowUpb_copy-rowLwb_copy+1;
898 const Int_t ncols_copy = colUpb_copy-colLwb_copy+1;
900 if (nrows_copy > 0 && ncols_copy > 0) {
901 const Int_t colOldOff = colLwb_copy-colLwb_old;
903 if (ncols_old < this->
fNcols) {
904 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
905 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
907 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
908 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->
fNelems,nelems_old);
910 memset(elements_new+iRowNew*this->fNcols+colNewOff+ncols_copy,0,
911 (this->fNcols-ncols_copy)*
sizeof(Element));
914 for (
Int_t i = 0; i < nrows_copy; i++) {
915 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
917 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
918 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->
fNelems,nelems_old);
925 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1);
933 template<
class Element>
945 template<
class Element>
959 template<
class Element>
977 template<
class Element>
988 Error(
"InvertFast",
"matrix is singular");
998 TMatrixTSymCramerInv::Inv2x2<Element>(*
this,det);
1003 TMatrixTSymCramerInv::Inv3x3<Element>(*
this,det);
1008 TMatrixTSymCramerInv::Inv4x4<Element>(*
this,det);
1013 TMatrixTSymCramerInv::Inv5x5<Element>(*
this,det);
1018 TMatrixTSymCramerInv::Inv6x6<Element>(*
this,det);
1039 template<
class Element>
1048 Error(
"Transpose",
"matrix has wrong shape");
1061 template<
class Element>
1068 Error(
"Rank1Update",
"vector too short");
1079 const Element tmp = alpha*pv[i];
1081 if (j > i) *tcp += tmp*pv[j];
1082 *trp++ += tmp*pv[j];
1097 template<
class Element>
1104 Error(
"Similarity(const TMatrixT &)",
"matrices incompatible");
1118 Element *bap = work;
1120 isAllocated =
kTRUE;
1121 bap =
new Element[nrowsb*ncolsa];
1126 if (nrowsb != this->
fNrows)
1131 if (
typeid(Element) ==
typeid(
Double_t))
1132 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasTrans,this->
fNrows,this->
fNcols,ba.GetNcols(),
1134 else if (
typeid(Element) !=
typeid(
Float_t))
1135 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasTrans,this->
fNrows,this->
fNcols,ba.GetNcols(),
1138 Error(
"Similarity",
"type %s not implemented in BLAS library",
typeid(Element));
1140 const Int_t nba = nrowsb*ncolsa;
1141 const Int_t ncolsba = ncolsa;
1142 const Element * bi1p = bp;
1144 Element *
const cp0 = cp;
1147 const Element *barp0 = bap;
1148 while (barp0 < bap+nba) {
1149 const Element *brp0 = bi1p;
1150 while (brp0 < bp+nb) {
1151 const Element *barp = barp0;
1152 const Element *brp = brp0;
1154 while (brp < brp0+ncolsb)
1155 cij += *barp++ * *brp++;
1167 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
1169 for (
Int_t icol = 0; icol < irow; icol++) {
1171 cp[rowOff1+icol] = cp[rowOff2+irow];
1188 template<
class Element>
1195 Error(
"Similarity(const TMatrixTSym &)",
"matrices incompatible");
1206 Element *abtp = work;
1208 isAllocated =
kTRUE;
1209 abtp =
new Element[this->
fNcols];
1216 if (
typeid(Element) ==
typeid(
Double_t))
1217 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,this->
fNrows,this->
fNcols,1.0,
1219 else if (
typeid(Element) !=
typeid(
Float_t))
1220 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,this->
fNrows,this->
fNcols,1.0,
1223 Error(
"Similarity",
"type %s not implemented in BLAS library",
typeid(Element));
1237 Element *bap = work;
1239 isAllocated =
kTRUE;
1240 bap =
new Element[nrowsb*ncolsa];
1245 const Int_t nba = nrowsb*ncolsa;
1246 const Int_t ncolsba = ncolsa;
1247 const Element * bi1p = bp;
1249 Element *
const cp0 = cp;
1252 const Element *barp0 = bap;
1253 while (barp0 < bap+nba) {
1254 const Element *brp0 = bi1p;
1255 while (brp0 < bp+nb) {
1256 const Element *barp = barp0;
1257 const Element *brp = brp0;
1259 while (brp < brp0+ncolsb)
1260 cij += *barp++ * *brp++;
1272 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
1274 for (
Int_t icol = 0; icol < irow; icol++) {
1276 cp[rowOff1+icol] = cp[rowOff2+irow];
1290 template<
class Element>
1297 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1306 const Element *
const vp_first = vp;
1307 const Element *
const vp_last = vp+v.
GetNrows();
1308 while (vp < vp_last) {
1310 for (
const Element *sp = vp_first; sp < vp_last; )
1311 sum2 += *mp++ * *sp++;
1312 sum1 += sum2 * *vp++;
1325 template<
class Element>
1332 Error(
"SimilarityT(const TMatrixT &)",
"matrices incompatible");
1342 Element *btap = work;
1344 isAllocated =
kTRUE;
1345 btap =
new Element[ncolsb*ncolsa];
1351 if (ncolsb != this->
fNcols)
1357 if (
typeid(Element) ==
typeid(
Double_t))
1360 else if (
typeid(Element) !=
typeid(
Float_t))
1364 Error(
"similarityT",
"type %s not implemented in BLAS library",
typeid(Element));
1371 Element *
const cp0 = cp;
1374 const Element *btarp0 = btap;
1375 const Element *bcp0 = bp;
1376 while (btarp0 < btap+nbta) {
1377 for (
const Element *bcp = bcp0; bcp < bp+ncolsb; ) {
1378 const Element *btarp = btarp0;
1380 while (bcp < bp+nb) {
1381 cij += *btarp++ * *bcp;
1395 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
1397 for (
Int_t icol = 0; icol < irow; icol++) {
1399 cp[rowOff1+icol] = cp[rowOff2+irow];
1412 template<
class Element>
1416 Error(
"operator=",
"matrices not compatible");
1429 template<
class Element>
1434 if (lazy_constructor.
fRowUpb != this->GetRowUpb() ||
1436 Error(
"operator=(const TMatrixTSymLazy&)",
"matrix is incompatible with " 1437 "the assigned Lazy matrix");
1441 lazy_constructor.
FillIn(*
this);
1448 template<
class Element>
1454 const Element *
const ep_last = ep+this->
fNelems;
1455 while (ep < ep_last)
1464 template<
class Element>
1470 const Element *
const ep_last = ep+this->
fNelems;
1471 while (ep < ep_last)
1480 template<
class Element>
1486 const Element *
const ep_last = ep+this->
fNelems;
1487 while (ep < ep_last)
1496 template<
class Element>
1502 const Element *
const ep_last = ep+this->
fNelems;
1503 while (ep < ep_last)
1512 template<
class Element>
1516 Error(
"operator+=",
"matrices not compatible");
1522 const Element *
const tp_last = tp+this->
fNelems;
1523 while (tp < tp_last)
1532 template<
class Element>
1536 Error(
"operator-=",
"matrices not compatible");
1542 const Element *
const tp_last = tp+this->
fNelems;
1543 while (tp < tp_last)
1551 template<
class Element>
1564 if (j > i) *tcp = val;
1578 template<
class Element>
1593 if (j > i) *tcp = val;
1606 template<
class Element>
1612 Error(
"Randomize(Element,Element,Element &",
"matrix should be square");
1617 const Element scale = beta-alpha;
1618 const Element shift = alpha/scale;
1623 for (
Int_t j = 0; j <= i; j++) {
1624 ep[off+j] = scale*(
Drand(seed)+shift);
1626 ep[j*this->fNcols+i] = ep[off+j];
1637 template<
class Element>
1643 Error(
"RandomizeSym(Element,Element,Element &",
"matrix should be square");
1648 const Element scale = beta-alpha;
1649 const Element shift = alpha/scale;
1653 for (i = 0; i < this->
fNrows; i++) {
1655 for (
Int_t j = 0; j <= i; j++)
1656 ep[off+j] = scale*(
Drand(seed)+shift);
1659 for (i = this->fNrows-1; i >= 0; i--) {
1661 for (
Int_t j = i; j >= 0; j--) {
1663 ep[off1+j] *= ep[off2+j];
1664 for (
Int_t k = j-1; k >= 0; k--) {
1665 ep[off1+j] += ep[off1+k]*ep[off2+k];
1668 ep[off2+i] = ep[off1+j];
1679 template<
class Element>
1692 template<
class Element>
1702 template<
class Element>
1712 template<
class Element>
1722 template<
class Element>
1730 template<
class Element>
1740 template<
class Element>
1750 template<
class Element>
1753 return Element(-1.0)*
operator-(source1,val);
1758 template<
class Element>
1768 template<
class Element>
1777 template<
class Element>
1783 Error(
"operator&&(const TMatrixTSym&,const TMatrixTSym&)",
"matrices not compatible");
1793 while (tp < tp_last)
1794 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
1802 template<
class Element>
1808 Error(
"operator||(const TMatrixTSym&,const TMatrixTSym&)",
"matrices not compatible");
1818 while (tp < tp_last)
1819 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
1827 template<
class Element>
1833 Error(
"operator>(const TMatrixTSym&,const TMatrixTSym&)",
"matrices not compatible");
1843 while (tp < tp_last) {
1844 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
1853 template<
class Element>
1859 Error(
"operator>=(const TMatrixTSym&,const TMatrixTSym&)",
"matrices not compatible");
1869 while (tp < tp_last) {
1870 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
1879 template<
class Element>
1885 Error(
"operator<=(const TMatrixTSym&,const TMatrixTSym&)",
"matrices not compatible");
1892 const Element *sp2 = source2.GetMatrixArray();
1895 while (tp < tp_last) {
1896 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
1905 template<
class Element>
1911 Error(
"operator<(const TMatrixTSym&,const TMatrixTSym&)",
"matrices not compatible");
1918 const Element *sp2 = source2.GetMatrixArray();
1921 while (tp < tp_last) {
1922 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
1931 template<
class Element>
1935 ::Error(
"Add",
"matrices not compatible");
1945 for (
Int_t i = 0; i < nrows; i++) {
1949 for (
Int_t j = i; j < ncols; j++) {
1950 const Element tmp = scalar * *sp++;
1951 if (j > i) *tcp += tmp;
1964 template<
class Element>
1968 ::Error(
"ElementMult",
"matrices not compatible");
1978 for (
Int_t i = 0; i < nrows; i++) {
1982 for (
Int_t j = i; j < ncols; j++) {
1983 if (j > i) *tcp *= *sp;
1996 template<
class Element>
2000 ::Error(
"ElementDiv",
"matrices not compatible");
2010 for (
Int_t i = 0; i < nrows; i++) {
2014 for (
Int_t j = i; j < ncols; j++) {
2016 if (j > i) *tcp /= *sp;
2021 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
2035 template<
class Element>
2045 for (i = 0; i < this->
fNrows; i++) {
2049 for (i = 0; i < this->
fNrows; i++) {
2050 for (
Int_t j = 0; j < i; j++) {
2054 if (this->fNelems <= this->
kSizeMax) {
TMatrixTSym< Element > & SimilarityT(const TMatrixT< Element > &n)
Calculate B^T * (*this) * B , final matrix will be (ncolsb x ncolsb) It is more efficient than applyi...
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 TMatrixTBase< Element > & Shift(Int_t row_shift, Int_t col_shift)
Shift the row index by adding row_shift and the column index by adding col_shift, respectively...
virtual 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...
template TMatrixFSym operator<=< Float_t >(const TMatrixFSym &source1, const TMatrixFSym &source2)
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TMatrixTSym< Element > & ElementMult(TMatrixTSym< Element > &target, const TMatrixTSym< Element > &source)
Multiply target by the source, element-by-element.
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...
TMatrixTSym< Element > & Use(Int_t row_lwb, Int_t row_upb, Element *data)
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
Copy array data to matrix .
TMatrixTSym< Element > & Add(TMatrixTSym< Element > &target, Element scalar, const TMatrixTSym< Element > &source)
Modify addition: target += scalar * source.
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.
TMatrixTSym< Element > & operator=(const TMatrixTSym< Element > &source)
virtual const Element * GetMatrixArray() const
Element fDataStack[TMatrixTBase< Element >::kSizeMax]
TMatrixTSym< Element > & ElementDiv(TMatrixTSym< Element > &target, const TMatrixTSym< Element > &source)
Multiply target by the source, element-by-element.
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
void TMult(const TMatrixT< Element > &a)
Create a matrix C such that C = A' * A.
static Bool_t InvertLU(TMatrixD &a, Double_t tol, Double_t *det=0)
Calculate matrix inversion through in place forward/backward substitution.
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)
Bool_t operator>(Element val) const
Are all matrix elements > val?
virtual const Element * GetMatrixArray() const
virtual void Clear(Option_t *="")
TMatrixTSym< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1)=0
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
TMatrixTSym< Element > & Rank1Update(const TVectorT< Element > &v, Element alpha=1.0)
Perform a rank 1 operation on the matrix: A += alpha * v * v^T.
double beta(double x, double y)
Calculates the beta function.
Int_t GetNoElements() const
template TMatrixDSym & ElementDiv< Double_t >(TMatrixDSym &target, const TMatrixDSym &source)
#define templateClassImp(name)
TMatrixTSym< Element > & operator+=(Element val)
Add val to every element of the matrix.
virtual void Operation(Element &element) const =0
void AMultB(int n, int m, int k, const double *A, const double *B, double *C)
template TMatrixDSym & ElementMult< Double_t >(TMatrixDSym &target, const TMatrixDSym &source)
static double p2(double t, double a, double b, double c)
Bool_t operator>=(Element val) const
Are all matrix elements >= val?
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.
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
Copy array data to matrix .
virtual void FillIn(TMatrixTSym< Element > &m) const =0
void Error(const char *location, const char *msgfmt,...)
void Minus(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Symmetric matrix summation. Create a matrix C such that C = A + B.
virtual const Int_t * GetColIndexArray() const
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 .
Element * GetMatrixArray()
TMatrixTSym< Element > operator &&(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Logical AND.
virtual Double_t Determinant() const
TMatrixTBase< Element > & Apply(const TElementActionT< Element > &action)
Apply action to each matrix element.
template TMatrixFSym & Add< Float_t >(TMatrixFSym &target, Float_t scalar, const TMatrixFSym &source)
template TMatrixDSym operator<=< Double_t >(const TMatrixDSym &source1, const TMatrixDSym &source2)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
template TMatrixFSym & ElementDiv< Float_t >(TMatrixFSym &target, const TMatrixFSym &source)
Int_t GetNoElements() const
static double p1(double t, double a, double b)
R__EXTERN Int_t gMatrixCheck
virtual TMatrixTBase< Element > & Randomize(Element alpha, Element beta, Double_t &seed)
randomize matrix element values but keep matrix symmetric
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
const TMatrixD & GetEigenVectors() const
TMatrixTSym< Element > & GetSub(Int_t row_lwb, Int_t row_upb, TMatrixTSym< Element > &target, Option_t *option="S") const
Get submatrix [row_lwb..row_upb][row_lwb..row_upb]; The indexing range of the returned matrix depends...
TMatrixTSym< Element > & Transpose(const TMatrixTSym< Element > &source)
Transpose a matrix.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
const TVectorD & GetEigenValues() const
void Plus(const TMatrixTSym< Element > &a, const TMatrixTSym< Element > &b)
Symmetric matrix summation. Create a matrix C such that C = A + B.
TMatrixTSym< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
virtual TMatrixTSym< Element > & RandomizePD(Element alpha, Element beta, Double_t &seed)
randomize matrix element values but keep matrix symmetric positive definite
TMatrixTSym< Element > & InvertFast(Double_t *det=0)
Invert the matrix and calculate its determinant.
TMatrixTSym< Element > & SetSub(Int_t row_lwb, const TMatrixTBase< Element > &source)
Insert matrix source starting at [row_lwb][row_lwb], thereby overwriting the part [row_lwb...
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TMatrixTSym< Element > & Similarity(const TMatrixT< Element > &n)
Calculate B * (*this) * B^T , final matrix will be (nrowsb x nrowsb) This is a similarity transform w...
void Delete_m(Int_t size, Element *&)
delete data pointer m, if it was assigned on the heap
virtual void Operation(Element &element) const =0
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])
TMatrixTSym< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant Notice that the LU decomposition is used instead of B...
TMatrixTSym< Element > operator||(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Logical Or.
TMatrixTSym< Element > operator+(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Short_t Max(Short_t a, Short_t b)
Bool_t operator==(Element val) const
Are all matrix elements equal to val?
template TMatrixDSym & Add< Double_t >(TMatrixDSym &target, Double_t scalar, const TMatrixDSym &source)
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
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
const TMatrixT< Element > EigenVectors(TVectorT< Element > &eigenValues) const
Return a matrix containing the eigen-vectors ordered by descending eigen-values.
Element * New_m(Int_t size)
return data pointer .
TMatrixTSym< Element > operator*(const TMatrixTSym< Element > &source1, Element val)
template TMatrixFSym & ElementMult< Float_t >(TMatrixFSym &target, const TMatrixFSym &source)
Element * fElements
data container
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.
TMatrixTSym< Element > operator-(const TMatrixTSym< Element > &source1, const TMatrixTSym< Element > &source2)
Element SetTol(Element tol)
virtual const Int_t * GetRowIndexArray() const
virtual const Int_t * GetColIndexArray() const =0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual const Int_t * GetRowIndexArray() const =0