39template <
class Element>
48template <
class Element>
51 Allocate(row_upb - row_lwb + 1, col_upb - col_lwb + 1, row_lwb, col_lwb, 1);
62template <
class Element>
72template <
class Element>
76 Allocate(row_upb - row_lwb + 1, col_upb - col_lwb + 1, row_lwb, col_lwb);
83template <
class Element>
94template <
class Element>
105template <
class Element>
118template <
class Element>
143 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
151 TMult(prototype, prototype);
154 default:
Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
164template <
class Element>
177 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
182 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
187 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
189 if (
a.GetNrows() ==
b.GetNcols()) {
191 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
197 const Element oldTol = ainv.
SetTol(std::numeric_limits<Element>::min());
217 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
226template <
class Element>
234 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
239 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
244 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
249 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
251 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
259 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
265 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
270 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
280template <
class Element>
288 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
293 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
298 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
303 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
305 if (
a.GetNrows() ==
b.GetNcols()) {
307 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
313 const Element oldTol = ainv.
SetTol(std::numeric_limits<Element>::min());
322 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
328 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
333 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
342template <
class Element>
350 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
355 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
360 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
365 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
367 const Element oldTol = this->
SetTol(std::numeric_limits<Element>::min());
375 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
381 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
386 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
393template <
class Element>
399 lazy_constructor.
FillIn(*
this);
405template <
class Element>
419template <
class Element>
428 Element *heap =
new Element[
size];
438template <
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++)
454 memcpy(newp, oldp, copySize *
sizeof(Element));
463template <
class Element>
468 this->
fTol = std::numeric_limits<Element>::epsilon();
476 if (no_rows < 0 || no_cols < 0) {
477 Error(
"Allocate",
"no_rows=%d no_cols=%d", no_rows, no_cols);
491 Error(
"Allocate",
"too large: no_rows=%d no_cols=%d", no_rows, no_cols);
507template <
class Element>
512 Error(
"Plus",
"matrices not compatible");
517 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
522 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
527 const Element *ap =
a.GetMatrixArray();
528 const Element *bp =
b.GetMatrixArray();
530 const Element *
const cp_last = cp + this->
fNelems;
532 while (cp < cp_last) {
541template <
class Element>
546 Error(
"Plus",
"matrices not compatible");
551 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
556 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
561 const Element *ap =
a.GetMatrixArray();
562 const Element *bp =
b.GetMatrixArray();
564 const Element *
const cp_last = cp + this->
fNelems;
566 while (cp < cp_last) {
575template <
class Element>
580 Error(
"Minus",
"matrices not compatible");
585 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
590 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
595 const Element *ap =
a.GetMatrixArray();
596 const Element *bp =
b.GetMatrixArray();
598 const Element *
const cp_last = cp + this->
fNelems;
600 while (cp < cp_last) {
609template <
class Element>
614 Error(
"Minus",
"matrices not compatible");
619 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
624 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
629 const Element *ap =
a.GetMatrixArray();
630 const Element *bp =
b.GetMatrixArray();
632 const Element *
const cp_last = cp + this->
fNelems;
634 while (cp < cp_last) {
643template <
class Element>
647 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
648 Error(
"Mult",
"A rows and B columns incompatible");
653 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
658 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
664 const Element *ap =
a.GetMatrixArray();
665 const Element *bp =
b.GetMatrixArray();
667 if (
typeid(Element) ==
typeid(
Double_t))
668 cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
fNrows,
fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
669 b.GetNcols(), 1.0, cp,
fNcols);
670 else if (
typeid(Element) !=
typeid(
Float_t))
671 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
fNrows,
fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
672 b.GetNcols(), 1.0, cp,
fNcols);
674 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
676 const Int_t na =
a.GetNoElements();
677 const Int_t nb =
b.GetNoElements();
678 const Int_t ncolsa =
a.GetNcols();
679 const Int_t ncolsb =
b.GetNcols();
680 const Element *
const ap =
a.GetMatrixArray();
681 const Element *
const bp =
b.GetMatrixArray();
684 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
692template <
class Element>
698 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
699 Error(
"Mult",
"A rows and B columns incompatible");
704 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
709 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
715 const Element *ap =
a.GetMatrixArray();
716 const Element *bp =
b.GetMatrixArray();
718 if (
typeid(Element) ==
typeid(
Double_t))
719 cblas_dsymm(CblasRowMajor, CblasLeft, CblasUpper,
fNrows,
fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
721 else if (
typeid(Element) !=
typeid(
Float_t))
722 cblas_ssymm(CblasRowMajor, CblasLeft, CblasUpper,
fNrows,
fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
725 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
727 const Int_t na =
a.GetNoElements();
728 const Int_t nb =
b.GetNoElements();
729 const Int_t ncolsa =
a.GetNcols();
730 const Int_t ncolsb =
b.GetNcols();
731 const Element *
const ap =
a.GetMatrixArray();
732 const Element *
const bp =
b.GetMatrixArray();
735 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
744template <
class Element>
750 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
751 Error(
"Mult",
"A rows and B columns incompatible");
756 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
761 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
767 const Element *ap =
a.GetMatrixArray();
768 const Element *bp =
b.GetMatrixArray();
770 if (
typeid(Element) ==
typeid(
Double_t))
771 cblas_dsymm(CblasRowMajor, CblasRight, CblasUpper,
fNrows,
fNcols, 1.0, bp,
b.GetNcols(), ap,
a.GetNcols(), 0.0,
773 else if (
typeid(Element) !=
typeid(
Float_t))
774 cblas_ssymm(CblasRowMajor, CblasRight, CblasUpper,
fNrows,
fNcols, 1.0, bp,
b.GetNcols(), ap,
a.GetNcols(), 0.0,
777 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
779 const Int_t na =
a.GetNoElements();
780 const Int_t nb =
b.GetNoElements();
781 const Int_t ncolsa =
a.GetNcols();
782 const Int_t ncolsb =
b.GetNcols();
783 const Element *
const ap =
a.GetMatrixArray();
784 const Element *
const bp =
b.GetMatrixArray();
787 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
796template <
class Element>
802 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
803 Error(
"Mult",
"A rows and B columns incompatible");
808 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
813 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
819 const Element *ap =
a.GetMatrixArray();
820 const Element *bp =
b.GetMatrixArray();
822 if (
typeid(Element) ==
typeid(
Double_t))
823 cblas_dsymm(CblasRowMajor, CblasLeft, CblasUpper,
fNrows,
fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
825 else if (
typeid(Element) !=
typeid(
Float_t))
826 cblas_ssymm(CblasRowMajor, CblasLeft, CblasUpper,
fNrows,
fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
829 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
831 const Int_t na =
a.GetNoElements();
832 const Int_t nb =
b.GetNoElements();
833 const Int_t ncolsa =
a.GetNcols();
834 const Int_t ncolsb =
b.GetNcols();
835 const Element *
const ap =
a.GetMatrixArray();
836 const Element *
const bp =
b.GetMatrixArray();
839 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
847template <
class Element>
853 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
854 Error(
"TMult",
"A rows and B columns incompatible");
859 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
864 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
870 const Element *ap =
a.GetMatrixArray();
871 const Element *bp =
b.GetMatrixArray();
873 if (
typeid(Element) ==
typeid(
Double_t))
874 cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, this->
fNrows, this->
fNcols,
a.GetNrows(), 1.0, ap,
875 a.GetNcols(), bp,
b.GetNcols(), 1.0, cp, this->fNcols);
876 else if (
typeid(Element) !=
typeid(
Float_t))
877 cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
fNrows,
fNcols,
a.GetNrows(), 1.0, ap,
a.GetNcols(), bp,
878 b.GetNcols(), 1.0, cp,
fNcols);
880 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
882 const Int_t nb =
b.GetNoElements();
883 const Int_t ncolsa =
a.GetNcols();
884 const Int_t ncolsb =
b.GetNcols();
885 const Element *
const ap =
a.GetMatrixArray();
886 const Element *
const bp =
b.GetMatrixArray();
889 AtMultB(ap, ncolsa, bp, nb, ncolsb, cp);
897template <
class Element>
903 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
904 Error(
"TMult",
"A rows and B columns incompatible");
909 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
914 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
920 const Element *ap =
a.GetMatrixArray();
921 const Element *bp =
b.GetMatrixArray();
923 if (
typeid(Element) ==
typeid(
Double_t))
924 cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
fNrows,
fNcols,
a.GetNrows(), 1.0, ap,
a.GetNcols(), bp,
925 b.GetNcols(), 1.0, cp,
fNcols);
926 else if (
typeid(Element) !=
typeid(
Float_t))
927 cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
fNrows,
fNcols,
a.GetNrows(), 1.0, ap,
a.GetNcols(), bp,
928 b.GetNcols(), 1.0, cp,
fNcols);
930 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
932 const Int_t nb =
b.GetNoElements();
933 const Int_t ncolsa =
a.GetNcols();
934 const Int_t ncolsb =
b.GetNcols();
935 const Element *
const ap =
a.GetMatrixArray();
936 const Element *
const bp =
b.GetMatrixArray();
939 AtMultB(ap, ncolsa, bp, nb, ncolsb, cp);
946template <
class Element>
953 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
954 Error(
"MultT",
"A rows and B columns incompatible");
959 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
964 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
970 const Element *ap =
a.GetMatrixArray();
971 const Element *bp =
b.GetMatrixArray();
973 if (
typeid(Element) ==
typeid(
Double_t))
974 cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans,
fNrows,
fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
975 b.GetNcols(), 1.0, cp,
fNcols);
976 else if (
typeid(Element) !=
typeid(
Float_t))
977 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans,
fNrows,
fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
978 b.GetNcols(), 1.0, cp,
fNcols);
980 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
982 const Int_t na =
a.GetNoElements();
983 const Int_t nb =
b.GetNoElements();
984 const Int_t ncolsa =
a.GetNcols();
985 const Int_t ncolsb =
b.GetNcols();
986 const Element *
const ap =
a.GetMatrixArray();
987 const Element *
const bp =
b.GetMatrixArray();
990 AMultBt(ap, na, ncolsa, bp, nb, ncolsb, cp);
998template <
class Element>
1004 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
1005 Error(
"MultT",
"A rows and B columns incompatible");
1010 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1015 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1021 const Element *ap =
a.GetMatrixArray();
1022 const Element *bp =
b.GetMatrixArray();
1024 if (
typeid(Element) ==
typeid(
Double_t))
1025 cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, this->
fNrows, this->
fNcols,
a.GetNcols(), 1.0, ap,
1026 a.GetNcols(), bp,
b.GetNcols(), 1.0, cp, this->fNcols);
1027 else if (
typeid(Element) !=
typeid(
Float_t))
1028 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans,
fNrows,
fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
1029 b.GetNcols(), 1.0, cp,
fNcols);
1031 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
1033 const Int_t na =
a.GetNoElements();
1034 const Int_t nb =
b.GetNoElements();
1035 const Int_t ncolsa =
a.GetNcols();
1036 const Int_t ncolsb =
b.GetNcols();
1037 const Element *
const ap =
a.GetMatrixArray();
1038 const Element *
const bp =
b.GetMatrixArray();
1041 AMultBt(ap, na, ncolsa, bp, nb, ncolsb, cp);
1048template <
class Element>
1052 if (row_upb < row_lwb) {
1053 Error(
"Use",
"row_upb=%d < row_lwb=%d", row_upb, row_lwb);
1056 if (col_upb < col_lwb) {
1057 Error(
"Use",
"col_upb=%d < col_lwb=%d", col_upb, col_lwb);
1063 this->
fNrows = row_upb - row_lwb + 1;
1064 this->
fNcols = col_upb - col_lwb + 1;
1081template <
class Element>
1088 Error(
"GetSub",
"row_lwb out of bounds");
1092 Error(
"GetSub",
"col_lwb out of bounds");
1096 Error(
"GetSub",
"row_upb out of bounds");
1100 Error(
"GetSub",
"col_upb out of bounds");
1103 if (row_upb < row_lwb || col_upb < col_lwb) {
1104 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1113 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1114 const Int_t row_upb_sub = (shift) ? row_upb - row_lwb : row_upb;
1115 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1116 const Int_t col_upb_sub = (shift) ? col_upb - col_lwb : col_upb;
1118 target.ResizeTo(row_lwb_sub, row_upb_sub, col_lwb_sub, col_upb_sub);
1119 const Int_t nrows_sub = row_upb_sub - row_lwb_sub + 1;
1120 const Int_t ncols_sub = col_upb_sub - col_lwb_sub + 1;
1122 if (
target.GetRowIndexArray() &&
target.GetColIndexArray()) {
1123 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1124 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1125 target(irow + row_lwb_sub, icol + col_lwb_sub) = (*this)(row_lwb + irow, col_lwb + icol);
1130 Element *bp =
target.GetMatrixArray();
1132 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1133 const Element *ap_sub = ap;
1134 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1148template <
class Element>
1156 Error(
"SetSub",
"row_lwb outof bounds");
1160 Error(
"SetSub",
"col_lwb outof bounds");
1163 if (row_lwb + source.
GetNrows() > this->fRowLwb + this->fNrows ||
1164 col_lwb + source.
GetNcols() > this->fColLwb + this->fNcols) {
1165 Error(
"SetSub",
"source matrix too large");
1176 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1177 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1178 (*this)(row_lwb + irow, col_lwb + icol) = source(rowlwb_s + irow, collwb_s + icol);
1185 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1186 Element *ap_sub = ap;
1187 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1202template <
class Element>
1207 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1214 else if (nrows == 0 || ncols == 0) {
1233 memset(elements_new, 0, this->
fNelems *
sizeof(Element));
1234 else if (this->
fNelems > nelems_old)
1235 memset(elements_new + nelems_old, 0, (this->
fNelems - nelems_old) *
sizeof(Element));
1242 if (ncols_old < this->
fNcols) {
1243 for (
Int_t i = nrows_copy - 1;
i >= 0;
i--) {
1244 Memcpy_m(elements_new +
i * this->fNcols, elements_old +
i * ncols_old, ncols_copy, nelems_new, nelems_old);
1246 memset(elements_new +
i * this->fNcols + ncols_copy, 0, (this->fNcols - ncols_copy) *
sizeof(Element));
1249 for (
Int_t i = 0;
i < nrows_copy;
i++)
1250 Memcpy_m(elements_new +
i * this->fNcols, elements_old +
i * ncols_old, ncols_copy, nelems_new, nelems_old);
1253 Delete_m(nelems_old, elements_old);
1266template <
class Element>
1272 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1276 const Int_t new_nrows = row_upb - row_lwb + 1;
1277 const Int_t new_ncols = col_upb - col_lwb + 1;
1284 else if (new_nrows == 0 || new_ncols == 0) {
1285 this->
fNrows = new_nrows;
1286 this->
fNcols = new_ncols;
1300 Allocate(new_nrows, new_ncols, row_lwb, col_lwb);
1307 memset(elements_new, 0, this->
fNelems *
sizeof(Element));
1308 else if (this->
fNelems > nelems_old)
1309 memset(elements_new + nelems_old, 0, (this->
fNelems - nelems_old) *
sizeof(Element));
1317 const Int_t nrows_copy = rowUpb_copy - rowLwb_copy + 1;
1318 const Int_t ncols_copy = colUpb_copy - colLwb_copy + 1;
1320 if (nrows_copy > 0 && ncols_copy > 0) {
1321 const Int_t colOldOff = colLwb_copy - colLwb_old;
1323 if (ncols_old < this->
fNcols) {
1324 for (
Int_t i = nrows_copy - 1;
i >= 0;
i--) {
1325 const Int_t iRowOld = rowLwb_copy +
i - rowLwb_old;
1327 Memcpy_m(elements_new + iRowNew * this->fNcols + colNewOff,
1328 elements_old + iRowOld * ncols_old + colOldOff, ncols_copy, this->
fNelems, nelems_old);
1330 memset(elements_new + iRowNew * this->fNcols + colNewOff + ncols_copy, 0,
1331 (this->fNcols - ncols_copy) *
sizeof(Element));
1334 for (
Int_t i = 0;
i < nrows_copy;
i++) {
1335 const Int_t iRowOld = rowLwb_copy +
i - rowLwb_old;
1337 Memcpy_m(elements_new + iRowNew * this->fNcols + colNewOff,
1338 elements_old + iRowOld * ncols_old + colOldOff, ncols_copy, this->
fNelems, nelems_old);
1343 Delete_m(nelems_old, elements_old);
1345 Allocate(new_nrows, new_ncols, row_lwb, col_lwb, 1);
1354template <
class Element>
1367template <
class Element>
1389template <
class Element>
1394 std::copy(tmp.GetMatrixArray(), tmp.GetMatrixArray() + this->GetNoElements(), this->GetMatrixArray());
1403template <
class Element>
1412 Error(
"Invert()",
"matrix should be square");
1416 Error(
"InvertFast",
"matrix is singular");
1454template <
class Element>
1464 const Int_t off_i =
i * this->fNrows;
1466 const Int_t off_j = j * this->fNcols;
1467 const Element tmp = ap[off_i + j];
1468 ap[off_i + j] = ap[off_j +
i];
1469 ap[off_j +
i] = tmp;
1480 this->
fNrows = ncols_old;
1481 this->
fNcols = nrows_old;
1486 const Int_t off = (icol - collwb_old) * ncols_old;
1487 (*this)(irow, icol) = oldElems[off + irow - rowlwb_old];
1495 Error(
"Transpose",
"matrix has wrong shape");
1500 const Element *scp = sp1;
1506 while (tp < tp_last) {
1507 const Element *sp2 = scp++;
1510 while (sp2 < sp1 + this->
fNelems) {
1525template <
class Element>
1531 if (
v.GetNoElements() <
TMath::Max(this->fNrows, this->fNcols)) {
1532 Error(
"Rank1Update",
"vector too short");
1537 const Element *
const pv =
v.GetMatrixArray();
1541 const Element tmp = alpha * pv[
i];
1543 *mp++ += tmp * pv[j];
1553template <
class Element>
1561 if (
v1.GetNoElements() < this->fNrows) {
1562 Error(
"Rank1Update",
"vector v1 too short");
1566 if (
v2.GetNoElements() < this->fNcols) {
1567 Error(
"Rank1Update",
"vector v2 too short");
1572 const Element *
const pv1 =
v1.GetMatrixArray();
1573 const Element *
const pv2 =
v2.GetMatrixArray();
1577 const Element tmp = alpha * pv1[
i];
1579 *mp++ += tmp * pv2[j];
1588template <
class Element>
1595 Error(
"Similarity(const TVectorT &)",
"matrix is not square");
1599 if (this->
fNcols !=
v.GetNrows() || this->fColLwb !=
v.GetLwb()) {
1600 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1606 const Element *vp =
v.GetMatrixArray();
1609 const Element *
const vp_first = vp;
1610 const Element *
const vp_last = vp +
v.GetNrows();
1611 while (vp < vp_last) {
1613 for (
const Element *sp = vp_first; sp < vp_last;)
1614 sum2 += *mp++ * *sp++;
1615 sum1 += sum2 * *vp++;
1629template <
class Element>
1635 if (
v.GetNoElements() < this->fNrows) {
1636 Error(
"NormByColumn",
"vector shorter than matrix column");
1645 const Element *pv =
v.GetMatrixArray();
1647 const Element *
const mp_last = mp + this->
fNelems;
1650 for (; mp < mp_last; pv++) {
1655 Error(
"NormbyColumn",
"vector element %ld is zero",
Long_t(pv -
v.GetMatrixArray()));
1661 for (; mp < mp_last; pv++)
1675template <
class Element>
1681 if (
v.GetNoElements() < this->fNcols) {
1682 Error(
"NormByRow",
"vector shorter than matrix column");
1691 const Element *pv0 =
v.GetMatrixArray();
1692 const Element *pv = pv0;
1694 const Element *
const mp_last = mp + this->
fNelems;
1697 for (; mp < mp_last; pv = pv0)
1702 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv - pv0));
1707 for (; mp < mp_last; pv = pv0)
1718template <
class Element>
1722 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1737template <
class Element>
1741 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1756template <
class Element>
1760 this->GetRowLwb() != source.
GetRowLwb() || this->GetColLwb() != source.
GetColLwb()) {
1761 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1775 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
1777 const Int_t sIndex = pRowIndex[irow];
1778 const Int_t eIndex = pRowIndex[irow + 1];
1790template <
class Element>
1795 if (lazy_constructor.
GetRowUpb() != this->GetRowUpb() || lazy_constructor.
GetColUpb() != this->GetColUpb() ||
1796 lazy_constructor.
GetRowLwb() != this->GetRowLwb() || lazy_constructor.
GetColLwb() != this->GetColLwb()) {
1797 Error(
"operator=(const TMatrixTLazy&)",
"matrix is incompatible with "
1798 "the assigned Lazy matrix");
1802 lazy_constructor.
FillIn(*
this);
1809template <
class Element>
1815 const Element *
const ep_last = ep + this->
fNelems;
1816 while (ep < ep_last)
1825template <
class Element>
1831 const Element *
const ep_last = ep + this->
fNelems;
1832 while (ep < ep_last)
1841template <
class Element>
1847 const Element *
const ep_last = ep + this->
fNelems;
1848 while (ep < ep_last)
1857template <
class Element>
1863 const Element *
const ep_last = ep + this->
fNelems;
1864 while (ep < ep_last)
1873template <
class Element>
1877 Error(
"operator+=(const TMatrixT &)",
"matrices not compatible");
1883 const Element *
const tp_last = tp + this->
fNelems;
1884 while (tp < tp_last)
1893template <
class Element>
1897 Error(
"operator+=(const TMatrixTSym &)",
"matrices not compatible");
1903 const Element *
const tp_last = tp + this->
fNelems;
1904 while (tp < tp_last)
1913template <
class Element>
1917 Error(
"operator=-(const TMatrixT &)",
"matrices not compatible");
1923 const Element *
const tp_last = tp + this->
fNelems;
1924 while (tp < tp_last)
1933template <
class Element>
1937 Error(
"operator=-(const TMatrixTSym &)",
"matrices not compatible");
1943 const Element *
const tp_last = tp + this->
fNelems;
1944 while (tp < tp_last)
1955template <
class Element>
1963 Error(
"operator*=(const TMatrixT &)",
"source matrix has wrong shape");
1972 tmp.ResizeTo(source);
1974 sp = tmp.GetMatrixArray();
1981 Element *trp = work;
1983 isAllocated =
kTRUE;
1984 trp =
new Element[this->
fNcols];
1988 const Element *trp0 = cp;
1989 const Element *
const trp0_last = trp0 + this->
fNelems;
1990 while (trp0 < trp0_last) {
1991 memcpy(trp, trp0, this->
fNcols *
sizeof(Element));
1992 for (
const Element *scp = sp; scp < sp + this->
fNcols;) {
1995 for (
Int_t j = 0; j < this->fNcols; j++) {
1996 cij += trp[j] * *scp;
1997 scp += this->fNcols;
2002 trp0 += this->fNcols;
2006 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2017template <
class Element>
2024 Error(
"operator*=(const TMatrixTSym &)",
"source matrix has wrong shape");
2033 tmp.ResizeTo(source);
2035 sp = tmp.GetMatrixArray();
2042 Element *trp = work;
2044 isAllocated =
kTRUE;
2045 trp =
new Element[this->
fNcols];
2049 const Element *trp0 = cp;
2050 const Element *
const trp0_last = trp0 + this->
fNelems;
2051 while (trp0 < trp0_last) {
2052 memcpy(trp, trp0, this->
fNcols *
sizeof(Element));
2053 for (
const Element *scp = sp; scp < sp + this->
fNcols;) {
2056 for (
Int_t j = 0; j < this->fNcols; j++) {
2057 cij += trp[j] * *scp;
2058 scp += this->fNcols;
2063 trp0 += this->fNcols;
2067 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2078template <
class Element>
2085 Error(
"operator*=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2091 const Element *
const mp_last = mp + this->
fNelems;
2093 while (mp < mp_last) {
2094 const Element *dp = diag.
GetPtr();
2108template <
class Element>
2115 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2121 const Element *
const mp_last = mp + this->
fNelems;
2123 while (mp < mp_last) {
2124 const Element *dp = diag.
GetPtr();
2129 Error(
"operator/=",
"%d-diagonal element is zero", j);
2143template <
class Element>
2152 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2159 const Element *
const mp_last = mp + this->
fNelems;
2160 const Element *cp = col.
GetPtr();
2162 while (mp < mp_last) {
2176template <
class Element>
2185 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2192 const Element *
const mp_last = mp + this->
fNelems;
2193 const Element *cp = col.
GetPtr();
2195 while (mp < mp_last) {
2202 Error(
"operator/=",
"%d-row of matrix column is zero", icol);
2215template <
class Element>
2224 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2231 const Element *
const mp_last = mp + this->
fNelems;
2233 while (mp < mp_last) {
2234 const Element *rp = row.
GetPtr();
2249template <
class Element>
2257 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2263 const Element *
const mp_last = mp + this->
fNelems;
2265 while (mp < mp_last) {
2266 const Element *rp = row.
GetPtr();
2272 Error(
"operator/=",
"%d-col of matrix row is zero", j);
2288template <
class Element>
2292 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2302template <
class Element>
2313template <
class Element>
2324template <
class Element>
2333template <
class Element>
2344template <
class Element>
2353template <
class Element>
2364template <
class Element>
2375template <
class Element>
2378 return Element(-1.0) * (
operator-(source2, source1));
2384template <
class Element>
2395template <
class Element>
2398 return Element(-1.0) *
operator-(source, val);
2404template <
class Element>
2415template <
class Element>
2424template <
class Element>
2434template <
class Element>
2444template <
class Element>
2454template <
class Element>
2465template <
class Element>
2471 Error(
"operator&&(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2475 target.ResizeTo(source1);
2479 Element *tp =
target.GetMatrixArray();
2480 const Element *
const tp_last = tp +
target.GetNoElements();
2481 while (tp < tp_last)
2482 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2490template <
class Element>
2496 Error(
"operator&&(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2500 target.ResizeTo(source1);
2504 Element *tp =
target.GetMatrixArray();
2505 const Element *
const tp_last = tp +
target.GetNoElements();
2506 while (tp < tp_last)
2507 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2515template <
class Element>
2524template <
class Element>
2530 Error(
"operator||(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2534 target.ResizeTo(source1);
2538 Element *tp =
target.GetMatrixArray();
2539 const Element *
const tp_last = tp +
target.GetNoElements();
2540 while (tp < tp_last)
2541 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2549template <
class Element>
2555 Error(
"operator||(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2559 target.ResizeTo(source1);
2563 Element *tp =
target.GetMatrixArray();
2564 const Element *
const tp_last = tp +
target.GetNoElements();
2565 while (tp < tp_last)
2566 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2574template <
class Element>
2583template <
class Element>
2589 Error(
"operator|(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2593 target.ResizeTo(source1);
2597 Element *tp =
target.GetMatrixArray();
2598 const Element *
const tp_last = tp +
target.GetNoElements();
2599 while (tp < tp_last) {
2600 *tp++ = (*sp1) > (*sp2);
2611template <
class Element>
2617 Error(
"operator>(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2621 target.ResizeTo(source1);
2625 Element *tp =
target.GetMatrixArray();
2626 const Element *
const tp_last = tp +
target.GetNoElements();
2627 while (tp < tp_last) {
2628 *tp++ = (*sp1) > (*sp2);
2639template <
class Element>
2648template <
class Element>
2654 Error(
"operator>=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2658 target.ResizeTo(source1);
2662 Element *tp =
target.GetMatrixArray();
2663 const Element *
const tp_last = tp +
target.GetNoElements();
2664 while (tp < tp_last) {
2665 *tp++ = (*sp1) >= (*sp2);
2676template <
class Element>
2682 Error(
"operator>=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2686 target.ResizeTo(source1);
2690 Element *tp =
target.GetMatrixArray();
2691 const Element *
const tp_last = tp +
target.GetNoElements();
2692 while (tp < tp_last) {
2693 *tp++ = (*sp1) >= (*sp2);
2704template <
class Element>
2713template <
class Element>
2719 Error(
"operator<=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2723 target.ResizeTo(source1);
2727 Element *tp =
target.GetMatrixArray();
2728 const Element *
const tp_last = tp +
target.GetNoElements();
2729 while (tp < tp_last) {
2730 *tp++ = (*sp1) <= (*sp2);
2741template <
class Element>
2747 Error(
"operator<=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2751 target.ResizeTo(source1);
2755 Element *tp =
target.GetMatrixArray();
2756 const Element *
const tp_last = tp +
target.GetNoElements();
2757 while (tp < tp_last) {
2758 *tp++ = (*sp1) <= (*sp2);
2769template <
class Element>
2778template <
class Element>
2784 Error(
"operator<(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2790 Element *tp =
target.GetMatrixArray();
2791 const Element *
const tp_last = tp +
target.GetNoElements();
2792 while (tp < tp_last) {
2793 *tp++ = (*sp1) < (*sp2);
2804template <
class Element>
2810 Error(
"operator<(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2814 target.ResizeTo(source1);
2818 Element *tp =
target.GetMatrixArray();
2819 const Element *
const tp_last = tp +
target.GetNoElements();
2820 while (tp < tp_last) {
2821 *tp++ = (*sp1) < (*sp2);
2832template <
class Element>
2841template <
class Element>
2847 Error(
"operator!=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2851 target.ResizeTo(source1);
2855 Element *tp =
target.GetMatrixArray();
2856 const Element *
const tp_last = tp +
target.GetNoElements();
2857 while (tp != tp_last) {
2858 *tp++ = (*sp1) != (*sp2);
2869template <
class Element>
2875 Error(
"operator!=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2879 target.ResizeTo(source1);
2883 Element *tp =
target.GetMatrixArray();
2884 const Element *
const tp_last = tp +
target.GetNoElements();
2885 while (tp != tp_last) {
2886 *tp++ = (*sp1) != (*sp2);
2897template <
class Element>
2907template<class Element>
2908TMatrixT<Element> operator!=(const TMatrixT<Element> &source1,Element val)
2910 TMatrixT<Element> target; target.ResizeTo(source1);
2912 const Element *sp = source1.GetMatrixArray();
2913 Element *tp = target.GetMatrixArray();
2914 const Element * const tp_last = tp+target.GetNoElements();
2915 while (tp != tp_last) {
2916 *tp++ = (*sp != val); sp++;
2925template<class Element>
2926TMatrixT<Element> operator!=(Element val,const TMatrixT<Element> &source1)
2928 return operator!=(source1,val);
2935template <
class Element>
2939 ::Error(
"Add(TMatrixT &,Element,const TMatrixT &)",
"matrices not compatible");
2944 Element *tp =
target.GetMatrixArray();
2945 const Element *ftp = tp +
target.GetNoElements();
2948 *tp++ = scalar * (*sp++);
2949 }
else if (scalar == 1.) {
2954 *tp++ += scalar * (*sp++);
2963template <
class Element>
2968 ::Error(
"Add(TMatrixT &,Element,const TMatrixTSym &)",
"matrices not compatible");
2973 Element *tp =
target.GetMatrixArray();
2974 const Element *ftp = tp +
target.GetNoElements();
2976 *tp++ += scalar * (*sp++);
2984template <
class Element>
2988 ::Error(
"ElementMult(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2993 Element *tp =
target.GetMatrixArray();
2994 const Element *ftp = tp +
target.GetNoElements();
3004template <
class Element>
3008 ::Error(
"ElementMult(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3013 Element *tp =
target.GetMatrixArray();
3014 const Element *ftp = tp +
target.GetNoElements();
3024template <
class Element>
3028 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3033 Element *tp =
target.GetMatrixArray();
3034 const Element *ftp = tp +
target.GetNoElements();
3041 Error(
"ElementDiv",
"source (%d,%d) is zero", irow, icol);
3052template <
class Element>
3056 ::Error(
"ElementDiv(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3061 Element *tp =
target.GetMatrixArray();
3062 const Element *ftp = tp +
target.GetNoElements();
3069 Error(
"ElementDiv",
"source (%d,%d) is zero", irow, icol);
3080template <
class Element>
3082 Int_t ncolsb, Element *cp)
3084 const Element *arp0 = ap;
3085 while (arp0 < ap + na) {
3086 for (
const Element *bcp = bp; bcp < bp + ncolsb;) {
3087 const Element *arp = arp0;
3089 while (bcp < bp + nb) {
3090 cij += *arp++ * *bcp;
3103template <
class Element>
3105 Int_t ncolsb, Element *cp)
3107 const Element *acp0 = ap;
3108 while (acp0 < ap + ncolsa) {
3109 for (
const Element *bcp = bp; bcp < bp + ncolsb;) {
3110 const Element *acp = acp0;
3112 while (bcp < bp + nb) {
3127template <
class Element>
3129 Int_t ncolsb, Element *cp)
3131 const Element *arp0 = ap;
3132 while (arp0 < ap + na) {
3133 const Element *brp0 = bp;
3134 while (brp0 < bp + nb) {
3135 const Element *arp = arp0;
3136 const Element *brp = brp0;
3138 while (brp < brp0 + ncolsb)
3139 cij += *arp++ * *brp++;
3150template <
class Element>
3159 }
else if (R__v == 2) {
3171 if (this->fNelems > 0) {
3192 for (
Int_t j =
i; j < this->fNcols; j++) {
3193 const Int_t off_j = j * this->fNrows;
3194 const Element tmp =
fElements[off_i + j];
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define templateClassImp(name)
Bool_t operator<=(const TDatime &d1, const TDatime &d2)
Bool_t operator>(const TDatime &d1, const TDatime &d2)
Bool_t operator!=(const TDatime &d1, const TDatime &d2)
Bool_t operator>=(const TDatime &d1, const TDatime &d2)
Bool_t operator<(const TDatime &d1, const TDatime &d2)
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
TMatrixTSym< Double_t > TMatrixDSym
TMatrixT< Double_t > TMatrixD
TMatrixTSym< Float_t > TMatrixFSym
TMatrixT< Float_t > TMatrixF
R__EXTERN Int_t gMatrixCheck
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
TTime operator*(const TTime &t1, const TTime &t2)
TTime operator-(const TTime &t1, const TTime &t2)
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadArray(Bool_t *&b)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void Det(Double_t &d1, Double_t &d2) override
Calculate determinant det = d1*TMath::Power(2.,d2)
static Bool_t InvertLU(TMatrixD &a, Double_t tol, Double_t *det=nullptr)
Calculate matrix inversion through in place forward/backward substitution.
const TMatrixD & GetEigenVectors() const
const TVectorD & GetEigenValuesRe() const
virtual const Element * GetMatrixArray() const =0
virtual TMatrixTBase< Float_t > & UnitMatrix()
virtual const Int_t * GetRowIndexArray() const =0
virtual const Int_t * GetColIndexArray() const =0
Int_t GetNoElements() const
Float_t SetTol(Float_t tol)
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
Copy array data to matrix .
const TMatrixTBase< Element > * GetMatrix() const
const Element * GetPtr() const
const Element * GetPtr() const
const TMatrixTBase< Element > * GetMatrix() const
Templates of Lazy Matrix classes.
virtual void FillIn(TMatrixT< Element > &m) const =0
const Element * GetPtr() const
const TMatrixTBase< Element > * GetMatrix() const
const Int_t * GetRowIndexArray() const override
const Int_t * GetColIndexArray() const override
const Element * GetMatrixArray() const override
TMatrixTSym< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant Notice that the LU decomposition is used instead of B...
const Element * GetMatrixArray() const override
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 override
Get submatrix [row_lwb..row_upb] x [col_lwb..col_upb]; The indexing range of the returned matrix depe...
TMatrixT< Element > & Rank1Update(const TVectorT< Element > &v, Element alpha=1.0)
Perform a rank 1 operation on matrix A: A += alpha * v * v^T.
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])
void Clear(Option_t *="") override
void Delete_m(Int_t size, Element *&)
Delete data pointer m, if it was assigned on the heap.
void Streamer(TBuffer &) override
Stream an object of class TMatrixT.
TMatrixT< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
Element fDataStack[TMatrixTBase< Element >::kSizeMax]
TMatrixT< Element > & operator=(const TMatrixT< Element > &source)
Assignment operator.
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,...
const Element * GetMatrixArray() const override
void Minus(const TMatrixT< Float_t > &a, const TMatrixT< Float_t > &b)
TClass * IsA() const override
Element Similarity(const TVectorT< Element > &v) const
Calculate scalar v * (*this) * v^T.
void Plus(const TMatrixT< Float_t > &a, const TMatrixT< Float_t > &b)
TMatrixT< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
Double_t Determinant() const override
Return the matrix determinant.
TMatrixT< Float_t > & Transpose(const TMatrixT< Float_t > &source)
void MultT(const TMatrixT< Float_t > &a, const TMatrixT< Float_t > &b)
TMatrixT< Element > & InvertFast(Double_t *det=nullptr)
Invert the matrix and calculate its determinant, however upto (6x6) a fast Cramer inversion is used .
TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source) override
Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part [row_lwb....
Element * New_m(Int_t size)
Return data pointer .
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixT< Float_t > & Invert(Double_t *det=nullptr)
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.
TMatrixT< Element > & operator+=(Element val)
Add val to every element of the matrix.
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,...
void TMult(const TMatrixT< Float_t > &a, const TMatrixT< Float_t > &b)
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. Replace this matrix with C such that C = A * B.
Element * fElements
data container
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 .
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.
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
void ToUpper()
Change string to upper case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
TMatrixT< Element > operator!=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 != source2
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 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.
TMatrixT< Element > operator+(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1+source2
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.
TMatrixT< Element > operator>=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 >= source2
TMatrixT< Element > & ElementMult(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Multiply target by the source, element-by-element.
TMatrixT< Element > operator||(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical OR.
TMatrixT< Element > operator<(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 < source2
TMatrixT< Element > operator>(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 > source2
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
TMatrixT< Element > & ElementDiv(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Divide target by the source, element-by-element.
Element1 Mult(const TVectorT< Element1 > &v1, const TMatrixT< Element2 > &m, const TVectorT< Element3 > &v2)
Perform v1 * M * v2, a scalar result.
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)
logical operation source1 <= source2
TMatrixT< Element > operator&&(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical AND.
TMatrixT< Element > operator*(Element val, const TMatrixT< Element > &source)
operation this = val*source
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 .
Bool_t Inv6x6(TMatrixT< Element > &m, Double_t *determ)
Bool_t Inv3x3(TMatrixT< Element > &m, Double_t *determ)
Bool_t Inv4x4(TMatrixT< Element > &m, Double_t *determ)
Bool_t Inv2x2(TMatrixT< Element > &m, Double_t *determ)
Bool_t Inv5x5(TMatrixT< Element > &m, Double_t *determ)