41template<
class Element>
50template<
class Element>
53 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb,1);
64template<
class Element>
74template<
class Element>
78 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb);
85template<
class Element>
96template<
class Element>
107template<
class Element>
120template<
class Element>
150 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
152 this->SetTol(oldTol);
158 TMult(prototype,prototype);
162 Error(
"TMatrixT(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
171template<
class Element>
179 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
184 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
195 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
197 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
199 this->SetTol(oldTol);
206 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
213 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
219 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
228template<
class Element>
236 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
241 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
246 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1);
252 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
254 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
256 this->SetTol(oldTol);
263 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
270 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
276 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
285template<
class Element>
293 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
298 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
303 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1);
309 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
311 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
313 this->SetTol(oldTol);
320 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
327 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
333 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
342template<
class Element>
350 Allocate(
a.GetNrows(),
b.GetNcols(),
a.GetRowLwb(),
b.GetColLwb(),1);
355 Allocate(
a.GetNcols(),
b.GetNcols(),
a.GetColLwb(),
b.GetColLwb(),1);
360 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1);
366 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
368 const Element oldTol = this->SetTol(std::numeric_limits<Element>::min());
370 this->SetTol(oldTol);
377 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
384 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb(),1);
390 Error(
"TMatrixT(EMatrixCreatorOp2)",
"operation %d not yet implemented", op);
397template<
class Element>
403 lazy_constructor.
FillIn(*
this);
409template<
class Element>
413 if (size > this->kSizeMax)
423template<
class Element>
426 if (size == 0)
return 0;
428 if ( size <= this->kSizeMax )
431 Element *heap =
new Element[size];
441template<
class Element>
445 if (copySize == 0 || oldp == newp)
448 if ( newSize <= this->kSizeMax && oldSize <= this->kSizeMax ) {
451 for (
Int_t i = copySize-1; i >= 0; i--)
454 for (
Int_t i = 0; i < copySize; i++)
459 memcpy(newp,oldp,copySize*
sizeof(Element));
468template<
class Element>
472 this->fIsOwner =
kTRUE;
481 if (no_rows < 0 || no_cols < 0)
483 Error(
"Allocate",
"no_rows=%d no_cols=%d",no_rows,no_cols);
489 this->fNrows = no_rows;
490 this->fNcols = no_cols;
491 this->fRowLwb = row_lwb;
492 this->fColLwb = col_lwb;
493 this->fNelems = this->fNrows*this->fNcols;
496 if( ((
Long64_t)this->fNrows)*this->fNcols != this->fNelems )
498 Error(
"Allocate",
"too large: no_rows=%d no_cols=%d",no_rows,no_cols);
503 if (this->fNelems > 0) {
504 fElements = New_m(this->fNelems);
506 memset(fElements,0,this->fNelems*
sizeof(Element));
514template<
class Element>
519 Error(
"Plus",
"matrices not compatible");
523 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
524 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
528 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
529 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
534 const Element * ap =
a.GetMatrixArray();
535 const Element * bp =
b.GetMatrixArray();
536 Element * cp = this->GetMatrixArray();
537 const Element *
const cp_last = cp+this->fNelems;
539 while (cp < cp_last) {
548template<
class Element>
553 Error(
"Plus",
"matrices not compatible");
557 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
558 Error(
"Plus",
"this->GetMatrixArray() == a.GetMatrixArray()");
562 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
563 Error(
"Plus",
"this->GetMatrixArray() == b.GetMatrixArray()");
568 const Element * ap =
a.GetMatrixArray();
569 const Element * bp =
b.GetMatrixArray();
570 Element * cp = this->GetMatrixArray();
571 const Element *
const cp_last = cp+this->fNelems;
573 while (cp < cp_last) {
582template<
class Element>
587 Error(
"Minus",
"matrices not compatible");
591 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
592 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
596 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
597 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
602 const Element * ap =
a.GetMatrixArray();
603 const Element * bp =
b.GetMatrixArray();
604 Element * cp = this->GetMatrixArray();
605 const Element *
const cp_last = cp+this->fNelems;
607 while (cp < cp_last) {
616template<
class Element>
621 Error(
"Minus",
"matrices not compatible");
625 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
626 Error(
"Minus",
"this->GetMatrixArray() == a.GetMatrixArray()");
630 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
631 Error(
"Minus",
"this->GetMatrixArray() == b.GetMatrixArray()");
636 const Element * ap =
a.GetMatrixArray();
637 const Element * bp =
b.GetMatrixArray();
638 Element * cp = this->GetMatrixArray();
639 const Element *
const cp_last = cp+this->fNelems;
641 while (cp < cp_last) {
650template<
class Element>
654 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
655 Error(
"Mult",
"A rows and B columns incompatible");
659 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
660 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
664 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
665 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
671 const Element *ap =
a.GetMatrixArray();
672 const Element *bp =
b.GetMatrixArray();
673 Element *cp = this->GetMatrixArray();
674 if (
typeid(Element) ==
typeid(
Double_t))
675 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasNoTrans,fNrows,fNcols,
a.GetNcols(),
676 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
677 else if (
typeid(Element) !=
typeid(
Float_t))
678 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasNoTrans,fNrows,fNcols,
a.GetNcols(),
679 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
681 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
683 const Int_t na =
a.GetNoElements();
684 const Int_t nb =
b.GetNoElements();
685 const Int_t ncolsa =
a.GetNcols();
686 const Int_t ncolsb =
b.GetNcols();
687 const Element *
const ap =
a.GetMatrixArray();
688 const Element *
const bp =
b.GetMatrixArray();
689 Element * cp = this->GetMatrixArray();
691 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
699template<
class Element>
705 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
706 Error(
"Mult",
"A rows and B columns incompatible");
710 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
711 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
715 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
716 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
722 const Element *ap =
a.GetMatrixArray();
723 const Element *bp =
b.GetMatrixArray();
724 Element *cp = this->GetMatrixArray();
725 if (
typeid(Element) ==
typeid(
Double_t))
726 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
727 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
728 else if (
typeid(Element) !=
typeid(
Float_t))
729 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
730 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
732 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
734 const Int_t na =
a.GetNoElements();
735 const Int_t nb =
b.GetNoElements();
736 const Int_t ncolsa =
a.GetNcols();
737 const Int_t ncolsb =
b.GetNcols();
738 const Element *
const ap =
a.GetMatrixArray();
739 const Element *
const bp =
b.GetMatrixArray();
740 Element * cp = this->GetMatrixArray();
742 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
751template<
class Element>
757 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
758 Error(
"Mult",
"A rows and B columns incompatible");
762 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
763 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
767 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
768 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
774 const Element *ap =
a.GetMatrixArray();
775 const Element *bp =
b.GetMatrixArray();
776 Element *cp = this->GetMatrixArray();
777 if (
typeid(Element) ==
typeid(
Double_t))
778 cblas_dsymm (CblasRowMajor,CblasRight,CblasUpper,fNrows,fNcols,1.0,
779 bp,
b.GetNcols(),ap,
a.GetNcols(),0.0,cp,fNcols);
780 else if (
typeid(Element) !=
typeid(
Float_t))
781 cblas_ssymm (CblasRowMajor,CblasRight,CblasUpper,fNrows,fNcols,1.0,
782 bp,
b.GetNcols(),ap,
a.GetNcols(),0.0,cp,fNcols);
784 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
786 const Int_t na =
a.GetNoElements();
787 const Int_t nb =
b.GetNoElements();
788 const Int_t ncolsa =
a.GetNcols();
789 const Int_t ncolsb =
b.GetNcols();
790 const Element *
const ap =
a.GetMatrixArray();
791 const Element *
const bp =
b.GetMatrixArray();
792 Element * cp = this->GetMatrixArray();
794 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
803template<
class Element>
809 if (
a.GetNcols() !=
b.GetNrows() ||
a.GetColLwb() !=
b.GetRowLwb()) {
810 Error(
"Mult",
"A rows and B columns incompatible");
814 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
815 Error(
"Mult",
"this->GetMatrixArray() == a.GetMatrixArray()");
819 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
820 Error(
"Mult",
"this->GetMatrixArray() == b.GetMatrixArray()");
826 const Element *ap =
a.GetMatrixArray();
827 const Element *bp =
b.GetMatrixArray();
828 Element *cp = this->GetMatrixArray();
829 if (
typeid(Element) ==
typeid(
Double_t))
830 cblas_dsymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
831 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
832 else if (
typeid(Element) !=
typeid(
Float_t))
833 cblas_ssymm (CblasRowMajor,CblasLeft,CblasUpper,fNrows,fNcols,1.0,
834 ap,
a.GetNcols(),bp,
b.GetNcols(),0.0,cp,fNcols);
836 Error(
"Mult",
"type %s not implemented in BLAS library",
typeid(Element));
838 const Int_t na =
a.GetNoElements();
839 const Int_t nb =
b.GetNoElements();
840 const Int_t ncolsa =
a.GetNcols();
841 const Int_t ncolsb =
b.GetNcols();
842 const Element *
const ap =
a.GetMatrixArray();
843 const Element *
const bp =
b.GetMatrixArray();
844 Element * cp = this->GetMatrixArray();
846 AMultB(ap,na,ncolsa,bp,nb,ncolsb,cp);
854template<
class Element>
860 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
861 Error(
"TMult",
"A rows and B columns incompatible");
865 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
866 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
870 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
871 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
877 const Element *ap =
a.GetMatrixArray();
878 const Element *bp =
b.GetMatrixArray();
879 Element *cp = this->GetMatrixArray();
880 if (
typeid(Element) ==
typeid(
Double_t))
881 cblas_dgemm (CblasRowMajor,CblasTrans,CblasNoTrans,this->fNrows,this->fNcols,
a.GetNrows(),
882 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,this->fNcols);
883 else if (
typeid(Element) !=
typeid(
Float_t))
884 cblas_sgemm (CblasRowMajor,CblasTrans,CblasNoTrans,fNrows,fNcols,
a.GetNrows(),
885 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
887 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
889 const Int_t nb =
b.GetNoElements();
890 const Int_t ncolsa =
a.GetNcols();
891 const Int_t ncolsb =
b.GetNcols();
892 const Element *
const ap =
a.GetMatrixArray();
893 const Element *
const bp =
b.GetMatrixArray();
894 Element * cp = this->GetMatrixArray();
896 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
904template<
class Element>
910 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetRowLwb() !=
b.GetRowLwb()) {
911 Error(
"TMult",
"A rows and B columns incompatible");
915 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
916 Error(
"TMult",
"this->GetMatrixArray() == a.GetMatrixArray()");
920 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
921 Error(
"TMult",
"this->GetMatrixArray() == b.GetMatrixArray()");
927 const Element *ap =
a.GetMatrixArray();
928 const Element *bp =
b.GetMatrixArray();
929 Element *cp = this->GetMatrixArray();
930 if (
typeid(Element) ==
typeid(
Double_t))
931 cblas_dgemm (CblasRowMajor,CblasTrans,CblasNoTrans,fNrows,fNcols,
a.GetNrows(),
932 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
933 else if (
typeid(Element) !=
typeid(
Float_t))
934 cblas_sgemm (CblasRowMajor,CblasTrans,CblasNoTrans,fNrows,fNcols,
a.GetNrows(),
935 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
937 Error(
"TMult",
"type %s not implemented in BLAS library",
typeid(Element));
939 const Int_t nb =
b.GetNoElements();
940 const Int_t ncolsa =
a.GetNcols();
941 const Int_t ncolsb =
b.GetNcols();
942 const Element *
const ap =
a.GetMatrixArray();
943 const Element *
const bp =
b.GetMatrixArray();
944 Element * cp = this->GetMatrixArray();
946 AtMultB(ap,ncolsa,bp,nb,ncolsb,cp);
953template<
class Element>
960 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
961 Error(
"MultT",
"A rows and B columns incompatible");
965 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
966 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
970 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
971 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
977 const Element *ap =
a.GetMatrixArray();
978 const Element *bp =
b.GetMatrixArray();
979 Element *cp = this->GetMatrixArray();
980 if (
typeid(Element) ==
typeid(
Double_t))
981 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasTrans,fNrows,fNcols,
a.GetNcols(),
982 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
983 else if (
typeid(Element) !=
typeid(
Float_t))
984 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasTrans,fNrows,fNcols,
a.GetNcols(),
985 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
987 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
989 const Int_t na =
a.GetNoElements();
990 const Int_t nb =
b.GetNoElements();
991 const Int_t ncolsa =
a.GetNcols();
992 const Int_t ncolsb =
b.GetNcols();
993 const Element *
const ap =
a.GetMatrixArray();
994 const Element *
const bp =
b.GetMatrixArray();
995 Element * cp = this->GetMatrixArray();
997 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1005template<
class Element>
1011 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
1012 Error(
"MultT",
"A rows and B columns incompatible");
1016 if (this->GetMatrixArray() ==
a.GetMatrixArray()) {
1017 Error(
"MultT",
"this->GetMatrixArray() == a.GetMatrixArray()");
1021 if (this->GetMatrixArray() ==
b.GetMatrixArray()) {
1022 Error(
"MultT",
"this->GetMatrixArray() == b.GetMatrixArray()");
1028 const Element *ap =
a.GetMatrixArray();
1029 const Element *bp =
b.GetMatrixArray();
1030 Element *cp = this->GetMatrixArray();
1031 if (
typeid(Element) ==
typeid(
Double_t))
1032 cblas_dgemm (CblasRowMajor,CblasNoTrans,CblasTrans,this->fNrows,this->fNcols,
a.GetNcols(),
1033 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,this->fNcols);
1034 else if (
typeid(Element) !=
typeid(
Float_t))
1035 cblas_sgemm (CblasRowMajor,CblasNoTrans,CblasTrans,fNrows,fNcols,
a.GetNcols(),
1036 1.0,ap,
a.GetNcols(),bp,
b.GetNcols(),1.0,cp,fNcols);
1038 Error(
"MultT",
"type %s not implemented in BLAS library",
typeid(Element));
1040 const Int_t na =
a.GetNoElements();
1041 const Int_t nb =
b.GetNoElements();
1042 const Int_t ncolsa =
a.GetNcols();
1043 const Int_t ncolsb =
b.GetNcols();
1044 const Element *
const ap =
a.GetMatrixArray();
1045 const Element *
const bp =
b.GetMatrixArray();
1046 Element * cp = this->GetMatrixArray();
1048 AMultBt(ap,na,ncolsa,bp,nb,ncolsb,cp);
1055template<
class Element>
1060 if (row_upb < row_lwb)
1062 Error(
"Use",
"row_upb=%d < row_lwb=%d",row_upb,row_lwb);
1065 if (col_upb < col_lwb)
1067 Error(
"Use",
"col_upb=%d < col_lwb=%d",col_upb,col_lwb);
1073 this->fNrows = row_upb-row_lwb+1;
1074 this->fNcols = col_upb-col_lwb+1;
1075 this->fRowLwb = row_lwb;
1076 this->fColLwb = col_lwb;
1077 this->fNelems = this->fNrows*this->fNcols;
1091template<
class Element>
1097 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb+this->fNrows-1) {
1098 Error(
"GetSub",
"row_lwb out of bounds");
1101 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb+this->fNcols-1) {
1102 Error(
"GetSub",
"col_lwb out of bounds");
1105 if (row_upb < this->fRowLwb || row_upb > this->fRowLwb+this->fNrows-1) {
1106 Error(
"GetSub",
"row_upb out of bounds");
1109 if (col_upb < this->fColLwb || col_upb > this->fColLwb+this->fNcols-1) {
1110 Error(
"GetSub",
"col_upb out of bounds");
1113 if (row_upb < row_lwb || col_upb < col_lwb) {
1114 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1123 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1124 const Int_t row_upb_sub = (shift) ? row_upb-row_lwb : row_upb;
1125 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1126 const Int_t col_upb_sub = (shift) ? col_upb-col_lwb : col_upb;
1128 target.
ResizeTo(row_lwb_sub,row_upb_sub,col_lwb_sub,col_upb_sub);
1129 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
1130 const Int_t ncols_sub = col_upb_sub-col_lwb_sub+1;
1133 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1134 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1135 target(irow+row_lwb_sub,icol+col_lwb_sub) = (*this)(row_lwb+irow,col_lwb+icol);
1139 const Element *ap = this->GetMatrixArray()+(row_lwb-this->fRowLwb)*this->fNcols+(col_lwb-this->fColLwb);
1142 for (
Int_t irow = 0; irow < nrows_sub; irow++) {
1143 const Element *ap_sub = ap;
1144 for (
Int_t icol = 0; icol < ncols_sub; icol++) {
1158template<
class Element>
1165 if (row_lwb < this->fRowLwb || row_lwb > this->fRowLwb+this->fNrows-1) {
1166 Error(
"SetSub",
"row_lwb outof bounds");
1169 if (col_lwb < this->fColLwb || col_lwb > this->fColLwb+this->fNcols-1) {
1170 Error(
"SetSub",
"col_lwb outof bounds");
1173 if (row_lwb+source.
GetNrows() > this->fRowLwb+this->fNrows ||
1174 col_lwb+source.
GetNcols() > this->fColLwb+this->fNcols) {
1175 Error(
"SetSub",
"source matrix too large");
1186 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1187 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1188 (*this)(row_lwb+irow,col_lwb+icol) = source(rowlwb_s+irow,collwb_s+icol);
1193 Element *ap = this->GetMatrixArray()+(row_lwb-this->fRowLwb)*this->fNcols+(col_lwb-this->fColLwb);
1195 for (
Int_t irow = 0; irow < nRows_source; irow++) {
1196 Element *ap_sub = ap;
1197 for (
Int_t icol = 0; icol < nCols_source; icol++) {
1212template<
class Element>
1216 if (!this->fIsOwner) {
1217 Error(
"ResizeTo(Int_t,Int_t)",
"Not owner of data array,cannot resize");
1221 if (this->fNelems > 0) {
1222 if (this->fNrows == nrows && this->fNcols == ncols)
1224 else if (nrows == 0 || ncols == 0) {
1225 this->fNrows = nrows; this->fNcols = ncols;
1230 Element *elements_old = GetMatrixArray();
1231 const Int_t nelems_old = this->fNelems;
1232 const Int_t nrows_old = this->fNrows;
1233 const Int_t ncols_old = this->fNcols;
1238 Element *elements_new = GetMatrixArray();
1241 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
1242 memset(elements_new,0,this->fNelems*
sizeof(Element));
1243 else if (this->fNelems > nelems_old)
1244 memset(elements_new+nelems_old,0,(this->fNelems-nelems_old)*
sizeof(Element));
1250 const Int_t nelems_new = this->fNelems;
1251 if (ncols_old < this->fNcols) {
1252 for (
Int_t i = nrows_copy-1; i >= 0; i--) {
1253 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1254 nelems_new,nelems_old);
1255 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
1256 memset(elements_new+i*this->fNcols+ncols_copy,0,(this->fNcols-ncols_copy)*
sizeof(Element));
1259 for (
Int_t i = 0; i < nrows_copy; i++)
1260 Memcpy_m(elements_new+i*this->fNcols,elements_old+i*ncols_old,ncols_copy,
1261 nelems_new,nelems_old);
1264 Delete_m(nelems_old,elements_old);
1277template<
class Element>
1282 if (!this->fIsOwner) {
1283 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1287 const Int_t new_nrows = row_upb-row_lwb+1;
1288 const Int_t new_ncols = col_upb-col_lwb+1;
1290 if (this->fNelems > 0) {
1292 if (this->fNrows == new_nrows && this->fNcols == new_ncols &&
1293 this->fRowLwb == row_lwb && this->fColLwb == col_lwb)
1295 else if (new_nrows == 0 || new_ncols == 0) {
1296 this->fNrows = new_nrows; this->fNcols = new_ncols;
1297 this->fRowLwb = row_lwb; this->fColLwb = col_lwb;
1302 Element *elements_old = GetMatrixArray();
1303 const Int_t nelems_old = this->fNelems;
1304 const Int_t nrows_old = this->fNrows;
1305 const Int_t ncols_old = this->fNcols;
1306 const Int_t rowLwb_old = this->fRowLwb;
1307 const Int_t colLwb_old = this->fColLwb;
1309 Allocate(new_nrows,new_ncols,row_lwb,col_lwb);
1312 Element *elements_new = GetMatrixArray();
1315 if (this->fNelems > this->kSizeMax || nelems_old > this->kSizeMax)
1316 memset(elements_new,0,this->fNelems*
sizeof(Element));
1317 else if (this->fNelems > nelems_old)
1318 memset(elements_new+nelems_old,0,(this->fNelems-nelems_old)*
sizeof(Element));
1323 const Int_t rowUpb_copy =
TMath::Min(this->fRowLwb+this->fNrows-1,rowLwb_old+nrows_old-1);
1324 const Int_t colUpb_copy =
TMath::Min(this->fColLwb+this->fNcols-1,colLwb_old+ncols_old-1);
1326 const Int_t nrows_copy = rowUpb_copy-rowLwb_copy+1;
1327 const Int_t ncols_copy = colUpb_copy-colLwb_copy+1;
1329 if (nrows_copy > 0 && ncols_copy > 0) {
1330 const Int_t colOldOff = colLwb_copy-colLwb_old;
1331 const Int_t colNewOff = colLwb_copy-this->fColLwb;
1332 if (ncols_old < this->fNcols) {
1333 for (
Int_t i = nrows_copy-1; i >= 0; 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);
1338 if (this->fNelems <= this->kSizeMax && nelems_old <= this->kSizeMax)
1339 memset(elements_new+iRowNew*this->fNcols+colNewOff+ncols_copy,0,
1340 (this->fNcols-ncols_copy)*
sizeof(Element));
1343 for (
Int_t i = 0; i < nrows_copy; i++) {
1344 const Int_t iRowOld = rowLwb_copy+i-rowLwb_old;
1345 const Int_t iRowNew = rowLwb_copy+i-this->fRowLwb;
1346 Memcpy_m(elements_new+iRowNew*this->fNcols+colNewOff,
1347 elements_old+iRowOld*ncols_old+colOldOff,ncols_copy,this->fNelems,nelems_old);
1352 Delete_m(nelems_old,elements_old);
1354 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1);
1363template<
class Element>
1376template<
class Element>
1398template<
class Element>
1412template<
class Element>
1421 if (this->GetNrows() != this->GetNcols() || this->GetRowLwb() != this->GetColLwb()) {
1422 Error(
"Invert()",
"matrix should be square");
1424 Element *pM = this->GetMatrixArray();
1426 Error(
"InvertFast",
"matrix is singular");
1438 TMatrixTCramerInv::Inv2x2<Element>(*
this,det);
1443 TMatrixTCramerInv::Inv3x3<Element>(*
this,det);
1448 TMatrixTCramerInv::Inv4x4<Element>(*
this,det);
1453 TMatrixTCramerInv::Inv5x5<Element>(*
this,det);
1458 TMatrixTCramerInv::Inv6x6<Element>(*
this,det);
1471template<
class Element>
1478 Element *ap = this->GetMatrixArray();
1479 if (this->fNrows == this->fNcols && this->fRowLwb == this->fColLwb) {
1480 for (
Int_t i = 0; i < this->fNrows; i++) {
1481 const Int_t off_i = i*this->fNrows;
1482 for (
Int_t j = i+1; j < this->fNcols; j++) {
1483 const Int_t off_j = j*this->fNcols;
1484 const Element tmp = ap[off_i+j];
1485 ap[off_i+j] = ap[off_j+i];
1492 const Int_t nrows_old = this->fNrows;
1493 const Int_t ncols_old = this->fNcols;
1494 const Int_t rowlwb_old = this->fRowLwb;
1495 const Int_t collwb_old = this->fColLwb;
1497 this->fNrows = ncols_old; this->fNcols = nrows_old;
1498 this->fRowLwb = collwb_old; this->fColLwb = rowlwb_old;
1499 for (
Int_t irow = this->fRowLwb; irow < this->fRowLwb+this->fNrows; irow++) {
1500 for (
Int_t icol = this->fColLwb; icol < this->fColLwb+this->fNcols; icol++) {
1501 const Int_t off = (icol-collwb_old)*ncols_old;
1502 (*this)(irow,icol) = oldElems[off+irow-rowlwb_old];
1508 if (this->fNrows != source.
GetNcols() || this->fNcols != source.
GetNrows() ||
1511 Error(
"Transpose",
"matrix has wrong shape");
1516 const Element *scp = sp1;
1517 Element *tp = this->GetMatrixArray();
1518 const Element *
const tp_last = this->GetMatrixArray()+this->fNelems;
1522 while (tp < tp_last) {
1523 const Element *sp2 = scp++;
1526 while (sp2 < sp1+this->fNelems) {
1528 sp2 += this->fNrows;
1531 R__ASSERT(tp == tp_last && scp == sp1+this->fNrows);
1541template<
class Element>
1547 if (
v.GetNoElements() <
TMath::Max(this->fNrows,this->fNcols)) {
1548 Error(
"Rank1Update",
"vector too short");
1553 const Element *
const pv =
v.GetMatrixArray();
1554 Element *mp = this->GetMatrixArray();
1556 for (
Int_t i = 0; i < this->fNrows; i++) {
1557 const Element tmp = alpha*pv[i];
1558 for (
Int_t j = 0; j < this->fNcols; j++)
1569template<
class Element>
1576 if (
v1.GetNoElements() < this->fNrows) {
1577 Error(
"Rank1Update",
"vector v1 too short");
1581 if (
v2.GetNoElements() < this->fNcols) {
1582 Error(
"Rank1Update",
"vector v2 too short");
1587 const Element *
const pv1 =
v1.GetMatrixArray();
1588 const Element *
const pv2 =
v2.GetMatrixArray();
1589 Element *mp = this->GetMatrixArray();
1591 for (
Int_t i = 0; i < this->fNrows; i++) {
1592 const Element tmp = alpha*pv1[i];
1593 for (
Int_t j = 0; j < this->fNcols; j++)
1594 *mp++ += tmp*pv2[j];
1603template<
class Element>
1609 if (this->fNcols != this->fNrows || this->fColLwb != this->fRowLwb) {
1610 Error(
"Similarity(const TVectorT &)",
"matrix is not square");
1614 if (this->fNcols !=
v.GetNrows() || this->fColLwb !=
v.GetLwb()) {
1615 Error(
"Similarity(const TVectorT &)",
"vector and matrix incompatible");
1620 const Element *mp = this->GetMatrixArray();
1621 const Element *vp =
v.GetMatrixArray();
1624 const Element *
const vp_first = vp;
1625 const Element *
const vp_last = vp+
v.GetNrows();
1626 while (vp < vp_last) {
1628 for (
const Element *sp = vp_first; sp < vp_last; )
1629 sum2 += *mp++ * *sp++;
1630 sum1 += sum2 * *vp++;
1633 R__ASSERT(mp == this->GetMatrixArray()+this->GetNoElements());
1644template<
class Element>
1650 if (
v.GetNoElements() < this->fNrows) {
1651 Error(
"NormByColumn",
"vector shorter than matrix column");
1660 const Element *pv =
v.GetMatrixArray();
1661 Element *mp = this->GetMatrixArray();
1662 const Element *
const mp_last = mp+this->fNelems;
1665 for ( ; mp < mp_last; pv++) {
1666 for (
Int_t j = 0; j < this->fNcols; j++)
1671 Error(
"NormbyColumn",
"vector element %ld is zero",
Long_t(pv-
v.GetMatrixArray()));
1677 for ( ; mp < mp_last; pv++)
1678 for (
Int_t j = 0; j < this->fNcols; j++)
1691template<
class Element>
1697 if (
v.GetNoElements() < this->fNcols) {
1698 Error(
"NormByRow",
"vector shorter than matrix column");
1707 const Element *pv0 =
v.GetMatrixArray();
1708 const Element *pv = pv0;
1709 Element *mp = this->GetMatrixArray();
1710 const Element *
const mp_last = mp+this->fNelems;
1713 for ( ; mp < mp_last; pv = pv0 )
1714 for (
Int_t j = 0; j < this->fNcols; j++) {
1718 Error(
"NormbyRow",
"vector element %ld is zero",
Long_t(pv-pv0));
1723 for ( ; mp < mp_last; pv = pv0 )
1724 for (
Int_t j = 0; j < this->fNcols; j++)
1734template<
class Element>
1738 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
1744 memcpy(fElements,source.
GetMatrixArray(),this->fNelems*
sizeof(Element));
1745 this->fTol = source.
GetTol();
1753template<
class Element>
1757 Error(
"operator=(const TMatrixTSym &)",
"matrices not compatible");
1763 memcpy(fElements,source.
GetMatrixArray(),this->fNelems*
sizeof(Element));
1764 this->fTol = source.
GetTol();
1772template<
class Element>
1776 this->GetNrows() != source.
GetNrows()) || this->GetNcols() != source.
GetNcols() ||
1777 this->GetRowLwb() != source.
GetRowLwb() || this->GetColLwb() != source.
GetColLwb()) {
1778 Error(
"operator=(const TMatrixTSparse &",
"matrices not compatible");
1784 memset(fElements,0,this->fNelems*
sizeof(Element));
1787 Element * tp = this->GetMatrixArray();
1792 for (
Int_t irow = 0; irow < this->fNrows; irow++ ) {
1793 const Int_t off = irow*this->fNcols;
1794 const Int_t sIndex = pRowIndex[irow];
1795 const Int_t eIndex = pRowIndex[irow+1];
1796 for (
Int_t index = sIndex; index < eIndex; index++)
1797 tp[off+pColIndex[index]] = sp[index];
1799 this->fTol = source.
GetTol();
1807template<
class Element>
1812 if (lazy_constructor.
GetRowUpb() != this->GetRowUpb() ||
1813 lazy_constructor.
GetColUpb() != this->GetColUpb() ||
1814 lazy_constructor.
GetRowLwb() != this->GetRowLwb() ||
1815 lazy_constructor.
GetColLwb() != this->GetColLwb()) {
1816 Error(
"operator=(const TMatrixTLazy&)",
"matrix is incompatible with "
1817 "the assigned Lazy matrix");
1821 lazy_constructor.
FillIn(*
this);
1828template<
class Element>
1833 Element *ep = this->GetMatrixArray();
1834 const Element *
const ep_last = ep+this->fNelems;
1835 while (ep < ep_last)
1844template<
class Element>
1849 Element *ep = this->GetMatrixArray();
1850 const Element *
const ep_last = ep+this->fNelems;
1851 while (ep < ep_last)
1860template<
class Element>
1865 Element *ep = this->GetMatrixArray();
1866 const Element *
const ep_last = ep+this->fNelems;
1867 while (ep < ep_last)
1876template<
class Element>
1881 Element *ep = this->GetMatrixArray();
1882 const Element *
const ep_last = ep+this->fNelems;
1883 while (ep < ep_last)
1892template<
class Element>
1896 Error(
"operator+=(const TMatrixT &)",
"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 TMatrixTSym &)",
"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 TMatrixT &)",
"matrices not compatible");
1941 Element *tp = this->GetMatrixArray();
1942 const Element *
const tp_last = tp+this->fNelems;
1943 while (tp < tp_last)
1952template<
class Element>
1956 Error(
"operator=-(const TMatrixTSym &)",
"matrices not compatible");
1961 Element *tp = this->GetMatrixArray();
1962 const Element *
const tp_last = tp+this->fNelems;
1963 while (tp < tp_last)
1974template<
class Element>
1982 Error(
"operator*=(const TMatrixT &)",
"source matrix has wrong shape");
1999 Element work[kWorkMax];
2001 Element *trp = work;
2002 if (this->fNcols > kWorkMax) {
2003 isAllocated =
kTRUE;
2004 trp =
new Element[this->fNcols];
2007 Element *cp = this->GetMatrixArray();
2008 const Element *trp0 = cp;
2009 const Element *
const trp0_last = trp0+this->fNelems;
2010 while (trp0 < trp0_last) {
2011 memcpy(trp,trp0,this->fNcols*
sizeof(Element));
2012 for (
const Element *scp = sp; scp < sp+this->fNcols; ) {
2015 for (
Int_t j = 0; j < this->fNcols; j++) {
2016 cij += trp[j] * *scp;
2017 scp += this->fNcols;
2022 trp0 += this->fNcols;
2026 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2037template<
class Element>
2044 Error(
"operator*=(const TMatrixTSym &)",
"source matrix has wrong shape");
2061 Element work[kWorkMax];
2063 Element *trp = work;
2064 if (this->fNcols > kWorkMax) {
2065 isAllocated =
kTRUE;
2066 trp =
new Element[this->fNcols];
2069 Element *cp = this->GetMatrixArray();
2070 const Element *trp0 = cp;
2071 const Element *
const trp0_last = trp0+this->fNelems;
2072 while (trp0 < trp0_last) {
2073 memcpy(trp,trp0,this->fNcols*
sizeof(Element));
2074 for (
const Element *scp = sp; scp < sp+this->fNcols; ) {
2077 for (
Int_t j = 0; j < this->fNcols; j++) {
2078 cij += trp[j] * *scp;
2079 scp += this->fNcols;
2084 trp0 += this->fNcols;
2088 R__ASSERT(cp == trp0_last && trp0 == trp0_last);
2099template<
class Element>
2106 Error(
"operator*=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2111 Element *mp = this->GetMatrixArray();
2112 const Element *
const mp_last = mp+this->fNelems;
2114 while (mp < mp_last) {
2115 const Element *dp = diag.
GetPtr();
2116 for (
Int_t j = 0; j < this->fNcols; j++) {
2129template<
class Element>
2136 Error(
"operator/=(const TMatrixTDiag_const &)",
"wrong diagonal length");
2141 Element *mp = this->GetMatrixArray();
2142 const Element *
const mp_last = mp+this->fNelems;
2144 while (mp < mp_last) {
2145 const Element *dp = diag.
GetPtr();
2146 for (
Int_t j = 0; j < this->fNcols; j++) {
2150 Error(
"operator/=",
"%d-diagonal element is zero",j);
2164template<
class Element>
2172 if (this->fNrows != mt->
GetNrows()) {
2173 Error(
"operator*=(const TMatrixTColumn_const &)",
"wrong column length");
2179 Element *mp = this->GetMatrixArray();
2180 const Element *
const mp_last = mp+this->fNelems;
2181 const Element *cp = col.
GetPtr();
2183 while (mp < mp_last) {
2185 for (
Int_t j = 0; j < this->fNcols; j++)
2197template<
class Element>
2205 if (this->fNrows != mt->
GetNrows()) {
2206 Error(
"operator/=(const TMatrixTColumn_const &)",
"wrong column matrix");
2212 Element *mp = this->GetMatrixArray();
2213 const Element *
const mp_last = mp+this->fNelems;
2214 const Element *cp = col.
GetPtr();
2216 while (mp < mp_last) {
2219 for (
Int_t j = 0; j < this->fNcols; j++)
2223 Error(
"operator/=",
"%d-row of matrix column is zero",icol);
2236template<
class Element>
2244 if (this->fNcols != mt->
GetNcols()) {
2245 Error(
"operator*=(const TMatrixTRow_const &)",
"wrong row length");
2251 Element *mp = this->GetMatrixArray();
2252 const Element *
const mp_last = mp+this->fNelems;
2254 while (mp < mp_last) {
2255 const Element *rp = row.
GetPtr();
2256 for (
Int_t j = 0; j < this->fNcols; j++) {
2270template<
class Element>
2277 if (this->fNcols != mt->
GetNcols()) {
2278 Error(
"operator/=(const TMatrixTRow_const &)",
"wrong row length");
2283 Element *mp = this->GetMatrixArray();
2284 const Element *
const mp_last = mp+this->fNelems;
2286 while (mp < mp_last) {
2287 const Element *rp = row.
GetPtr();
2288 for (
Int_t j = 0; j < this->fNcols; j++) {
2293 Error(
"operator/=",
"%d-col of matrix row is zero",j);
2309template<
class Element>
2312 if (!this->IsSymmetric())
2313 Warning(
"EigenVectors(TVectorT &)",
"Only real part of eigen-values will be returned");
2315 eigenValues.
ResizeTo(this->fNrows);
2323template<
class Element>
2334template<
class Element>
2345template<
class Element>
2354template<
class Element>
2365template<
class Element>
2374template<
class Element>
2385template<
class Element>
2396template<
class Element>
2399 return Element(-1.0)*(
operator-(source2,source1));
2405template<
class Element>
2416template<
class Element>
2419 return Element(-1.0)*
operator-(source,val);
2425template<
class Element>
2436template<
class Element>
2445template<
class Element>
2455template<
class Element>
2465template<
class Element>
2475template<
class Element>
2485template<
class Element>
2491 Error(
"operator&&(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2501 while (tp < tp_last)
2502 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2510template<
class Element>
2516 Error(
"operator&&(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2526 while (tp < tp_last)
2527 *tp++ = (*sp1++ != 0.0 && *sp2++ != 0.0);
2535template<
class Element>
2544template<
class Element>
2550 Error(
"operator||(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2560 while (tp < tp_last)
2561 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2569template<
class Element>
2575 Error(
"operator||(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2585 while (tp < tp_last)
2586 *tp++ = (*sp1++ != 0.0 || *sp2++ != 0.0);
2594template<
class Element>
2603template<
class Element>
2609 Error(
"operator|(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2619 while (tp < tp_last) {
2620 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2629template<
class Element>
2635 Error(
"operator>(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2645 while (tp < tp_last) {
2646 *tp++ = (*sp1) > (*sp2); sp1++; sp2++;
2655template<
class Element>
2664template<
class Element>
2670 Error(
"operator>=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2680 while (tp < tp_last) {
2681 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2690template<
class Element>
2696 Error(
"operator>=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2706 while (tp < tp_last) {
2707 *tp++ = (*sp1) >= (*sp2); sp1++; sp2++;
2716template<
class Element>
2725template<
class Element>
2731 Error(
"operator<=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2741 while (tp < tp_last) {
2742 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2751template<
class Element>
2757 Error(
"operator<=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2767 while (tp < tp_last) {
2768 *tp++ = (*sp1) <= (*sp2); sp1++; sp2++;
2777template<
class Element>
2786template<
class Element>
2792 Error(
"operator<(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2800 while (tp < tp_last) {
2801 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2810template<
class Element>
2816 Error(
"operator<(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2826 while (tp < tp_last) {
2827 *tp++ = (*sp1) < (*sp2); sp1++; sp2++;
2836template<
class Element>
2845template<
class Element>
2851 Error(
"operator!=(const TMatrixT&,const TMatrixT&)",
"matrices not compatible");
2861 while (tp != tp_last) {
2862 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2871template<
class Element>
2877 Error(
"operator!=(const TMatrixT&,const TMatrixTSym&)",
"matrices not compatible");
2887 while (tp != tp_last) {
2888 *tp++ = (*sp1) != (*sp2); sp1++; sp2++;
2897template<
class Element>
2907template<class Element>
2908TMatrixT<Element> operator!=(const TMatrixT<Element> &source1,Element val)
2910 TMatrixT<Element> target; target.ResizeTo(source1);
2912 const Element *sp = source1.GetMatrixArray();
2913 Element *tp = target.GetMatrixArray();
2914 const Element * const tp_last = tp+target.GetNoElements();
2915 while (tp != tp_last) {
2916 *tp++ = (*sp != val); sp++;
2925template<class Element>
2926TMatrixT<Element> operator!=(Element val,const TMatrixT<Element> &source1)
2928 return operator!=(source1,val);
2935template<
class Element>
2939 ::Error(
"Add(TMatrixT &,Element,const TMatrixT &)",
"matrices not compatible");
2948 *tp++ = scalar * (*sp++);
2949 }
else if (scalar == 1.) {
2954 *tp++ += scalar * (*sp++);
2963template<
class Element>
2967 ::Error(
"Add(TMatrixT &,Element,const TMatrixTSym &)",
"matrices not compatible");
2975 *tp++ += scalar * (*sp++);
2983template<
class Element>
2987 ::Error(
"ElementMult(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3003template<
class Element>
3007 ::Error(
"ElementMult(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3023template<
class Element>
3027 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
3034 while ( tp < ftp ) {
3040 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3051template<
class Element>
3055 ::Error(
"ElementDiv(TMatrixT &,const TMatrixTSym &)",
"matrices not compatible");
3062 while ( tp < ftp ) {
3068 Error(
"ElementDiv",
"source (%d,%d) is zero",irow,icol);
3079template<
class Element>
3081 const Element *
const bp,
Int_t nb,
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 const Element *
const bp,
Int_t nb,
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 const Element *
const bp,
Int_t nb,
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) {
3160 TObject::Streamer(R__b);
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];
3178 TObject::Streamer(R__b);
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));
3202 delete [] fElements;
3204 fElements = fDataStack;
3205 }
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] .
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.
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
RPY_EXPORTED 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)