38template<
class Element>
47template<
class Element>
50 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb,1);
61template<
class Element>
71template<
class Element>
73 const Element *elements,
Option_t *option)
75 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb);
82template<
class Element>
93template<
class Element>
104template<
class Element>
117template<
class Element>
147 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
149 this->SetTol(oldTol);
155 TMult(prototype,prototype);
159 Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
168template<
class Element>
176 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
181 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
194 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
196 this->SetTol(oldTol);
210 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
216 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);
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);
260 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
267 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
273 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
282template<
class Element>
290 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
295 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
300 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1);
306 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
308 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
310 this->SetTol(oldTol);
317 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
324 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
330 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
339template<
class Element>
347 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
352 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
357 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1);
363 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
365 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
367 this->SetTol(oldTol);
374 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
381 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
387 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
394template<
class Element>
400 lazy_constructor.
FillIn(*
this);
406template<
class Element>
410 if (size > this->kSizeMax)
420template<
class Element>
423 if (size == 0)
return 0;
425 if ( size <= this->kSizeMax )
428 Element *heap =
new Element[size];
438template<
class Element>
442 if (copySize == 0 || oldp == newp)
445 if ( newSize <= this->kSizeMax && oldSize <= this->kSizeMax ) {
448 for (
Int_t i = copySize-1; i >= 0; i--)
451 for (
Int_t i = 0; i < copySize; i++)
456 memcpy(newp,oldp,copySize*
sizeof(Element));
465template<
class Element>
469 this->fIsOwner =
kTRUE;
478 if (no_rows < 0 || no_cols < 0)
480 Error(
"Allocate",
"no_rows=%d no_cols=%d",no_rows,no_cols);
486 this->fNrows = no_rows;
487 this->fNcols = no_cols;
488 this->fRowLwb = row_lwb;
489 this->fColLwb = col_lwb;
490 this->fNelems = this->fNrows*this->fNcols;
493 if( ((
Long64_t)this->fNrows)*this->fNcols != this->fNelems )
495 Error(
"Allocate",
"too large: no_rows=%d no_cols=%d",no_rows,no_cols);
500 if (this->fNelems > 0) {
501 fElements = New_m(this->fNelems);
503 memset(fElements,0,this->fNelems*
sizeof(Element));
511template<
class Element>
516 Error(
"Plus",
"matrices not compatible");
520 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
521 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
525 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
526 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
531 const Element * ap =
a.GetMatrixArray();
532 const Element * bp =
b.GetMatrixArray();
533 Element * cp = this->GetMatrixArray();
534 const Element *
const cp_last = cp+this->fNelems;
536 while (cp < cp_last) {
545template<
class Element>
550 Error(
"Plus",
"matrices not compatible");
554 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
555 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
559 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
560 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
565 const Element * ap =
a.GetMatrixArray();
566 const Element * bp =
b.GetMatrixArray();
567 Element * cp = this->GetMatrixArray();
568 const Element *
const cp_last = cp+this->fNelems;
570 while (cp < cp_last) {
579template<
class Element>
584 Error(
"Minus",
"matrices not compatible");
588 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
589 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
593 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
594 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
599 const Element * ap =
a.GetMatrixArray();
600 const Element * bp =
b.GetMatrixArray();
601 Element * cp = this->GetMatrixArray();
602 const Element *
const cp_last = cp+this->fNelems;
604 while (cp < cp_last) {
613template<
class Element>
618 Error(
"Minus",
"matrices not compatible");
622 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
623 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
627 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
628 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
633 const Element * ap =
a.GetMatrixArray();
634 const Element * bp =
b.GetMatrixArray();
635 Element * cp = this->GetMatrixArray();
636 const Element *
const cp_last = cp+this->fNelems;
638 while (cp < cp_last) {
647template<
class Element>
651 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
652 Error(
"Mult",
"A rows and B columns incompatible");
656 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
657 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
661 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
662 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
668 const Element *ap =
a.GetMatrixArray();
669 const Element *bp =
b.GetMatrixArray();
670 Element *cp = this->GetMatrixArray();
671 if (
typeid(Element) ==
typeid(
Double_t))
672 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasNoTrans,fNrows,fNcols,
a.GetNcols(),
673 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
674 else if (
typeid(Element) !=
typeid(
Float_t))
675 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasNoTrans,fNrows,fNcols,
a.GetNcols(),
676 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
678 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
680 const Int_t na =
a.GetNoElements();
681 const Int_t nb =
b.GetNoElements();
682 const Int_t ncolsa =
a.GetNcols();
683 const Int_t ncolsb =
b.GetNcols();
684 const Element *
const ap =
a.GetMatrixArray();
685 const Element *
const bp =
b.GetMatrixArray();
686 Element * cp = this->GetMatrixArray();
688 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
696template<
class Element>
702 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
703 Error(
"Mult",
"A rows and B columns incompatible");
707 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
708 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
712 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
713 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
719 const Element *ap =
a.GetMatrixArray();
720 const Element *bp =
b.GetMatrixArray();
721 Element *cp = this->GetMatrixArray();
722 if (
typeid(Element) ==
typeid(
Double_t))
723 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
724 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
725 else if (
typeid(Element) !=
typeid(
Float_t))
726 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
727 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
729 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
731 const Int_t na =
a.GetNoElements();
732 const Int_t nb =
b.GetNoElements();
733 const Int_t ncolsa =
a.GetNcols();
734 const Int_t ncolsb =
b.GetNcols();
735 const Element *
const ap =
a.GetMatrixArray();
736 const Element *
const bp =
b.GetMatrixArray();
737 Element * cp = this->GetMatrixArray();
739 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
748template<
class Element>
754 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
755 Error(
"Mult",
"A rows and B columns incompatible");
759 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
760 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
764 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
765 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
771 const Element *ap =
a.GetMatrixArray();
772 const Element *bp =
b.GetMatrixArray();
773 Element *cp = this->GetMatrixArray();
774 if (
typeid(Element) ==
typeid(
Double_t))
775 cblas_dsymm (CblasRowMajor,CblasRight,CblasUpper,fNrows,fNcols,1.0,
776 bp,
b.GetNcols(),ap,
a.GetNcols(),0.0,cp,fNcols);
777 else if (
typeid(Element) !=
typeid(
Float_t))
778 cblas_ssymm (CblasRowMajor,CblasRight,CblasUpper,fNrows,fNcols,1.0,
779 bp,
b.GetNcols(),ap,
a.GetNcols(),0.0,cp,fNcols);
781 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
783 const Int_t na =
a.GetNoElements();
784 const Int_t nb =
b.GetNoElements();
785 const Int_t ncolsa =
a.GetNcols();
786 const Int_t ncolsb =
b.GetNcols();
787 const Element *
const ap =
a.GetMatrixArray();
788 const Element *
const bp =
b.GetMatrixArray();
789 Element * cp = this->GetMatrixArray();
791 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
800template<
class Element>
806 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
807 Error(
"Mult",
"A rows and B columns incompatible");
811 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
812 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
816 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
817 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
823 const Element *ap =
a.GetMatrixArray();
824 const Element *bp =
b.GetMatrixArray();
825 Element *cp = this->GetMatrixArray();
826 if (
typeid(Element) ==
typeid(
Double_t))
827 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
828 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
829 else if (
typeid(Element) !=
typeid(
Float_t))
830 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
831 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
833 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
835 const Int_t na =
a.GetNoElements();
836 const Int_t nb =
b.GetNoElements();
837 const Int_t ncolsa =
a.GetNcols();
838 const Int_t ncolsb =
b.GetNcols();
839 const Element *
const ap =
a.GetMatrixArray();
840 const Element *
const bp =
b.GetMatrixArray();
841 Element * cp = this->GetMatrixArray();
843 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
851template<
class Element>
857 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
858 Error(
"TMult",
"A rows and B columns incompatible");
862 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
863 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
867 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
868 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
874 const Element *ap =
a.GetMatrixArray();
875 const Element *bp =
b.GetMatrixArray();
876 Element *cp = this->GetMatrixArray();
877 if (
typeid(Element) ==
typeid(
Double_t))
878 cblas_dgemm (CblasRowMajor,CblasTrans,CblasNoTrans,this->fNrows,this->fNcols,
a.GetNrows(),
879 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,this->fNcols);
880 else if (
typeid(Element) !=
typeid(
Float_t))
881 cblas_sgemm (CblasRowMajor,CblasTrans,CblasNoTrans,fNrows,fNcols,
a.GetNrows(),
882 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
884 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
886 const Int_t nb =
b.GetNoElements();
887 const Int_t ncolsa =
a.GetNcols();
888 const Int_t ncolsb =
b.GetNcols();
889 const Element *
const ap =
a.GetMatrixArray();
890 const Element *
const bp =
b.GetMatrixArray();
891 Element * cp = this->GetMatrixArray();
893 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
901template<
class Element>
907 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
908 Error(
"TMult",
"A rows and B columns incompatible");
912 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
913 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
917 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
918 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
924 const Element *ap =
a.GetMatrixArray();
925 const Element *bp =
b.GetMatrixArray();
926 Element *cp = this->GetMatrixArray();
927 if (
typeid(Element) ==
typeid(
Double_t))
928 cblas_dgemm (CblasRowMajor,CblasTrans,CblasNoTrans,fNrows,fNcols,
a.GetNrows(),
929 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
930 else if (
typeid(Element) !=
typeid(
Float_t))
931 cblas_sgemm (CblasRowMajor,CblasTrans,CblasNoTrans,fNrows,fNcols,
a.GetNrows(),
932 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
934 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
936 const Int_t nb =
b.GetNoElements();
937 const Int_t ncolsa =
a.GetNcols();
938 const Int_t ncolsb =
b.GetNcols();
939 const Element *
const ap =
a.GetMatrixArray();
940 const Element *
const bp =
b.GetMatrixArray();
941 Element * cp = this->GetMatrixArray();
943 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
950template<
class Element>
957 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
958 Error(
"MultT",
"A rows and B columns incompatible");
962 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
963 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
967 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
968 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
974 const Element *ap =
a.GetMatrixArray();
975 const Element *bp =
b.GetMatrixArray();
976 Element *cp = this->GetMatrixArray();
977 if (
typeid(Element) ==
typeid(
Double_t))
978 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasTrans,fNrows,fNcols,
a.GetNcols(),
979 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
980 else if (
typeid(Element) !=
typeid(
Float_t))
981 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasTrans,fNrows,fNcols,
a.GetNcols(),
982 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
984 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
986 const Int_t na =
a.GetNoElements();
987 const Int_t nb =
b.GetNoElements();
988 const Int_t ncolsa =
a.GetNcols();
989 const Int_t ncolsb =
b.GetNcols();
990 const Element *
const ap =
a.GetMatrixArray();
991 const Element *
const bp =
b.GetMatrixArray();
992 Element * cp = this->GetMatrixArray();
994 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1002template<
class Element>
1008 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
1009 Error(
"MultT",
"A rows and B columns incompatible");
1013 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
1014 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1018 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
1019 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1025 const Element *ap =
a.GetMatrixArray();
1026 const Element *bp =
b.GetMatrixArray();
1027 Element *cp = this->GetMatrixArray();
1028 if (
typeid(Element) ==
typeid(
Double_t))
1029 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasTrans,this->fNrows,this->fNcols,
a.GetNcols(),
1030 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,this->fNcols);
1031 else if (
typeid(Element) !=
typeid(
Float_t))
1032 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasTrans,fNrows,fNcols,
a.GetNcols(),
1033 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
1035 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
1037 const Int_t na =
a.GetNoElements();
1038 const Int_t nb =
b.GetNoElements();
1039 const Int_t ncolsa =
a.GetNcols();
1040 const Int_t ncolsb =
b.GetNcols();
1041 const Element *
const ap =
a.GetMatrixArray();
1042 const Element *
const bp =
b.GetMatrixArray();
1043 Element * cp = this->GetMatrixArray();
1045 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1052template<
class Element>
1057 if (row_upb < row_lwb)
1059 Error(
"Use",
"row_upb=%d < row_lwb=%d",row_upb,row_lwb);
1062 if (col_upb < col_lwb)
1064 Error(
"Use",
"col_upb=%d < col_lwb=%d",col_upb,col_lwb);
1070 this->fNrows = row_upb-row_lwb+1;
1071 this->fNcols = col_upb-col_lwb+1;
1072 this->fRowLwb = row_lwb;
1073 this->fColLwb = col_lwb;
1074 this->fNelems = this->fNrows*this->fNcols;
1088template<
class Element>
1094 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb+this->fNrows-1) {
1095 Error(
"GetSub",
"row_lwb out of bounds");
1098 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb+this->fNcols-1) {
1099 Error(
"GetSub",
"col_lwb out of bounds");
1102 if (row_upb < this->fRowLwb || row_upb > this->fRowLwb+this->fNrows-1) {
1103 Error(
"GetSub",
"row_upb out of bounds");
1106 if (col_upb < this->fColLwb || col_upb > this->fColLwb+this->fNcols-1) {
1107 Error(
"GetSub",
"col_upb out of bounds");
1110 if (row_upb < row_lwb || col_upb < col_lwb) {
1111 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1120 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1121 const Int_t row_upb_sub = (shift) ? row_upb-row_lwb : row_upb;
1122 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1123 const Int_t col_upb_sub = (shift) ? col_upb-col_lwb : col_upb;
1125 target.
ResizeTo(row_lwb_sub,row_upb_sub,col_lwb_sub,col_upb_sub);
1126 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
1127 const Int_t ncols_sub = col_upb_sub-col_lwb_sub+1;
1130 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1131 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1132 target(irow+row_lwb_sub,icol+col_lwb_sub) = (*this)(row_lwb+irow,col_lwb+icol);
1136 const Element *ap = this->GetMatrixArray()+(row_lwb-this->fRowLwb)*this->fNcols+(col_lwb-this->fColLwb);
1139 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1140 const Element *ap_sub = ap;
1141 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1155template<
class Element>
1162 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb+this->fNrows-1) {
1163 Error(
"SetSub",
"row_lwb outof bounds");
1166 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb+this->fNcols-1) {
1167 Error(
"SetSub",
"col_lwb outof bounds");
1170 if (row_lwb+source.
GetNrows() > this->fRowLwb+this->fNrows ||
1171 col_lwb+source.
GetNcols() > this->fColLwb+this->fNcols) {
1172 Error(
"SetSub",
"source matrix too large");
1183 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1184 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1185 (*this)(row_lwb+irow,col_lwb+icol) = source(rowlwb_s+irow,collwb_s+icol);
1190 Element *ap = this->GetMatrixArray()+(row_lwb-this->fRowLwb)*this->fNcols+(col_lwb-this->fColLwb);
1192 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1193 Element *ap_sub = ap;
1194 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1209template<
class Element>
1213 if (!this->fIsOwner) {
1214 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1218 if (this->fNelems > 0) {
1219 if (this->fNrows == nrows && this->fNcols == ncols)
1221 else if (nrows == 0 || ncols == 0) {
1222 this->fNrows = nrows; this->fNcols = ncols;
1227 Element *elements_old = GetMatrixArray();
1228 const Int_t nelems_old = this->fNelems;
1229 const Int_t nrows_old = this->fNrows;
1230 const Int_t ncols_old = this->fNcols;
1235 Element *elements_new = GetMatrixArray();
1238 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
1239 memset(elements_new,0,this->fNelems*
sizeof(Element));
1240 else if (this->fNelems > nelems_old)
1241 memset(elements_new+nelems_old,0,(this->fNelems-nelems_old)*
sizeof(Element));
1247 const Int_t nelems_new = this->fNelems;
1248 if (ncols_old < this->fNcols) {
1249 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1250 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1251 nelems_new,nelems_old);
1252 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
1253 memset(elements_new+i*this->fNcols+ncols_copy,0,(this->fNcols-ncols_copy)*
sizeof(Element));
1256 for (
Int_t i = 0; i < nrows_copy; i++)
1257 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1258 nelems_new,nelems_old);
1261 Delete_m(nelems_old,elements_old);
1274template<
class Element>
1279 if (!this->fIsOwner) {
1280 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1284 const Int_t new_nrows = row_upb-row_lwb+1;
1285 const Int_t new_ncols = col_upb-col_lwb+1;
1287 if (this->fNelems > 0) {
1289 if (this->fNrows == new_nrows && this->fNcols == new_ncols &&
1290 this->fRowLwb == row_lwb && this->fColLwb == col_lwb)
1292 else if (new_nrows == 0 || new_ncols == 0) {
1293 this->fNrows = new_nrows; this->fNcols = new_ncols;
1294 this->fRowLwb = row_lwb; this->fColLwb = col_lwb;
1299 Element *elements_old = GetMatrixArray();
1300 const Int_t nelems_old = this->fNelems;
1301 const Int_t nrows_old = this->fNrows;
1302 const Int_t ncols_old = this->fNcols;
1303 const Int_t rowLwb_old = this->fRowLwb;
1304 const Int_t colLwb_old = this->fColLwb;
1306 Allocate(new_nrows,new_ncols,row_lwb,col_lwb);
1309 Element *elements_new = GetMatrixArray();
1312 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
1313 memset(elements_new,0,this->fNelems*
sizeof(Element));
1314 else if (this->fNelems > nelems_old)
1315 memset(elements_new+nelems_old,0,(this->fNelems-nelems_old)*
sizeof(Element));
1320 const Int_t rowUpb_copy =
TMath::Min(this->fRowLwb+this->fNrows-1,rowLwb_old+nrows_old-1);
1321 const Int_t colUpb_copy =
TMath::Min(this->fColLwb+this->fNcols-1,colLwb_old+ncols_old-1);
1323 const Int_t nrows_copy = rowUpb_copy-rowLwb_copy+1;
1324 const Int_t ncols_copy = colUpb_copy-colLwb_copy+1;
1326 if (nrows_copy > 0 && ncols_copy > 0) {
1327 const Int_t colOldOff = colLwb_copy-colLwb_old;
1328 const Int_t colNewOff = colLwb_copy-this->fColLwb;
1329 if (ncols_old < this->fNcols) {
1330 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1331 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1332 const Int_t iRowNew = rowLwb_copy+i-this->fRowLwb;
1333 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1334 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->fNelems,nelems_old);
1335 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
1336 memset(elements_new+iRowNew*this->fNcols+colNewOff+ncols_copy,0,
1337 (this->fNcols-ncols_copy)*
sizeof(Element));
1340 for (
Int_t i = 0; i < nrows_copy; i++) {
1341 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1342 const Int_t iRowNew = rowLwb_copy+i-this->fRowLwb;
1343 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1344 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->fNelems,nelems_old);
1349 Delete_m(nelems_old,elements_old);
1351 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1);
1360template<
class Element>
1373template<
class Element>
1395template<
class Element>
1409template<
class Element>
1418 if (this->GetNrows() != this->GetNcols() || this->GetRowLwb() != this->GetColLwb()) {
1419 Error(
"Invert()",
"matrix should be square");
1421 Element *pM = this->GetMatrixArray();
1423 Error(
"InvertFast",
"matrix is singular");
1435 TMatrixTCramerInv::Inv2x2<Element>(*
this,det);
1440 TMatrixTCramerInv::Inv3x3<Element>(*
this,det);
1445 TMatrixTCramerInv::Inv4x4<Element>(*
this,det);
1450 TMatrixTCramerInv::Inv5x5<Element>(*
this,det);
1455 TMatrixTCramerInv::Inv6x6<Element>(*
this,det);
1468template<
class Element>
1475 Element *ap = this->GetMatrixArray();
1476 if (this->fNrows == this->fNcols && this->fRowLwb == this->fColLwb) {
1477 for (
Int_t i = 0; i < this->fNrows; i++) {
1478 const Int_t off_i = i*this->fNrows;
1479 for (
Int_t j = i+1; j < this->fNcols; j++) {
1480 const Int_t off_j = j*this->fNcols;
1481 const Element tmp = ap[off_i+j];
1482 ap[off_i+j] = ap[off_j+i];
1489 const Int_t nrows_old = this->fNrows;
1490 const Int_t ncols_old = this->fNcols;
1491 const Int_t rowlwb_old = this->fRowLwb;
1492 const Int_t collwb_old = this->fColLwb;
1494 this->fNrows = ncols_old; this->fNcols = nrows_old;
1495 this->fRowLwb = collwb_old; this->fColLwb = rowlwb_old;
1496 for (
Int_t irow = this->fRowLwb; irow < this->fRowLwb+this->fNrows; irow++) {
1497 for (
Int_t icol = this->fColLwb; icol < this->fColLwb+this->fNcols; icol++) {
1498 const Int_t off = (icol-collwb_old)*ncols_old;
1499 (*this)(irow,icol) = oldElems[off+irow-rowlwb_old];
1505 if (this->fNrows != source.
GetNcols() || this->fNcols != source.
GetNrows() ||
1508 Error(
"Transpose",
"matrix has wrong shape");
1513 const Element *scp = sp1;
1514 Element *tp = this->GetMatrixArray();
1515 const Element *
const tp_last = this->GetMatrixArray()+this->fNelems;
1519 while (tp < tp_last) {
1520 const Element *sp2 = scp++;
1523 while (sp2 < sp1+this->fNelems) {
1525 sp2 += this->fNrows;
1528 R__ASSERT(tp == tp_last && scp == sp1+this->fNrows);
1538template<
class Element>
1544 if (
v.GetNoElements() <
TMath::Max(this->fNrows,this->fNcols)) {
1545 Error(
"Rank1Update",
"vector too short");
1550 const Element *
const pv =
v.GetMatrixArray();
1551 Element *mp = this->GetMatrixArray();
1553 for (
Int_t i = 0; i < this->fNrows; i++) {
1554 const Element tmp = alpha*pv[i];
1555 for (
Int_t j = 0; j < this->fNcols; j++)
1566template<
class Element>
1574 Error(
"Rank1Update",
"vector v1 too short");
1579 Error(
"Rank1Update",
"vector v2 too short");
1586 Element *mp = this->GetMatrixArray();
1588 for (
Int_t i = 0; i < this->fNrows; i++) {
1589 const Element tmp = alpha*pv1[i];
1590 for (
Int_t j = 0; j < this->fNcols; j++)
1591 *mp++ += tmp*pv2[j];
1600template<
class Element>
1606 if (this->fNcols != this->fNrows || this->fColLwb != this->fRowLwb) {
1607 Error(
"Similarity(const TVectorT &)",
"matrix is not square");
1611 if (this->fNcols !=
v.GetNrows() || this->fColLwb !=
v.GetLwb()) {
1612 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1617 const Element *mp = this->GetMatrixArray();
1618 const Element *vp =
v.GetMatrixArray();
1621 const Element *
const vp_first = vp;
1622 const Element *
const vp_last = vp+
v.GetNrows();
1623 while (vp < vp_last) {
1625 for (
const Element *sp = vp_first; sp < vp_last; )
1626 sum2 += *mp++ * *sp++;
1627 sum1 += sum2 * *vp++;
1630 R__ASSERT(mp == this->GetMatrixArray()+this->GetNoElements());
1641template<
class Element>
1647 if (
v.GetNoElements() < this->fNrows) {
1648 Error(
"NormByColumn",
"vector shorter than matrix column");
1657 const Element *pv =
v.GetMatrixArray();
1658 Element *mp = this->GetMatrixArray();
1659 const Element *
const mp_last = mp+this->fNelems;
1662 for ( ; mp < mp_last; pv++) {
1663 for (
Int_t j = 0; j < this->fNcols; j++)
1668 Error(
"NormbyColumn",
"vector element %ld is zero",
Long_t(pv-
v.GetMatrixArray()));
1674 for ( ; mp < mp_last; pv++)
1675 for (
Int_t j = 0; j < this->fNcols; j++)
1688template<
class Element>
1694 if (
v.GetNoElements() < this->fNcols) {
1695 Error(
"NormByRow",
"vector shorter than matrix column");
1704 const Element *pv0 =
v.GetMatrixArray();
1705 const Element *pv = pv0;
1706 Element *mp = this->GetMatrixArray();
1707 const Element *
const mp_last = mp+this->fNelems;
1710 for ( ; mp < mp_last; pv = pv0 )
1711 for (
Int_t j = 0; j < this->fNcols; j++) {
1715 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv-pv0));
1720 for ( ; mp < mp_last; pv = pv0 )
1721 for (
Int_t j = 0; j < this->fNcols; j++)
1731template<
class Element>
1735 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1741 memcpy(fElements,source.
GetMatrixArray(),this->fNelems*
sizeof(Element));
1742 this->fTol = source.
GetTol();
1750template<
class Element>
1754 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1760 memcpy(fElements,source.
GetMatrixArray(),this->fNelems*
sizeof(Element));
1761 this->fTol = source.
GetTol();
1769template<
class Element>
1773 this->GetNrows() != source.
GetNrows()) || this->GetNcols() != source.
GetNcols() ||
1774 this->GetRowLwb() != source.
GetRowLwb() || this->GetColLwb() != source.
GetColLwb()) {
1775 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1781 memset(fElements,0,this->fNelems*
sizeof(Element));
1784 Element * tp = this->GetMatrixArray();
1789 for (
Int_t irow = 0; irow < this->fNrows; irow++ ) {
1790 const Int_t off = irow*this->fNcols;
1791 const Int_t sIndex = pRowIndex[irow];
1792 const Int_t eIndex = pRowIndex[irow+1];
1793 for (
Int_t index = sIndex; index < eIndex; index++)
1794 tp[off+pColIndex[index]] = sp[index];
1796 this->fTol = source.
GetTol();
1804template<
class Element>
1809 if (lazy_constructor.
GetRowUpb() != this->GetRowUpb() ||
1810 lazy_constructor.
GetColUpb() != this->GetColUpb() ||
1811 lazy_constructor.
GetRowLwb() != this->GetRowLwb() ||
1812 lazy_constructor.
GetColLwb() != this->GetColLwb()) {
1813 Error(
"operator=(const TMatrixTLazy&)",
"matrix is incompatible with "
1814 "the assigned Lazy matrix");
1818 lazy_constructor.
FillIn(*
this);
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>
1878 Element *ep = this->GetMatrixArray();
1879 const Element *
const ep_last = ep+this->fNelems;
1880 while (ep < ep_last)
1889template<
class Element>
1893 Error(
"operator+=(const TMatrixT &)",
"matrices not compatible");
1898 Element *tp = this->GetMatrixArray();
1899 const Element *
const tp_last = tp+this->fNelems;
1900 while (tp < tp_last)
1909template<
class Element>
1913 Error(
"operator+=(const TMatrixTSym &)",
"matrices not compatible");
1918 Element *tp = this->GetMatrixArray();
1919 const Element *
const tp_last = tp+this->fNelems;
1920 while (tp < tp_last)
1929template<
class Element>
1933 Error(
"operator=-(const TMatrixT &)",
"matrices not compatible");
1938 Element *tp = this->GetMatrixArray();
1939 const Element *
const tp_last = tp+this->fNelems;
1940 while (tp < tp_last)
1949template<
class Element>
1953 Error(
"operator=-(const TMatrixTSym &)",
"matrices not compatible");
1958 Element *tp = this->GetMatrixArray();
1959 const Element *
const tp_last = tp+this->fNelems;
1960 while (tp < tp_last)
1971template<
class Element>
1979 Error(
"operator*=(const TMatrixT &)",
"source matrix has wrong shape");
1996 Element work[kWorkMax];
1998 Element *trp = work;
1999 if (this->fNcols > kWorkMax) {
2000 isAllocated =
kTRUE;
2001 trp =
new Element[this->fNcols];
2004 Element *cp = this->GetMatrixArray();
2005 const Element *trp0 = cp;
2006 const Element *
const trp0_last = trp0+this->fNelems;
2007 while (trp0 < trp0_last) {
2008 memcpy(trp,trp0,this->fNcols*
sizeof(Element));
2009 for (
const Element *scp = sp; scp < sp+this->fNcols; ) {
2012 for (
Int_t j = 0; j < this->fNcols; j++) {
2013 cij += trp[j] * *scp;
2014 scp += this->fNcols;
2019 trp0 += this->fNcols;
2023 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2034template<
class Element>
2041 Error(
"operator*=(const TMatrixTSym &)",
"source matrix has wrong shape");
2058 Element work[kWorkMax];
2060 Element *trp = work;
2061 if (this->fNcols > kWorkMax) {
2062 isAllocated =
kTRUE;
2063 trp =
new Element[this->fNcols];
2066 Element *cp = this->GetMatrixArray();
2067 const Element *trp0 = cp;
2068 const Element *
const trp0_last = trp0+this->fNelems;
2069 while (trp0 < trp0_last) {
2070 memcpy(trp,trp0,this->fNcols*
sizeof(Element));
2071 for (
const Element *scp = sp; scp < sp+this->fNcols; ) {
2074 for (
Int_t j = 0; j < this->fNcols; j++) {
2075 cij += trp[j] * *scp;
2076 scp += this->fNcols;
2081 trp0 += this->fNcols;
2085 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2096template<
class Element>
2103 Error(
"operator*=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2108 Element *mp = this->GetMatrixArray();
2109 const Element *
const mp_last = mp+this->fNelems;
2111 while (mp < mp_last) {
2112 const Element *dp = diag.
GetPtr();
2113 for (
Int_t j = 0; j < this->fNcols; j++) {
2126template<
class Element>
2133 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2138 Element *mp = this->GetMatrixArray();
2139 const Element *
const mp_last = mp+this->fNelems;
2141 while (mp < mp_last) {
2142 const Element *dp = diag.
GetPtr();
2143 for (
Int_t j = 0; j < this->fNcols; j++) {
2147 Error(
"operator/=",
"%d-diagonal element is zero",j);
2161template<
class Element>
2169 if (this->fNrows != mt->
GetNrows()) {
2170 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2176 Element *mp = this->GetMatrixArray();
2177 const Element *
const mp_last = mp+this->fNelems;
2178 const Element *cp = col.
GetPtr();
2180 while (mp < mp_last) {
2182 for (
Int_t j = 0; j < this->fNcols; j++)
2194template<
class Element>
2202 if (this->fNrows != mt->
GetNrows()) {
2203 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2209 Element *mp = this->GetMatrixArray();
2210 const Element *
const mp_last = mp+this->fNelems;
2211 const Element *cp = col.
GetPtr();
2213 while (mp < mp_last) {
2216 for (
Int_t j = 0; j < this->fNcols; j++)
2220 Error(
"operator/=",
"%d-row of matrix column is zero",icol);
2233template<
class Element>
2241 if (this->fNcols != mt->
GetNcols()) {
2242 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2248 Element *mp = this->GetMatrixArray();
2249 const Element *
const mp_last = mp+this->fNelems;
2251 while (mp < mp_last) {
2252 const Element *rp = row.
GetPtr();
2253 for (
Int_t j = 0; j < this->fNcols; j++) {
2267template<
class Element>
2274 if (this->fNcols != mt->
GetNcols()) {
2275 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2280 Element *mp = this->GetMatrixArray();
2281 const Element *
const mp_last = mp+this->fNelems;
2283 while (mp < mp_last) {
2284 const Element *rp = row.
GetPtr();
2285 for (
Int_t j = 0; j < this->fNcols; j++) {
2290 Error(
"operator/=",
"%d-col of matrix row is zero",j);
2306template<
class Element>
2309 if (!this->IsSymmetric())
2310 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2312 eigenValues.
ResizeTo(this->fNrows);
2320template<
class Element>
2331template<
class Element>
2342template<
class Element>
2351template<
class Element>
2362template<
class Element>
2371template<
class Element>
2382template<
class Element>
2393template<
class Element>
2396 return Element(-1.0)*(
operator-(source2,source1));
2402template<
class Element>
2413template<
class Element>
2416 return Element(-1.0)*
operator-(source,val);
2422template<
class Element>
2433template<
class Element>
2442template<
class Element>
2452template<
class Element>
2462template<
class Element>
2472template<
class Element>
2482template<
class Element>
2488 Error(
"operator&&(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2498 while (tp < tp_last)
2499 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2507template<
class Element>
2513 Error(
"operator&&(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2523 while (tp < tp_last)
2524 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2532template<
class Element>
2541template<
class Element>
2547 Error(
"operator||(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2557 while (tp < tp_last)
2558 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2566template<
class Element>
2572 Error(
"operator||(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2582 while (tp < tp_last)
2583 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2591template<
class Element>
2600template<
class Element>
2606 Error(
"operator|(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2616 while (tp < tp_last) {
2617 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2626template<
class Element>
2632 Error(
"operator>(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2642 while (tp < tp_last) {
2643 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2652template<
class Element>
2661template<
class Element>
2667 Error(
"operator>=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2677 while (tp < tp_last) {
2678 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2687template<
class Element>
2693 Error(
"operator>=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2703 while (tp < tp_last) {
2704 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2713template<
class Element>
2722template<
class Element>
2728 Error(
"operator<=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2738 while (tp < tp_last) {
2739 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2748template<
class Element>
2754 Error(
"operator<=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2764 while (tp < tp_last) {
2765 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2774template<
class Element>
2783template<
class Element>
2789 Error(
"operator<(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2797 while (tp < tp_last) {
2798 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2807template<
class Element>
2813 Error(
"operator<(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2823 while (tp < tp_last) {
2824 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2833template<
class Element>
2842template<
class Element>
2848 Error(
"operator!=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2858 while (tp != tp_last) {
2859 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2868template<
class Element>
2874 Error(
"operator!=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2884 while (tp != tp_last) {
2885 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2894template<
class Element>
2904template<class Element>
2905TMatrixT<Element> operator!=(const TMatrixT<Element> &source1,Element val)
2907 TMatrixT<Element> target; target.ResizeTo(source1);
2909 const Element *sp = source1.GetMatrixArray();
2910 Element *tp = target.GetMatrixArray();
2911 const Element * const tp_last = tp+target.GetNoElements();
2912 while (tp != tp_last) {
2913 *tp++ = (*sp != val); sp++;
2922template<class Element>
2923TMatrixT<Element> operator!=(Element val,const TMatrixT<Element> &source1)
2925 return operator!=(source1,val);
2932template<
class Element>
2936 ::Error(
"Add(TMatrixT &,Element,const TMatrixT &)",
"matrices not compatible");
2945 *tp++ = scalar * (*sp++);
2946 }
else if (scalar == 1.) {
2951 *tp++ += scalar * (*sp++);
2960template<
class Element>
2964 ::Error(
"Add(TMatrixT &,Element,const TMatrixTSym &)",
"matrices not compatible");
2972 *tp++ += scalar * (*sp++);
2980template<
class Element>
2984 ::Error(
"ElementMult(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3000template<
class Element>
3004 ::Error(
"ElementMult(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3020template<
class Element>
3024 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3031 while ( tp < ftp ) {
3037 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3048template<
class Element>
3052 ::Error(
"ElementDiv(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3059 while ( tp < ftp ) {
3065 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3076template<
class Element>
3078 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3080 const Element *arp0 = ap;
3081 while (arp0 < ap+na) {
3082 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
3083 const Element *arp = arp0;
3085 while (bcp < bp+nb) {
3086 cij += *arp++ * *bcp;
3099template<
class Element>
3101 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3103 const Element *acp0 = ap;
3104 while (acp0 < ap+ncolsa) {
3105 for (
const Element *bcp = bp; bcp < bp+ncolsb; ) {
3106 const Element *acp = acp0;
3108 while (bcp < bp+nb) {
3123template<
class Element>
3125 const Element *
const bp,
Int_t nb,
Int_t ncolsb,Element *cp)
3127 const Element *arp0 = ap;
3128 while (arp0 < ap+na) {
3129 const Element *brp0 = bp;
3130 while (brp0 < bp+nb) {
3131 const Element *arp = arp0;
3132 const Element *brp = brp0;
3134 while (brp < brp0+ncolsb)
3135 cij += *arp++ * *brp++;
3146template<
class Element>
3155 }
else if (R__v == 2) {
3157 TObject::Streamer(R__b);
3159 R__b >> this->fNrows;
3160 R__b >> this->fNcols;
3161 R__b >> this->fNelems;
3162 R__b >> this->fRowLwb;
3163 R__b >> this->fColLwb;
3167 if (this->fNelems > 0) {
3168 fElements =
new Element[this->fNelems];
3175 TObject::Streamer(R__b);
3177 R__b >> this->fNrows;
3178 R__b >> this->fNcols;
3179 R__b >> this->fRowLwb;
3180 R__b >> this->fColLwb;
3181 this->fNelems = R__b.
ReadArray(fElements);
3185 if (R__v <= 2 && fElements) {
3186 for (
Int_t i = 0; i < this->fNrows; i++) {
3187 const Int_t off_i = i*this->fNcols;
3188 for (
Int_t j = i; j < this->fNcols; j++) {
3189 const Int_t off_j = j*this->fNrows;
3190 const Element tmp = fElements[off_i+j];
3191 fElements[off_i+j] = fElements[off_j+i];
3192 fElements[off_j+i] = tmp;
3196 if (this->fNelems > 0 && this->fNelems <= this->kSizeMax) {
3198 memcpy(fDataStack,fElements,this->fNelems*
sizeof(Element));
3199 delete [] fElements;
3201 fElements = fDataStack;
3202 }
else if (this->fNelems < 0)
#define templateClassImp(name)
void Error(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
R__EXTERN Int_t gMatrixCheck
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 .
TMatrixT< Element > operator<(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 < source2
template TMatrixF operator<<Float_t >(const TMatrixF &source1, const TMatrixF &source2)
template void AMultB< Double_t >(const Double_t *const ap, Int_t na, Int_t ncolsa, const Double_t *const bp, Int_t nb, Int_t ncolsb, Double_t *cp)
TMatrixT< Element > operator>=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 >= source2
TMatrixT< Element > operator||(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical OR.
TMatrixT< Element > & ElementMult(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Multiply target by the source, element-by-element.
template void AtMultB< Float_t >(const Float_t *const ap, Int_t ncolsa, const Float_t *const bp, Int_t nb, Int_t ncolsb, Float_t *cp)
TMatrixT< Element > operator!=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 != source2
TMatrixT< Element > operator*(Element val, const TMatrixT< Element > &source)
operation this = val*source
template void AMultBt< Float_t >(const Float_t *const ap, Int_t na, Int_t ncolsa, const Float_t *const bp, Int_t nb, Int_t ncolsb, Float_t *cp)
template TMatrixF & ElementMult< Float_t >(TMatrixF &target, const TMatrixF &source)
template void AMultBt< Double_t >(const Double_t *const ap, Int_t na, Int_t ncolsa, const Double_t *const bp, Int_t nb, Int_t ncolsb, Double_t *cp)
template void AMultB< Float_t >(const Float_t *const ap, Int_t na, Int_t ncolsa, const Float_t *const bp, Int_t nb, Int_t ncolsb, Float_t *cp)
TMatrixT< Element > operator<=(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 <= source2
template void AtMultB< Double_t >(const Double_t *const ap, Int_t ncolsa, const Double_t *const bp, Int_t nb, Int_t ncolsb, Double_t *cp)
TMatrixT< Element > & ElementDiv(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Divide target by the source, element-by-element.
void AtMultB(const Element *const ap, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A^T*B.
template TMatrixF & ElementDiv< Float_t >(TMatrixF &target, const TMatrixF &source)
TMatrixT< Element > operator>(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
logical operation source1 > source2
template TMatrixF & Add< Float_t >(TMatrixF &target, Float_t scalar, const TMatrixF &source)
TMatrixT< Element > operator-(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1-source2
template TMatrixD operator<=< Double_t >(const TMatrixD &source1, const TMatrixD &source2)
TMatrixT< Element > operator+(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
operation this = source1+source2
template TMatrixF operator<=< Float_t >(const TMatrixF &source1, const TMatrixF &source2)
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
template TMatrixD & ElementMult< Double_t >(TMatrixD &target, const TMatrixD &source)
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.
template TMatrixD & ElementDiv< Double_t >(TMatrixD &target, const TMatrixD &source)
template TMatrixD & Add< Double_t >(TMatrixD &target, Double_t scalar, const TMatrixD &source)
TMatrixT< Element > operator&&(const TMatrixT< Element > &source1, const TMatrixT< Element > &source2)
Logical AND.
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.
template TMatrixD operator<<Double_t >(const TMatrixD &source1, const TMatrixD &source2)
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=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 WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Det(Double_t &d1, Double_t &d2)
Calculate determinant det = d1*TMath::Power(2.,d2)
static Bool_t InvertLU(TMatrixD &a, Double_t tol, Double_t *det=0)
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
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1)=0
Int_t GetNoElements() const
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
virtual const Int_t * GetRowIndexArray() const
virtual const Element * GetMatrixArray() const
virtual const Int_t * GetColIndexArray() const
virtual const Element * GetMatrixArray() const
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.
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixT< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
virtual const Element * GetMatrixArray() const
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,...
void Minus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Create a matrix C such that C = A - B.
Element Similarity(const TVectorT< Element > &v) const
Calculate scalar v * (*this) * v^T.
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
virtual Double_t Determinant() const
Return the matrix determinant.
void Plus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Create a matrix C such that C = A + B.
TMatrixT< Element > & InvertFast(Double_t *det=0)
Invert the matrix and calculate its determinant, however upto (6x6) a fast Cramer inversion is used .
TMatrixT< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
TMatrixT< Element > & Transpose(const TMatrixT< Element > &source)
Transpose matrix source.
void MultT(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B^T.
virtual TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source)
Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part [row_lwb....
virtual TMatrixTBase< Element > & GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixTBase< Element > &target, Option_t *option="S") const
Get submatrix [row_lwb..row_upb] x [col_lwb..col_upb]; The indexing range of the returned matrix depe...
Element * New_m(Int_t size)
Return data pointer .
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)
Create a matrix 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. Create a matrix 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.
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] .
Int_t GetNoElements() const
Element * GetMatrixArray()
Expr< TransposeOp< SMatrix< T, D1, D2, R >, T, D1, D2 >, T, D2, D1, typename TranspPolicy< T, D1, D2, R >::RepType > Transpose(const SMatrix< T, D1, D2, R > &rhs)
Matrix Transpose B(i,j) = A(j,i) returning a matrix expression.
TCppObject_t Allocate(TCppType_t type)
DisplacementVector3D< CoordSystem, U > Mult(const Matrix &m, const DisplacementVector3D< CoordSystem, U > &v)
Multiplications of a generic matrices with a DisplacementVector3D of any coordinate system.
int Invert(LASymMatrix &)
Short_t Max(Short_t a, Short_t b)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Short_t Min(Short_t a, Short_t b)