39template <
class Element>
42 Allocate(nrows, ncols, 0, 0, 1);
48template <
class Element>
51 Allocate(row_upb - row_lwb + 1, col_upb - col_lwb + 1, row_lwb, col_lwb, 1);
62template <
class Element>
65 Allocate(no_rows, no_cols);
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>
135 Transpose(prototype);
143 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
145 this->SetTol(oldTol);
151 TMult(prototype, prototype);
154 default:
Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
164template <
class Element>
172 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
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());
193 this->SetTol(oldTol);
197 const Element oldTol = ainv.
SetTol(std::numeric_limits<Element>::min());
206 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
212 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
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());
253 this->SetTol(oldTol);
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());
309 this->SetTol(oldTol);
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());
369 this->SetTol(oldTol);
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>
409 if (
size > this->kSizeMax)
419template <
class Element>
425 if (size <= this->kSizeMax)
428 Element *heap =
new Element[
size];
438template <
class Element>
441 if (copySize == 0 || oldp == newp)
444 if (newSize <= this->kSizeMax && oldSize <= this->kSizeMax) {
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>
467 this->fIsOwner =
kTRUE;
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);
483 this->fNrows = no_rows;
484 this->fNcols = no_cols;
485 this->fRowLwb = row_lwb;
486 this->fColLwb = col_lwb;
487 this->fNelems = this->fNrows * this->fNcols;
490 if (((
Long64_t)this->fNrows) * this->fNcols != this->fNelems) {
491 Error(
"Allocate",
"too large: no_rows=%d no_cols=%d", no_rows, no_cols);
496 if (this->fNelems > 0) {
497 fElements = New_m(this->fNelems);
499 memset(fElements, 0, this->fNelems *
sizeof(Element));
507template <
class Element>
512 Error(
"Plus",
"matrices not compatible");
516 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
517 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
521 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
522 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
527 const Element *ap =
a.GetMatrixArray();
528 const Element *bp =
b.GetMatrixArray();
529 Element *cp = this->GetMatrixArray();
530 const Element *
const cp_last = cp + this->fNelems;
532 while (cp < cp_last) {
541template <
class Element>
546 Error(
"Plus",
"matrices not compatible");
550 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
551 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
555 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
556 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
561 const Element *ap =
a.GetMatrixArray();
562 const Element *bp =
b.GetMatrixArray();
563 Element *cp = this->GetMatrixArray();
564 const Element *
const cp_last = cp + this->fNelems;
566 while (cp < cp_last) {
575template <
class Element>
580 Error(
"Minus",
"matrices not compatible");
584 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
585 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
589 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
590 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
595 const Element *ap =
a.GetMatrixArray();
596 const Element *bp =
b.GetMatrixArray();
597 Element *cp = this->GetMatrixArray();
598 const Element *
const cp_last = cp + this->fNelems;
600 while (cp < cp_last) {
609template <
class Element>
614 Error(
"Minus",
"matrices not compatible");
618 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
619 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
623 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
624 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
629 const Element *ap =
a.GetMatrixArray();
630 const Element *bp =
b.GetMatrixArray();
631 Element *cp = this->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");
652 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
653 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
657 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
658 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
664 const Element *ap =
a.GetMatrixArray();
665 const Element *bp =
b.GetMatrixArray();
666 Element *cp = this->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();
682 Element *cp = this->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");
703 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
704 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
708 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
709 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
715 const Element *ap =
a.GetMatrixArray();
716 const Element *bp =
b.GetMatrixArray();
717 Element *cp = this->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();
733 Element *cp = this->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");
755 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
756 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
760 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
761 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
767 const Element *ap =
a.GetMatrixArray();
768 const Element *bp =
b.GetMatrixArray();
769 Element *cp = this->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();
785 Element *cp = this->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");
807 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
808 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
812 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
813 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
819 const Element *ap =
a.GetMatrixArray();
820 const Element *bp =
b.GetMatrixArray();
821 Element *cp = this->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();
837 Element *cp = this->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");
858 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
859 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
863 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
864 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
870 const Element *ap =
a.GetMatrixArray();
871 const Element *bp =
b.GetMatrixArray();
872 Element *cp = this->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();
887 Element *cp = this->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");
908 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
909 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
913 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
914 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
920 const Element *ap =
a.GetMatrixArray();
921 const Element *bp =
b.GetMatrixArray();
922 Element *cp = this->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();
937 Element *cp = this->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");
958 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
959 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
963 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
964 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
970 const Element *ap =
a.GetMatrixArray();
971 const Element *bp =
b.GetMatrixArray();
972 Element *cp = this->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();
988 Element *cp = this->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");
1009 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
1010 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1014 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
1015 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1021 const Element *ap =
a.GetMatrixArray();
1022 const Element *bp =
b.GetMatrixArray();
1023 Element *cp = this->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();
1039 Element *cp = this->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;
1065 this->fRowLwb = row_lwb;
1066 this->fColLwb = col_lwb;
1067 this->fNelems = this->fNrows * this->fNcols;
1081template <
class Element>
1087 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb + this->fNrows - 1) {
1088 Error(
"GetSub",
"row_lwb out of bounds");
1091 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb + this->fNcols - 1) {
1092 Error(
"GetSub",
"col_lwb out of bounds");
1095 if (row_upb < this->fRowLwb || row_upb > this->fRowLwb + this->fNrows - 1) {
1096 Error(
"GetSub",
"row_upb out of bounds");
1099 if (col_upb < this->fColLwb || col_upb > this->fColLwb + this->fNcols - 1) {
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);
1129 const Element *ap = this->GetMatrixArray() + (row_lwb - this->fRowLwb) * this->fNcols + (col_lwb - this->fColLwb);
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>
1155 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb + this->fNrows - 1) {
1156 Error(
"SetSub",
"row_lwb outof bounds");
1159 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb + this->fNcols - 1) {
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);
1183 Element *ap = this->GetMatrixArray() + (row_lwb - this->fRowLwb) * this->fNcols + (col_lwb - this->fColLwb);
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>
1206 if (!this->fIsOwner) {
1207 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1211 if (this->fNelems > 0) {
1212 if (this->fNrows == nrows && this->fNcols == ncols)
1214 else if (nrows == 0 || ncols == 0) {
1215 this->fNrows = nrows;
1216 this->fNcols = ncols;
1221 Element *elements_old = GetMatrixArray();
1222 const Int_t nelems_old = this->fNelems;
1223 const Int_t nrows_old = this->fNrows;
1224 const Int_t ncols_old = this->fNcols;
1226 Allocate(nrows, ncols);
1229 Element *elements_new = GetMatrixArray();
1232 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
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));
1241 const Int_t nelems_new = this->fNelems;
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);
1245 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
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);
1255 Allocate(nrows, ncols, 0, 0, 1);
1266template <
class Element>
1271 if (!this->fIsOwner) {
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;
1279 if (this->fNelems > 0) {
1281 if (this->fNrows == new_nrows && this->fNcols == new_ncols && this->fRowLwb == row_lwb &&
1282 this->fColLwb == col_lwb)
1284 else if (new_nrows == 0 || new_ncols == 0) {
1285 this->fNrows = new_nrows;
1286 this->fNcols = new_ncols;
1287 this->fRowLwb = row_lwb;
1288 this->fColLwb = col_lwb;
1293 Element *elements_old = GetMatrixArray();
1294 const Int_t nelems_old = this->fNelems;
1295 const Int_t nrows_old = this->fNrows;
1296 const Int_t ncols_old = this->fNcols;
1297 const Int_t rowLwb_old = this->fRowLwb;
1298 const Int_t colLwb_old = this->fColLwb;
1300 Allocate(new_nrows, new_ncols, row_lwb, col_lwb);
1303 Element *elements_new = GetMatrixArray();
1306 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
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));
1314 const Int_t rowUpb_copy =
TMath::Min(this->fRowLwb + this->fNrows - 1, rowLwb_old + nrows_old - 1);
1315 const Int_t colUpb_copy =
TMath::Min(this->fColLwb + this->fNcols - 1, colLwb_old + ncols_old - 1);
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;
1322 const Int_t colNewOff = colLwb_copy - this->fColLwb;
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;
1326 const Int_t iRowNew = rowLwb_copy + i - this->fRowLwb;
1327 Memcpy_m(elements_new + iRowNew * this->fNcols + colNewOff,
1328 elements_old + iRowOld * ncols_old + colOldOff, ncols_copy, this->fNelems, nelems_old);
1329 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
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;
1336 const Int_t iRowNew = rowLwb_copy + i - this->fRowLwb;
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>
1411 if (this->GetNrows() != this->GetNcols() || this->GetRowLwb() != this->GetColLwb()) {
1412 Error(
"Invert()",
"matrix should be square");
1414 Element *pM = this->GetMatrixArray();
1416 Error(
"InvertFast",
"matrix is singular");
1426 TMatrixTCramerInv::Inv2x2<Element>(*
this, det);
1430 TMatrixTCramerInv::Inv3x3<Element>(*
this, det);
1434 TMatrixTCramerInv::Inv4x4<Element>(*
this, det);
1438 TMatrixTCramerInv::Inv5x5<Element>(*
this, det);
1442 TMatrixTCramerInv::Inv6x6<Element>(*
this, det);
1454template <
class Element>
1461 Element *ap = this->GetMatrixArray();
1462 if (this->fNrows == this->fNcols && this->fRowLwb == this->fColLwb) {
1463 for (
Int_t i = 0; i < this->fNrows; i++) {
1464 const Int_t off_i = i * this->fNrows;
1465 for (
Int_t j = i + 1; j < this->fNcols; j++) {
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;
1475 const Int_t nrows_old = this->fNrows;
1476 const Int_t ncols_old = this->fNcols;
1477 const Int_t rowlwb_old = this->fRowLwb;
1478 const Int_t collwb_old = this->fColLwb;
1480 this->fNrows = ncols_old;
1481 this->fNcols = nrows_old;
1482 this->fRowLwb = collwb_old;
1483 this->fColLwb = rowlwb_old;
1484 for (
Int_t irow = this->fRowLwb; irow < this->fRowLwb + this->fNrows; irow++) {
1485 for (
Int_t icol = this->fColLwb; icol < this->fColLwb + this->fNcols; icol++) {
1486 const Int_t off = (icol - collwb_old) * ncols_old;
1487 (*this)(irow, icol) = oldElems[off + irow - rowlwb_old];
1493 if (this->fNrows != source.
GetNcols() || this->fNcols != source.
GetNrows() ||
1495 Error(
"Transpose",
"matrix has wrong shape");
1500 const Element *scp = sp1;
1501 Element *tp = this->GetMatrixArray();
1502 const Element *
const tp_last = this->GetMatrixArray() + this->fNelems;
1506 while (tp < tp_last) {
1507 const Element *sp2 = scp++;
1510 while (sp2 < sp1 + this->fNelems) {
1512 sp2 += this->fNrows;
1515 R__ASSERT(tp == tp_last && scp == sp1 + this->fNrows);
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();
1538 Element *mp = this->GetMatrixArray();
1540 for (
Int_t i = 0; i < this->fNrows; i++) {
1541 const Element tmp = alpha * pv[i];
1542 for (
Int_t j = 0; j < this->fNcols; j++)
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();
1574 Element *mp = this->GetMatrixArray();
1576 for (
Int_t i = 0; i < this->fNrows; i++) {
1577 const Element tmp = alpha * pv1[i];
1578 for (
Int_t j = 0; j < this->fNcols; j++)
1579 *mp++ += tmp * pv2[j];
1588template <
class Element>
1594 if (this->fNcols != this->fNrows || this->fColLwb != this->fRowLwb) {
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");
1605 const Element *mp = this->GetMatrixArray();
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++;
1618 R__ASSERT(mp == this->GetMatrixArray() + this->GetNoElements());
1629template <
class Element>
1635 if (
v.GetNoElements() < this->fNrows) {
1636 Error(
"NormByColumn",
"vector shorter than matrix column");
1645 const Element *pv =
v.GetMatrixArray();
1646 Element *mp = this->GetMatrixArray();
1647 const Element *
const mp_last = mp + this->fNelems;
1650 for (; mp < mp_last; pv++) {
1651 for (
Int_t j = 0; j < this->fNcols; j++) {
1655 Error(
"NormbyColumn",
"vector element %ld is zero",
Long_t(pv -
v.GetMatrixArray()));
1661 for (; mp < mp_last; pv++)
1662 for (
Int_t j = 0; j < this->fNcols; j++)
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;
1693 Element *mp = this->GetMatrixArray();
1694 const Element *
const mp_last = mp + this->fNelems;
1697 for (; mp < mp_last; pv = pv0)
1698 for (
Int_t j = 0; j < this->fNcols; j++) {
1702 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv - pv0));
1707 for (; mp < mp_last; pv = pv0)
1708 for (
Int_t j = 0; j < this->fNcols; j++)
1718template <
class Element>
1722 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1728 memcpy(fElements, source.
GetMatrixArray(), this->fNelems *
sizeof(Element));
1729 this->fTol = source.
GetTol();
1737template <
class Element>
1741 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1747 memcpy(fElements, source.
GetMatrixArray(), this->fNelems *
sizeof(Element));
1748 this->fTol = source.
GetTol();
1756template <
class Element>
1760 this->GetRowLwb() != source.
GetRowLwb() || this->GetColLwb() != source.
GetColLwb()) {
1761 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1767 memset(fElements, 0, this->fNelems *
sizeof(Element));
1770 Element *tp = this->GetMatrixArray();
1775 for (
Int_t irow = 0; irow < this->fNrows; irow++) {
1776 const Int_t off = irow * this->fNcols;
1777 const Int_t sIndex = pRowIndex[irow];
1778 const Int_t eIndex = pRowIndex[irow + 1];
1782 this->fTol = source.
GetTol();
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>
1814 Element *ep = this->GetMatrixArray();
1815 const Element *
const ep_last = ep + this->fNelems;
1816 while (ep < ep_last)
1825template <
class Element>
1830 Element *ep = this->GetMatrixArray();
1831 const Element *
const ep_last = ep + this->fNelems;
1832 while (ep < ep_last)
1841template <
class Element>
1846 Element *ep = this->GetMatrixArray();
1847 const Element *
const ep_last = ep + this->fNelems;
1848 while (ep < ep_last)
1857template <
class Element>
1862 Element *ep = this->GetMatrixArray();
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");
1882 Element *tp = this->GetMatrixArray();
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");
1902 Element *tp = this->GetMatrixArray();
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");
1922 Element *tp = this->GetMatrixArray();
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");
1942 Element *tp = this->GetMatrixArray();
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();
1979 Element work[kWorkMax];
1981 Element *trp = work;
1982 if (this->fNcols > kWorkMax) {
1983 isAllocated =
kTRUE;
1984 trp =
new Element[this->fNcols];
1987 Element *cp = this->GetMatrixArray();
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();
2040 Element work[kWorkMax];
2042 Element *trp = work;
2043 if (this->fNcols > kWorkMax) {
2044 isAllocated =
kTRUE;
2045 trp =
new Element[this->fNcols];
2048 Element *cp = this->GetMatrixArray();
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");
2090 Element *mp = this->GetMatrixArray();
2091 const Element *
const mp_last = mp + this->fNelems;
2093 while (mp < mp_last) {
2094 const Element *dp = diag.
GetPtr();
2095 for (
Int_t j = 0; j < this->fNcols; j++) {
2108template <
class Element>
2115 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2120 Element *mp = this->GetMatrixArray();
2121 const Element *
const mp_last = mp + this->fNelems;
2123 while (mp < mp_last) {
2124 const Element *dp = diag.
GetPtr();
2125 for (
Int_t j = 0; j < this->fNcols; j++) {
2129 Error(
"operator/=",
"%d-diagonal element is zero", j);
2143template <
class Element>
2151 if (this->fNrows != mt->
GetNrows()) {
2152 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2158 Element *mp = this->GetMatrixArray();
2159 const Element *
const mp_last = mp + this->fNelems;
2160 const Element *cp = col.
GetPtr();
2162 while (mp < mp_last) {
2164 for (
Int_t j = 0; j < this->fNcols; j++)
2176template <
class Element>
2184 if (this->fNrows != mt->
GetNrows()) {
2185 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2191 Element *mp = this->GetMatrixArray();
2192 const Element *
const mp_last = mp + this->fNelems;
2193 const Element *cp = col.
GetPtr();
2195 while (mp < mp_last) {
2198 for (
Int_t j = 0; j < this->fNcols; j++)
2202 Error(
"operator/=",
"%d-row of matrix column is zero", icol);
2215template <
class Element>
2223 if (this->fNcols != mt->
GetNcols()) {
2224 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2230 Element *mp = this->GetMatrixArray();
2231 const Element *
const mp_last = mp + this->fNelems;
2233 while (mp < mp_last) {
2234 const Element *rp = row.
GetPtr();
2235 for (
Int_t j = 0; j < this->fNcols; j++) {
2249template <
class Element>
2256 if (this->fNcols != mt->
GetNcols()) {
2257 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2262 Element *mp = this->GetMatrixArray();
2263 const Element *
const mp_last = mp + this->fNelems;
2265 while (mp < mp_last) {
2266 const Element *rp = row.
GetPtr();
2267 for (
Int_t j = 0; j < this->fNcols; j++) {
2272 Error(
"operator/=",
"%d-col of matrix row is zero", j);
2288template <
class Element>
2291 if (!this->IsSymmetric())
2292 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2294 eigenValues.
ResizeTo(this->fNrows);
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) {
3163 R__b >> this->fNrows;
3164 R__b >> this->fNcols;
3165 R__b >> this->fNelems;
3166 R__b >> this->fRowLwb;
3167 R__b >> this->fColLwb;
3171 if (this->fNelems > 0) {
3172 fElements =
new Element[this->fNelems];
3175 fElements =
nullptr;
3181 R__b >> this->fNrows;
3182 R__b >> this->fNcols;
3183 R__b >> this->fRowLwb;
3184 R__b >> this->fColLwb;
3185 this->fNelems = R__b.
ReadArray(fElements);
3189 if (R__v <= 2 && fElements) {
3190 for (
Int_t i = 0; i < this->fNrows; i++) {
3191 const Int_t off_i = i * this->fNcols;
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];
3195 fElements[off_i + j] = fElements[off_j + i];
3196 fElements[off_j + i] = tmp;
3200 if (this->fNelems > 0 && this->fNelems <= this->kSizeMax) {
3202 memcpy(fDataStack, fElements, this->fNelems *
sizeof(Element));
3205 fElements = fDataStack;
3206 }
else if (this->fNelems < 0)
3263template void TMatrixTAutoloadOps::AMultB<Float_t>(
const Float_t *
const ap,
Int_t na,
Int_t ncolsa,
3265template void TMatrixTAutoloadOps::AtMultB<Float_t>(
const Float_t *
const ap,
Int_t ncolsa,
const Float_t *
const bp,
3267template void TMatrixTAutoloadOps::AMultBt<Float_t>(
const Float_t *
const ap,
Int_t na,
Int_t ncolsa,
3320template void TMatrixTAutoloadOps::AMultB<Double_t>(
const Double_t *
const ap,
Int_t na,
Int_t ncolsa,
3322template void TMatrixTAutoloadOps::AtMultB<Double_t>(
const Double_t *
const ap,
Int_t ncolsa,
const Double_t *
const bp,
3324template void TMatrixTAutoloadOps::AMultBt<Double_t>(
const Double_t *
const ap,
Int_t na,
Int_t ncolsa,
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)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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 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 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 char Point_t Rectangle_t WindowAttributes_t index
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 const Int_t * GetRowIndexArray() const =0
virtual const Int_t * GetColIndexArray() const =0
Int_t GetNoElements() const
Element SetTol(Element tol)
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 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.
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< Element > &a, const TMatrixT< Element > &b)
General matrix subtraction. Replace this matrix with C such that C = A - B.
Element Similarity(const TVectorT< Element > &v) const
Calculate scalar v * (*this) * v^T.
void Plus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Replace this matrix with C such that C = A + B.
TMatrixT< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
Double_t Determinant() const override
Return the matrix determinant.
TMatrixT< Element > & Transpose(const TMatrixT< Element > &source)
Transpose matrix source.
void MultT(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Replace this matrix with C such that C = A * B^T.
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< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
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< Element > &a, const TMatrixT< Element > &b)
Replace this matrix with C such that C = A' * 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.
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 .