38template <
class Element>
41 Allocate(nrows, ncols, 0, 0, 1);
47template <
class Element>
50 Allocate(row_upb - row_lwb + 1, col_upb - col_lwb + 1, row_lwb, col_lwb, 1);
61template <
class Element>
64 Allocate(no_rows, no_cols);
71template <
class Element>
75 Allocate(row_upb - row_lwb + 1, col_upb - col_lwb + 1, row_lwb, col_lwb);
82template <
class Element>
93template <
class Element>
104template <
class Element>
117template <
class Element>
134 Transpose(prototype);
142 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
144 this->SetTol(oldTol);
150 TMult(prototype, prototype);
153 default:
Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
163template <
class Element>
171 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
176 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
181 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
186 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
188 if (
a.GetNrows() ==
b.GetNcols()) {
190 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
192 this->SetTol(oldTol);
196 const Element oldTol = ainv.
SetTol(std::numeric_limits<Element>::min());
205 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
211 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
216 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
225template <
class Element>
233 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
238 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
243 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
248 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
250 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
252 this->SetTol(oldTol);
258 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
264 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
269 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
279template <
class Element>
287 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
292 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
297 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
302 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
304 if (
a.GetNrows() ==
b.GetNcols()) {
306 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
308 this->SetTol(oldTol);
312 const Element oldTol = ainv.
SetTol(std::numeric_limits<Element>::min());
321 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
327 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
332 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
341template <
class Element>
349 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(), 1);
354 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(), 1);
359 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(), 1);
364 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
366 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
368 this->SetTol(oldTol);
374 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
380 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(), 1);
385 default:
Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
392template <
class Element>
398 lazy_constructor.
FillIn(*
this);
404template <
class Element>
408 if (
size > this->kSizeMax)
418template <
class Element>
424 if (size <= this->kSizeMax)
427 Element *heap =
new Element[
size];
437template <
class Element>
440 if (copySize == 0 || oldp == newp)
443 if (newSize <= this->kSizeMax && oldSize <= this->kSizeMax) {
446 for (
Int_t i = copySize - 1; i >= 0; i--)
449 for (
Int_t i = 0; i < copySize; i++)
453 memcpy(newp, oldp, copySize *
sizeof(Element));
462template <
class Element>
466 this->fIsOwner =
kTRUE;
467 this->fTol = std::numeric_limits<Element>::epsilon();
475 if (no_rows < 0 || no_cols < 0) {
476 Error(
"Allocate",
"no_rows=%d no_cols=%d", no_rows, no_cols);
482 this->fNrows = no_rows;
483 this->fNcols = no_cols;
484 this->fRowLwb = row_lwb;
485 this->fColLwb = col_lwb;
486 this->fNelems = this->fNrows * this->fNcols;
489 if (((
Long64_t)this->fNrows) * this->fNcols != this->fNelems) {
490 Error(
"Allocate",
"too large: no_rows=%d no_cols=%d", no_rows, no_cols);
495 if (this->fNelems > 0) {
496 fElements = New_m(this->fNelems);
498 memset(fElements, 0, this->fNelems *
sizeof(Element));
506template <
class Element>
511 Error(
"Plus",
"matrices not compatible");
515 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
516 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
520 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
521 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
526 const Element *ap =
a.GetMatrixArray();
527 const Element *bp =
b.GetMatrixArray();
528 Element *cp = this->GetMatrixArray();
529 const Element *
const cp_last = cp + this->fNelems;
531 while (cp < cp_last) {
540template <
class Element>
545 Error(
"Plus",
"matrices not compatible");
549 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
550 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
554 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
555 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
560 const Element *ap =
a.GetMatrixArray();
561 const Element *bp =
b.GetMatrixArray();
562 Element *cp = this->GetMatrixArray();
563 const Element *
const cp_last = cp + this->fNelems;
565 while (cp < cp_last) {
574template <
class Element>
579 Error(
"Minus",
"matrices not compatible");
583 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
584 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
588 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
589 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
594 const Element *ap =
a.GetMatrixArray();
595 const Element *bp =
b.GetMatrixArray();
596 Element *cp = this->GetMatrixArray();
597 const Element *
const cp_last = cp + this->fNelems;
599 while (cp < cp_last) {
608template <
class Element>
613 Error(
"Minus",
"matrices not compatible");
617 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
618 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
622 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
623 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
628 const Element *ap =
a.GetMatrixArray();
629 const Element *bp =
b.GetMatrixArray();
630 Element *cp = this->GetMatrixArray();
631 const Element *
const cp_last = cp + this->fNelems;
633 while (cp < cp_last) {
642template <
class Element>
646 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
647 Error(
"Mult",
"A rows and B columns incompatible");
651 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
652 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
656 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
657 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
663 const Element *ap =
a.GetMatrixArray();
664 const Element *bp =
b.GetMatrixArray();
665 Element *cp = this->GetMatrixArray();
666 if (
typeid(Element) ==
typeid(
Double_t))
667 cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, fNrows, fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
668 b.GetNcols(), 1.0, cp, fNcols);
669 else if (
typeid(Element) !=
typeid(
Float_t))
670 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, fNrows, fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
671 b.GetNcols(), 1.0, cp, fNcols);
673 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
675 const Int_t na =
a.GetNoElements();
676 const Int_t nb =
b.GetNoElements();
677 const Int_t ncolsa =
a.GetNcols();
678 const Int_t ncolsb =
b.GetNcols();
679 const Element *
const ap =
a.GetMatrixArray();
680 const Element *
const bp =
b.GetMatrixArray();
681 Element *cp = this->GetMatrixArray();
683 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
691template <
class Element>
697 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
698 Error(
"Mult",
"A rows and B columns incompatible");
702 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
703 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
707 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
708 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
714 const Element *ap =
a.GetMatrixArray();
715 const Element *bp =
b.GetMatrixArray();
716 Element *cp = this->GetMatrixArray();
717 if (
typeid(Element) ==
typeid(
Double_t))
718 cblas_dsymm(CblasRowMajor, CblasLeft, CblasUpper, fNrows, fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
720 else if (
typeid(Element) !=
typeid(
Float_t))
721 cblas_ssymm(CblasRowMajor, CblasLeft, CblasUpper, fNrows, fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
724 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
726 const Int_t na =
a.GetNoElements();
727 const Int_t nb =
b.GetNoElements();
728 const Int_t ncolsa =
a.GetNcols();
729 const Int_t ncolsb =
b.GetNcols();
730 const Element *
const ap =
a.GetMatrixArray();
731 const Element *
const bp =
b.GetMatrixArray();
732 Element *cp = this->GetMatrixArray();
734 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
743template <
class Element>
749 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
750 Error(
"Mult",
"A rows and B columns incompatible");
754 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
755 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
759 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
760 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
766 const Element *ap =
a.GetMatrixArray();
767 const Element *bp =
b.GetMatrixArray();
768 Element *cp = this->GetMatrixArray();
769 if (
typeid(Element) ==
typeid(
Double_t))
770 cblas_dsymm(CblasRowMajor, CblasRight, CblasUpper, fNrows, fNcols, 1.0, bp,
b.GetNcols(), ap,
a.GetNcols(), 0.0,
772 else if (
typeid(Element) !=
typeid(
Float_t))
773 cblas_ssymm(CblasRowMajor, CblasRight, CblasUpper, fNrows, fNcols, 1.0, bp,
b.GetNcols(), ap,
a.GetNcols(), 0.0,
776 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
778 const Int_t na =
a.GetNoElements();
779 const Int_t nb =
b.GetNoElements();
780 const Int_t ncolsa =
a.GetNcols();
781 const Int_t ncolsb =
b.GetNcols();
782 const Element *
const ap =
a.GetMatrixArray();
783 const Element *
const bp =
b.GetMatrixArray();
784 Element *cp = this->GetMatrixArray();
786 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
795template <
class Element>
801 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
802 Error(
"Mult",
"A rows and B columns incompatible");
806 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
807 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
811 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
812 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
818 const Element *ap =
a.GetMatrixArray();
819 const Element *bp =
b.GetMatrixArray();
820 Element *cp = this->GetMatrixArray();
821 if (
typeid(Element) ==
typeid(
Double_t))
822 cblas_dsymm(CblasRowMajor, CblasLeft, CblasUpper, fNrows, fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
824 else if (
typeid(Element) !=
typeid(
Float_t))
825 cblas_ssymm(CblasRowMajor, CblasLeft, CblasUpper, fNrows, fNcols, 1.0, ap,
a.GetNcols(), bp,
b.GetNcols(), 0.0,
828 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
830 const Int_t na =
a.GetNoElements();
831 const Int_t nb =
b.GetNoElements();
832 const Int_t ncolsa =
a.GetNcols();
833 const Int_t ncolsb =
b.GetNcols();
834 const Element *
const ap =
a.GetMatrixArray();
835 const Element *
const bp =
b.GetMatrixArray();
836 Element *cp = this->GetMatrixArray();
838 AMultB(ap, na, ncolsa, bp, nb, ncolsb, cp);
846template <
class Element>
852 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
853 Error(
"TMult",
"A rows and B columns incompatible");
857 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
858 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
862 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
863 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
869 const Element *ap =
a.GetMatrixArray();
870 const Element *bp =
b.GetMatrixArray();
871 Element *cp = this->GetMatrixArray();
872 if (
typeid(Element) ==
typeid(
Double_t))
873 cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, this->fNrows, this->fNcols,
a.GetNrows(), 1.0, ap,
874 a.GetNcols(), bp,
b.GetNcols(), 1.0, cp, this->fNcols);
875 else if (
typeid(Element) !=
typeid(
Float_t))
876 cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, fNrows, fNcols,
a.GetNrows(), 1.0, ap,
a.GetNcols(), bp,
877 b.GetNcols(), 1.0, cp, fNcols);
879 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
881 const Int_t nb =
b.GetNoElements();
882 const Int_t ncolsa =
a.GetNcols();
883 const Int_t ncolsb =
b.GetNcols();
884 const Element *
const ap =
a.GetMatrixArray();
885 const Element *
const bp =
b.GetMatrixArray();
886 Element *cp = this->GetMatrixArray();
888 AtMultB(ap, ncolsa, bp, nb, ncolsb, cp);
896template <
class Element>
902 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
903 Error(
"TMult",
"A rows and B columns incompatible");
907 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
908 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
912 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
913 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
919 const Element *ap =
a.GetMatrixArray();
920 const Element *bp =
b.GetMatrixArray();
921 Element *cp = this->GetMatrixArray();
922 if (
typeid(Element) ==
typeid(
Double_t))
923 cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, fNrows, fNcols,
a.GetNrows(), 1.0, ap,
a.GetNcols(), bp,
924 b.GetNcols(), 1.0, cp, fNcols);
925 else if (
typeid(Element) !=
typeid(
Float_t))
926 cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, fNrows, fNcols,
a.GetNrows(), 1.0, ap,
a.GetNcols(), bp,
927 b.GetNcols(), 1.0, cp, fNcols);
929 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
931 const Int_t nb =
b.GetNoElements();
932 const Int_t ncolsa =
a.GetNcols();
933 const Int_t ncolsb =
b.GetNcols();
934 const Element *
const ap =
a.GetMatrixArray();
935 const Element *
const bp =
b.GetMatrixArray();
936 Element *cp = this->GetMatrixArray();
938 AtMultB(ap, ncolsa, bp, nb, ncolsb, cp);
945template <
class Element>
952 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
953 Error(
"MultT",
"A rows and B columns incompatible");
957 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
958 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
962 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
963 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
969 const Element *ap =
a.GetMatrixArray();
970 const Element *bp =
b.GetMatrixArray();
971 Element *cp = this->GetMatrixArray();
972 if (
typeid(Element) ==
typeid(
Double_t))
973 cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, fNrows, fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
974 b.GetNcols(), 1.0, cp, fNcols);
975 else if (
typeid(Element) !=
typeid(
Float_t))
976 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, fNrows, fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
977 b.GetNcols(), 1.0, cp, fNcols);
979 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
981 const Int_t na =
a.GetNoElements();
982 const Int_t nb =
b.GetNoElements();
983 const Int_t ncolsa =
a.GetNcols();
984 const Int_t ncolsb =
b.GetNcols();
985 const Element *
const ap =
a.GetMatrixArray();
986 const Element *
const bp =
b.GetMatrixArray();
987 Element *cp = this->GetMatrixArray();
989 AMultBt(ap, na, ncolsa, bp, nb, ncolsb, cp);
997template <
class Element>
1003 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
1004 Error(
"MultT",
"A rows and B columns incompatible");
1008 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
1009 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1013 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
1014 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1020 const Element *ap =
a.GetMatrixArray();
1021 const Element *bp =
b.GetMatrixArray();
1022 Element *cp = this->GetMatrixArray();
1023 if (
typeid(Element) ==
typeid(
Double_t))
1024 cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, this->fNrows, this->fNcols,
a.GetNcols(), 1.0, ap,
1025 a.GetNcols(), bp,
b.GetNcols(), 1.0, cp, this->fNcols);
1026 else if (
typeid(Element) !=
typeid(
Float_t))
1027 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, fNrows, fNcols,
a.GetNcols(), 1.0, ap,
a.GetNcols(), bp,
1028 b.GetNcols(), 1.0, cp, fNcols);
1030 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
1032 const Int_t na =
a.GetNoElements();
1033 const Int_t nb =
b.GetNoElements();
1034 const Int_t ncolsa =
a.GetNcols();
1035 const Int_t ncolsb =
b.GetNcols();
1036 const Element *
const ap =
a.GetMatrixArray();
1037 const Element *
const bp =
b.GetMatrixArray();
1038 Element *cp = this->GetMatrixArray();
1040 AMultBt(ap, na, ncolsa, bp, nb, ncolsb, cp);
1047template <
class Element>
1051 if (row_upb < row_lwb) {
1052 Error(
"Use",
"row_upb=%d < row_lwb=%d", row_upb, row_lwb);
1055 if (col_upb < col_lwb) {
1056 Error(
"Use",
"col_upb=%d < col_lwb=%d", col_upb, col_lwb);
1062 this->fNrows = row_upb - row_lwb + 1;
1063 this->fNcols = col_upb - col_lwb + 1;
1064 this->fRowLwb = row_lwb;
1065 this->fColLwb = col_lwb;
1066 this->fNelems = this->fNrows * this->fNcols;
1080template <
class Element>
1086 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb + this->fNrows - 1) {
1087 Error(
"GetSub",
"row_lwb out of bounds");
1090 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb + this->fNcols - 1) {
1091 Error(
"GetSub",
"col_lwb out of bounds");
1094 if (row_upb < this->fRowLwb || row_upb > this->fRowLwb + this->fNrows - 1) {
1095 Error(
"GetSub",
"row_upb out of bounds");
1098 if (col_upb < this->fColLwb || col_upb > this->fColLwb + this->fNcols - 1) {
1099 Error(
"GetSub",
"col_upb out of bounds");
1102 if (row_upb < row_lwb || col_upb < col_lwb) {
1103 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1112 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1113 const Int_t row_upb_sub = (shift) ? row_upb - row_lwb : row_upb;
1114 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1115 const Int_t col_upb_sub = (shift) ? col_upb - col_lwb : col_upb;
1117 target.ResizeTo(row_lwb_sub, row_upb_sub, col_lwb_sub, col_upb_sub);
1118 const Int_t nrows_sub = row_upb_sub - row_lwb_sub + 1;
1119 const Int_t ncols_sub = col_upb_sub - col_lwb_sub + 1;
1121 if (
target.GetRowIndexArray() &&
target.GetColIndexArray()) {
1122 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1123 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1124 target(irow + row_lwb_sub, icol + col_lwb_sub) = (*this)(row_lwb + irow, col_lwb + icol);
1128 const Element *ap = this->GetMatrixArray() + (row_lwb - this->fRowLwb) * this->fNcols + (col_lwb - this->fColLwb);
1129 Element *bp =
target.GetMatrixArray();
1131 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1132 const Element *ap_sub = ap;
1133 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1147template <
class Element>
1154 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb + this->fNrows - 1) {
1155 Error(
"SetSub",
"row_lwb outof bounds");
1158 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb + this->fNcols - 1) {
1159 Error(
"SetSub",
"col_lwb outof bounds");
1162 if (row_lwb + source.
GetNrows() > this->fRowLwb + this->fNrows ||
1163 col_lwb + source.
GetNcols() > this->fColLwb + this->fNcols) {
1164 Error(
"SetSub",
"source matrix too large");
1175 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1176 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1177 (*this)(row_lwb + irow, col_lwb + icol) = source(rowlwb_s + irow, collwb_s + icol);
1182 Element *ap = this->GetMatrixArray() + (row_lwb - this->fRowLwb) * this->fNcols + (col_lwb - this->fColLwb);
1184 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1185 Element *ap_sub = ap;
1186 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1201template <
class Element>
1205 if (!this->fIsOwner) {
1206 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1210 if (this->fNelems > 0) {
1211 if (this->fNrows == nrows && this->fNcols == ncols)
1213 else if (nrows == 0 || ncols == 0) {
1214 this->fNrows = nrows;
1215 this->fNcols = ncols;
1220 Element *elements_old = GetMatrixArray();
1221 const Int_t nelems_old = this->fNelems;
1222 const Int_t nrows_old = this->fNrows;
1223 const Int_t ncols_old = this->fNcols;
1225 Allocate(nrows, ncols);
1228 Element *elements_new = GetMatrixArray();
1231 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
1232 memset(elements_new, 0, this->fNelems *
sizeof(Element));
1233 else if (this->fNelems > nelems_old)
1234 memset(elements_new + nelems_old, 0, (this->fNelems - nelems_old) *
sizeof(Element));
1240 const Int_t nelems_new = this->fNelems;
1241 if (ncols_old < this->fNcols) {
1242 for (
Int_t i = nrows_copy - 1; i >= 0; i--) {
1243 Memcpy_m(elements_new + i * this->fNcols, elements_old + i * ncols_old, ncols_copy, nelems_new, nelems_old);
1244 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
1245 memset(elements_new + i * this->fNcols + ncols_copy, 0, (this->fNcols - ncols_copy) *
sizeof(Element));
1248 for (
Int_t i = 0; i < nrows_copy; i++)
1249 Memcpy_m(elements_new + i * this->fNcols, elements_old + i * ncols_old, ncols_copy, nelems_new, nelems_old);
1252 Delete_m(nelems_old, elements_old);
1254 Allocate(nrows, ncols, 0, 0, 1);
1265template <
class Element>
1270 if (!this->fIsOwner) {
1271 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1275 const Int_t new_nrows = row_upb - row_lwb + 1;
1276 const Int_t new_ncols = col_upb - col_lwb + 1;
1278 if (this->fNelems > 0) {
1280 if (this->fNrows == new_nrows && this->fNcols == new_ncols && this->fRowLwb == row_lwb &&
1281 this->fColLwb == col_lwb)
1283 else if (new_nrows == 0 || new_ncols == 0) {
1284 this->fNrows = new_nrows;
1285 this->fNcols = new_ncols;
1286 this->fRowLwb = row_lwb;
1287 this->fColLwb = col_lwb;
1292 Element *elements_old = GetMatrixArray();
1293 const Int_t nelems_old = this->fNelems;
1294 const Int_t nrows_old = this->fNrows;
1295 const Int_t ncols_old = this->fNcols;
1296 const Int_t rowLwb_old = this->fRowLwb;
1297 const Int_t colLwb_old = this->fColLwb;
1299 Allocate(new_nrows, new_ncols, row_lwb, col_lwb);
1302 Element *elements_new = GetMatrixArray();
1305 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
1306 memset(elements_new, 0, this->fNelems *
sizeof(Element));
1307 else if (this->fNelems > nelems_old)
1308 memset(elements_new + nelems_old, 0, (this->fNelems - nelems_old) *
sizeof(Element));
1313 const Int_t rowUpb_copy =
TMath::Min(this->fRowLwb + this->fNrows - 1, rowLwb_old + nrows_old - 1);
1314 const Int_t colUpb_copy =
TMath::Min(this->fColLwb + this->fNcols - 1, colLwb_old + ncols_old - 1);
1316 const Int_t nrows_copy = rowUpb_copy - rowLwb_copy + 1;
1317 const Int_t ncols_copy = colUpb_copy - colLwb_copy + 1;
1319 if (nrows_copy > 0 && ncols_copy > 0) {
1320 const Int_t colOldOff = colLwb_copy - colLwb_old;
1321 const Int_t colNewOff = colLwb_copy - this->fColLwb;
1322 if (ncols_old < this->fNcols) {
1323 for (
Int_t i = nrows_copy - 1; i >= 0; i--) {
1324 const Int_t iRowOld = rowLwb_copy + i - rowLwb_old;
1325 const Int_t iRowNew = rowLwb_copy + i - this->fRowLwb;
1326 Memcpy_m(elements_new + iRowNew * this->fNcols + colNewOff,
1327 elements_old + iRowOld * ncols_old + colOldOff, ncols_copy, this->fNelems, nelems_old);
1328 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
1329 memset(elements_new + iRowNew * this->fNcols + colNewOff + ncols_copy, 0,
1330 (this->fNcols - ncols_copy) *
sizeof(Element));
1333 for (
Int_t i = 0; i < nrows_copy; i++) {
1334 const Int_t iRowOld = rowLwb_copy + i - rowLwb_old;
1335 const Int_t iRowNew = rowLwb_copy + i - this->fRowLwb;
1336 Memcpy_m(elements_new + iRowNew * this->fNcols + colNewOff,
1337 elements_old + iRowOld * ncols_old + colOldOff, ncols_copy, this->fNelems, nelems_old);
1342 Delete_m(nelems_old, elements_old);
1344 Allocate(new_nrows, new_ncols, row_lwb, col_lwb, 1);
1353template <
class Element>
1366template <
class Element>
1388template <
class Element>
1402template <
class Element>
1410 if (this->GetNrows() != this->GetNcols() || this->GetRowLwb() != this->GetColLwb()) {
1411 Error(
"Invert()",
"matrix should be square");
1413 Element *pM = this->GetMatrixArray();
1415 Error(
"InvertFast",
"matrix is singular");
1425 TMatrixTCramerInv::Inv2x2<Element>(*
this, det);
1429 TMatrixTCramerInv::Inv3x3<Element>(*
this, det);
1433 TMatrixTCramerInv::Inv4x4<Element>(*
this, det);
1437 TMatrixTCramerInv::Inv5x5<Element>(*
this, det);
1441 TMatrixTCramerInv::Inv6x6<Element>(*
this, det);
1453template <
class Element>
1460 Element *ap = this->GetMatrixArray();
1461 if (this->fNrows == this->fNcols && this->fRowLwb == this->fColLwb) {
1462 for (
Int_t i = 0; i < this->fNrows; i++) {
1463 const Int_t off_i = i * this->fNrows;
1464 for (
Int_t j = i + 1; j < this->fNcols; j++) {
1465 const Int_t off_j = j * this->fNcols;
1466 const Element tmp = ap[off_i + j];
1467 ap[off_i + j] = ap[off_j + i];
1468 ap[off_j + i] = tmp;
1474 const Int_t nrows_old = this->fNrows;
1475 const Int_t ncols_old = this->fNcols;
1476 const Int_t rowlwb_old = this->fRowLwb;
1477 const Int_t collwb_old = this->fColLwb;
1479 this->fNrows = ncols_old;
1480 this->fNcols = nrows_old;
1481 this->fRowLwb = collwb_old;
1482 this->fColLwb = rowlwb_old;
1483 for (
Int_t irow = this->fRowLwb; irow < this->fRowLwb + this->fNrows; irow++) {
1484 for (
Int_t icol = this->fColLwb; icol < this->fColLwb + this->fNcols; icol++) {
1485 const Int_t off = (icol - collwb_old) * ncols_old;
1486 (*this)(irow, icol) = oldElems[off + irow - rowlwb_old];
1492 if (this->fNrows != source.
GetNcols() || this->fNcols != source.
GetNrows() ||
1494 Error(
"Transpose",
"matrix has wrong shape");
1499 const Element *scp = sp1;
1500 Element *tp = this->GetMatrixArray();
1501 const Element *
const tp_last = this->GetMatrixArray() + this->fNelems;
1505 while (tp < tp_last) {
1506 const Element *sp2 = scp++;
1509 while (sp2 < sp1 + this->fNelems) {
1511 sp2 += this->fNrows;
1514 R__ASSERT(tp == tp_last && scp == sp1 + this->fNrows);
1524template <
class Element>
1530 if (
v.GetNoElements() <
TMath::Max(this->fNrows, this->fNcols)) {
1531 Error(
"Rank1Update",
"vector too short");
1536 const Element *
const pv =
v.GetMatrixArray();
1537 Element *mp = this->GetMatrixArray();
1539 for (
Int_t i = 0; i < this->fNrows; i++) {
1540 const Element tmp = alpha * pv[i];
1541 for (
Int_t j = 0; j < this->fNcols; j++)
1542 *mp++ += tmp * pv[j];
1552template <
class Element>
1560 if (
v1.GetNoElements() < this->fNrows) {
1561 Error(
"Rank1Update",
"vector v1 too short");
1565 if (
v2.GetNoElements() < this->fNcols) {
1566 Error(
"Rank1Update",
"vector v2 too short");
1571 const Element *
const pv1 =
v1.GetMatrixArray();
1572 const Element *
const pv2 =
v2.GetMatrixArray();
1573 Element *mp = this->GetMatrixArray();
1575 for (
Int_t i = 0; i < this->fNrows; i++) {
1576 const Element tmp = alpha * pv1[i];
1577 for (
Int_t j = 0; j < this->fNcols; j++)
1578 *mp++ += tmp * pv2[j];
1587template <
class Element>
1593 if (this->fNcols != this->fNrows || this->fColLwb != this->fRowLwb) {
1594 Error(
"Similarity(const TVectorT &)",
"matrix is not square");
1598 if (this->fNcols !=
v.GetNrows() || this->fColLwb !=
v.GetLwb()) {
1599 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1604 const Element *mp = this->GetMatrixArray();
1605 const Element *vp =
v.GetMatrixArray();
1608 const Element *
const vp_first = vp;
1609 const Element *
const vp_last = vp +
v.GetNrows();
1610 while (vp < vp_last) {
1612 for (
const Element *sp = vp_first; sp < vp_last;)
1613 sum2 += *mp++ * *sp++;
1614 sum1 += sum2 * *vp++;
1617 R__ASSERT(mp == this->GetMatrixArray() + this->GetNoElements());
1628template <
class Element>
1634 if (
v.GetNoElements() < this->fNrows) {
1635 Error(
"NormByColumn",
"vector shorter than matrix column");
1644 const Element *pv =
v.GetMatrixArray();
1645 Element *mp = this->GetMatrixArray();
1646 const Element *
const mp_last = mp + this->fNelems;
1649 for (; mp < mp_last; pv++) {
1650 for (
Int_t j = 0; j < this->fNcols; j++) {
1654 Error(
"NormbyColumn",
"vector element %ld is zero",
Long_t(pv -
v.GetMatrixArray()));
1660 for (; mp < mp_last; pv++)
1661 for (
Int_t j = 0; j < this->fNcols; j++)
1674template <
class Element>
1680 if (
v.GetNoElements() < this->fNcols) {
1681 Error(
"NormByRow",
"vector shorter than matrix column");
1690 const Element *pv0 =
v.GetMatrixArray();
1691 const Element *pv = pv0;
1692 Element *mp = this->GetMatrixArray();
1693 const Element *
const mp_last = mp + this->fNelems;
1696 for (; mp < mp_last; pv = pv0)
1697 for (
Int_t j = 0; j < this->fNcols; j++) {
1701 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv - pv0));
1706 for (; mp < mp_last; pv = pv0)
1707 for (
Int_t j = 0; j < this->fNcols; j++)
1717template <
class Element>
1721 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1727 memcpy(fElements, source.
GetMatrixArray(), this->fNelems *
sizeof(Element));
1728 this->fTol = source.
GetTol();
1736template <
class Element>
1740 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1746 memcpy(fElements, source.
GetMatrixArray(), this->fNelems *
sizeof(Element));
1747 this->fTol = source.
GetTol();
1755template <
class Element>
1759 this->GetRowLwb() != source.
GetRowLwb() || this->GetColLwb() != source.
GetColLwb()) {
1760 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1766 memset(fElements, 0, this->fNelems *
sizeof(Element));
1769 Element *tp = this->GetMatrixArray();
1774 for (
Int_t irow = 0; irow < this->fNrows; irow++) {
1775 const Int_t off = irow * this->fNcols;
1776 const Int_t sIndex = pRowIndex[irow];
1777 const Int_t eIndex = pRowIndex[irow + 1];
1781 this->fTol = source.
GetTol();
1789template <
class Element>
1794 if (lazy_constructor.
GetRowUpb() != this->GetRowUpb() || lazy_constructor.
GetColUpb() != this->GetColUpb() ||
1795 lazy_constructor.
GetRowLwb() != this->GetRowLwb() || lazy_constructor.
GetColLwb() != this->GetColLwb()) {
1796 Error(
"operator=(const TMatrixTLazy&)",
"matrix is incompatible with "
1797 "the assigned Lazy matrix");
1801 lazy_constructor.
FillIn(*
this);
1808template <
class Element>
1813 Element *ep = this->GetMatrixArray();
1814 const Element *
const ep_last = ep + this->fNelems;
1815 while (ep < ep_last)
1824template <
class Element>
1829 Element *ep = this->GetMatrixArray();
1830 const Element *
const ep_last = ep + this->fNelems;
1831 while (ep < ep_last)
1840template <
class Element>
1845 Element *ep = this->GetMatrixArray();
1846 const Element *
const ep_last = ep + this->fNelems;
1847 while (ep < ep_last)
1856template <
class Element>
1861 Element *ep = this->GetMatrixArray();
1862 const Element *
const ep_last = ep + this->fNelems;
1863 while (ep < ep_last)
1872template <
class Element>
1876 Error(
"operator+=(const TMatrixT &)",
"matrices not compatible");
1881 Element *tp = this->GetMatrixArray();
1882 const Element *
const tp_last = tp + this->fNelems;
1883 while (tp < tp_last)
1892template <
class Element>
1896 Error(
"operator+=(const TMatrixTSym &)",
"matrices not compatible");
1901 Element *tp = this->GetMatrixArray();
1902 const Element *
const tp_last = tp + this->fNelems;
1903 while (tp < tp_last)
1912template <
class Element>
1916 Error(
"operator=-(const TMatrixT &)",
"matrices not compatible");
1921 Element *tp = this->GetMatrixArray();
1922 const Element *
const tp_last = tp + this->fNelems;
1923 while (tp < tp_last)
1932template <
class Element>
1936 Error(
"operator=-(const TMatrixTSym &)",
"matrices not compatible");
1941 Element *tp = this->GetMatrixArray();
1942 const Element *
const tp_last = tp + this->fNelems;
1943 while (tp < tp_last)
1954template <
class Element>
1962 Error(
"operator*=(const TMatrixT &)",
"source matrix has wrong shape");
1978 Element work[kWorkMax];
1980 Element *trp = work;
1981 if (this->fNcols > kWorkMax) {
1982 isAllocated =
kTRUE;
1983 trp =
new Element[this->fNcols];
1986 Element *cp = this->GetMatrixArray();
1987 const Element *trp0 = cp;
1988 const Element *
const trp0_last = trp0 + this->fNelems;
1989 while (trp0 < trp0_last) {
1990 memcpy(trp, trp0, this->fNcols *
sizeof(Element));
1991 for (
const Element *scp = sp; scp < sp + this->fNcols;) {
1994 for (
Int_t j = 0; j < this->fNcols; j++) {
1995 cij += trp[j] * *scp;
1996 scp += this->fNcols;
2001 trp0 += this->fNcols;
2005 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2016template <
class Element>
2023 Error(
"operator*=(const TMatrixTSym &)",
"source matrix has wrong shape");
2039 Element work[kWorkMax];
2041 Element *trp = work;
2042 if (this->fNcols > kWorkMax) {
2043 isAllocated =
kTRUE;
2044 trp =
new Element[this->fNcols];
2047 Element *cp = this->GetMatrixArray();
2048 const Element *trp0 = cp;
2049 const Element *
const trp0_last = trp0 + this->fNelems;
2050 while (trp0 < trp0_last) {
2051 memcpy(trp, trp0, this->fNcols *
sizeof(Element));
2052 for (
const Element *scp = sp; scp < sp + this->fNcols;) {
2055 for (
Int_t j = 0; j < this->fNcols; j++) {
2056 cij += trp[j] * *scp;
2057 scp += this->fNcols;
2062 trp0 += this->fNcols;
2066 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2077template <
class Element>
2084 Error(
"operator*=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2089 Element *mp = this->GetMatrixArray();
2090 const Element *
const mp_last = mp + this->fNelems;
2092 while (mp < mp_last) {
2093 const Element *dp = diag.
GetPtr();
2094 for (
Int_t j = 0; j < this->fNcols; j++) {
2107template <
class Element>
2114 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2119 Element *mp = this->GetMatrixArray();
2120 const Element *
const mp_last = mp + this->fNelems;
2122 while (mp < mp_last) {
2123 const Element *dp = diag.
GetPtr();
2124 for (
Int_t j = 0; j < this->fNcols; j++) {
2128 Error(
"operator/=",
"%d-diagonal element is zero", j);
2142template <
class Element>
2150 if (this->fNrows != mt->
GetNrows()) {
2151 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2157 Element *mp = this->GetMatrixArray();
2158 const Element *
const mp_last = mp + this->fNelems;
2159 const Element *cp = col.
GetPtr();
2161 while (mp < mp_last) {
2163 for (
Int_t j = 0; j < this->fNcols; j++)
2175template <
class Element>
2183 if (this->fNrows != mt->
GetNrows()) {
2184 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2190 Element *mp = this->GetMatrixArray();
2191 const Element *
const mp_last = mp + this->fNelems;
2192 const Element *cp = col.
GetPtr();
2194 while (mp < mp_last) {
2197 for (
Int_t j = 0; j < this->fNcols; j++)
2201 Error(
"operator/=",
"%d-row of matrix column is zero", icol);
2214template <
class Element>
2222 if (this->fNcols != mt->
GetNcols()) {
2223 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2229 Element *mp = this->GetMatrixArray();
2230 const Element *
const mp_last = mp + this->fNelems;
2232 while (mp < mp_last) {
2233 const Element *rp = row.
GetPtr();
2234 for (
Int_t j = 0; j < this->fNcols; j++) {
2248template <
class Element>
2255 if (this->fNcols != mt->
GetNcols()) {
2256 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2261 Element *mp = this->GetMatrixArray();
2262 const Element *
const mp_last = mp + this->fNelems;
2264 while (mp < mp_last) {
2265 const Element *rp = row.
GetPtr();
2266 for (
Int_t j = 0; j < this->fNcols; j++) {
2271 Error(
"operator/=",
"%d-col of matrix row is zero", j);
2287template <
class Element>
2290 if (!this->IsSymmetric())
2291 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2293 eigenValues.
ResizeTo(this->fNrows);
2301template <
class Element>
2312template <
class Element>
2323template <
class Element>
2332template <
class Element>
2343template <
class Element>
2352template <
class Element>
2363template <
class Element>
2374template <
class Element>
2377 return Element(-1.0) * (
operator-(source2, source1));
2383template <
class Element>
2394template <
class Element>
2397 return Element(-1.0) *
operator-(source, val);
2403template <
class Element>
2414template <
class Element>
2423template <
class Element>
2433template <
class Element>
2443template <
class Element>
2453template <
class Element>
2464template <
class Element>
2470 Error(
"operator&&(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2474 target.ResizeTo(source1);
2478 Element *tp =
target.GetMatrixArray();
2479 const Element *
const tp_last = tp +
target.GetNoElements();
2480 while (tp < tp_last)
2481 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2489template <
class Element>
2495 Error(
"operator&&(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2499 target.ResizeTo(source1);
2503 Element *tp =
target.GetMatrixArray();
2504 const Element *
const tp_last = tp +
target.GetNoElements();
2505 while (tp < tp_last)
2506 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2514template <
class Element>
2523template <
class Element>
2529 Error(
"operator||(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2533 target.ResizeTo(source1);
2537 Element *tp =
target.GetMatrixArray();
2538 const Element *
const tp_last = tp +
target.GetNoElements();
2539 while (tp < tp_last)
2540 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2548template <
class Element>
2554 Error(
"operator||(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2558 target.ResizeTo(source1);
2562 Element *tp =
target.GetMatrixArray();
2563 const Element *
const tp_last = tp +
target.GetNoElements();
2564 while (tp < tp_last)
2565 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2573template <
class Element>
2582template <
class Element>
2588 Error(
"operator|(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2592 target.ResizeTo(source1);
2596 Element *tp =
target.GetMatrixArray();
2597 const Element *
const tp_last = tp +
target.GetNoElements();
2598 while (tp < tp_last) {
2599 *tp++ = (*sp1) > (*sp2);
2610template <
class Element>
2616 Error(
"operator>(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2620 target.ResizeTo(source1);
2624 Element *tp =
target.GetMatrixArray();
2625 const Element *
const tp_last = tp +
target.GetNoElements();
2626 while (tp < tp_last) {
2627 *tp++ = (*sp1) > (*sp2);
2638template <
class Element>
2647template <
class Element>
2653 Error(
"operator>=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2657 target.ResizeTo(source1);
2661 Element *tp =
target.GetMatrixArray();
2662 const Element *
const tp_last = tp +
target.GetNoElements();
2663 while (tp < tp_last) {
2664 *tp++ = (*sp1) >= (*sp2);
2675template <
class Element>
2681 Error(
"operator>=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2685 target.ResizeTo(source1);
2689 Element *tp =
target.GetMatrixArray();
2690 const Element *
const tp_last = tp +
target.GetNoElements();
2691 while (tp < tp_last) {
2692 *tp++ = (*sp1) >= (*sp2);
2703template <
class Element>
2712template <
class Element>
2718 Error(
"operator<=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2722 target.ResizeTo(source1);
2726 Element *tp =
target.GetMatrixArray();
2727 const Element *
const tp_last = tp +
target.GetNoElements();
2728 while (tp < tp_last) {
2729 *tp++ = (*sp1) <= (*sp2);
2740template <
class Element>
2746 Error(
"operator<=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2750 target.ResizeTo(source1);
2754 Element *tp =
target.GetMatrixArray();
2755 const Element *
const tp_last = tp +
target.GetNoElements();
2756 while (tp < tp_last) {
2757 *tp++ = (*sp1) <= (*sp2);
2768template <
class Element>
2777template <
class Element>
2783 Error(
"operator<(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2789 Element *tp =
target.GetMatrixArray();
2790 const Element *
const tp_last = tp +
target.GetNoElements();
2791 while (tp < tp_last) {
2792 *tp++ = (*sp1) < (*sp2);
2803template <
class Element>
2809 Error(
"operator<(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2813 target.ResizeTo(source1);
2817 Element *tp =
target.GetMatrixArray();
2818 const Element *
const tp_last = tp +
target.GetNoElements();
2819 while (tp < tp_last) {
2820 *tp++ = (*sp1) < (*sp2);
2831template <
class Element>
2840template <
class Element>
2846 Error(
"operator!=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2850 target.ResizeTo(source1);
2854 Element *tp =
target.GetMatrixArray();
2855 const Element *
const tp_last = tp +
target.GetNoElements();
2856 while (tp != tp_last) {
2857 *tp++ = (*sp1) != (*sp2);
2868template <
class Element>
2874 Error(
"operator!=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2878 target.ResizeTo(source1);
2882 Element *tp =
target.GetMatrixArray();
2883 const Element *
const tp_last = tp +
target.GetNoElements();
2884 while (tp != tp_last) {
2885 *tp++ = (*sp1) != (*sp2);
2896template <
class Element>
2906template<class Element>
2907TMatrixT<Element> operator!=(const TMatrixT<Element> &source1,Element val)
2909 TMatrixT<Element> target; target.ResizeTo(source1);
2911 const Element *sp = source1.GetMatrixArray();
2912 Element *tp = target.GetMatrixArray();
2913 const Element * const tp_last = tp+target.GetNoElements();
2914 while (tp != tp_last) {
2915 *tp++ = (*sp != val); sp++;
2924template<class Element>
2925TMatrixT<Element> operator!=(Element val,const TMatrixT<Element> &source1)
2927 return operator!=(source1,val);
2934template <
class Element>
2938 ::Error(
"Add(TMatrixT &,Element,const TMatrixT &)",
"matrices not compatible");
2943 Element *tp =
target.GetMatrixArray();
2944 const Element *ftp = tp +
target.GetNoElements();
2947 *tp++ = scalar * (*sp++);
2948 }
else if (scalar == 1.) {
2953 *tp++ += scalar * (*sp++);
2962template <
class Element>
2967 ::Error(
"Add(TMatrixT &,Element,const TMatrixTSym &)",
"matrices not compatible");
2972 Element *tp =
target.GetMatrixArray();
2973 const Element *ftp = tp +
target.GetNoElements();
2975 *tp++ += scalar * (*sp++);
2983template <
class Element>
2987 ::Error(
"ElementMult(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2992 Element *tp =
target.GetMatrixArray();
2993 const Element *ftp = tp +
target.GetNoElements();
3003template <
class Element>
3007 ::Error(
"ElementMult(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3012 Element *tp =
target.GetMatrixArray();
3013 const Element *ftp = tp +
target.GetNoElements();
3023template <
class Element>
3027 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3032 Element *tp =
target.GetMatrixArray();
3033 const Element *ftp = tp +
target.GetNoElements();
3040 Error(
"ElementDiv",
"source (%d,%d) is zero", irow, icol);
3051template <
class Element>
3055 ::Error(
"ElementDiv(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3060 Element *tp =
target.GetMatrixArray();
3061 const Element *ftp = tp +
target.GetNoElements();
3068 Error(
"ElementDiv",
"source (%d,%d) is zero", irow, icol);
3079template <
class Element>
3081 Int_t ncolsb, Element *cp)
3083 const Element *arp0 = ap;
3084 while (arp0 < ap + na) {
3085 for (
const Element *bcp = bp; bcp < bp + ncolsb;) {
3086 const Element *arp = arp0;
3088 while (bcp < bp + nb) {
3089 cij += *arp++ * *bcp;
3102template <
class Element>
3104 Int_t ncolsb, Element *cp)
3106 const Element *acp0 = ap;
3107 while (acp0 < ap + ncolsa) {
3108 for (
const Element *bcp = bp; bcp < bp + ncolsb;) {
3109 const Element *acp = acp0;
3111 while (bcp < bp + nb) {
3126template <
class Element>
3128 Int_t ncolsb, Element *cp)
3130 const Element *arp0 = ap;
3131 while (arp0 < ap + na) {
3132 const Element *brp0 = bp;
3133 while (brp0 < bp + nb) {
3134 const Element *arp = arp0;
3135 const Element *brp = brp0;
3137 while (brp < brp0 + ncolsb)
3138 cij += *arp++ * *brp++;
3149template <
class Element>
3158 }
else if (R__v == 2) {
3162 R__b >> this->fNrows;
3163 R__b >> this->fNcols;
3164 R__b >> this->fNelems;
3165 R__b >> this->fRowLwb;
3166 R__b >> this->fColLwb;
3170 if (this->fNelems > 0) {
3171 fElements =
new Element[this->fNelems];
3174 fElements =
nullptr;
3180 R__b >> this->fNrows;
3181 R__b >> this->fNcols;
3182 R__b >> this->fRowLwb;
3183 R__b >> this->fColLwb;
3184 this->fNelems = R__b.
ReadArray(fElements);
3188 if (R__v <= 2 && fElements) {
3189 for (
Int_t i = 0; i < this->fNrows; i++) {
3190 const Int_t off_i = i * this->fNcols;
3191 for (
Int_t j = i; j < this->fNcols; j++) {
3192 const Int_t off_j = j * this->fNrows;
3193 const Element tmp = fElements[off_i + j];
3194 fElements[off_i + j] = fElements[off_j + i];
3195 fElements[off_j + i] = tmp;
3199 if (this->fNelems > 0 && this->fNelems <= this->kSizeMax) {
3201 memcpy(fDataStack, fElements, this->fNelems *
sizeof(Element));
3204 fElements = fDataStack;
3205 }
else if (this->fNelems < 0)
3262template void TMatrixTAutoloadOps::AMultB<Float_t>(
const Float_t *
const ap,
Int_t na,
Int_t ncolsa,
3264template void TMatrixTAutoloadOps::AtMultB<Float_t>(
const Float_t *
const ap,
Int_t ncolsa,
const Float_t *
const bp,
3266template void TMatrixTAutoloadOps::AMultBt<Float_t>(
const Float_t *
const ap,
Int_t na,
Int_t ncolsa,
3319template void TMatrixTAutoloadOps::AMultB<Double_t>(
const Double_t *
const ap,
Int_t na,
Int_t ncolsa,
3321template void TMatrixTAutoloadOps::AtMultB<Double_t>(
const Double_t *
const ap,
Int_t ncolsa,
const Double_t *
const bp,
3323template 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
int Int_t
Signed integer 4 bytes (int)
short Version_t
Class version identifier (short)
char Char_t
Character 1 byte (char)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char)
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) noexcept
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 .