99template<
class Element>
109template<
class Element>
112 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb,1);
119template<
class Element>
128 if (row[irowmin] < row_lwb || row[irowmax] > row_upb) {
129 Error(
"TMatrixTSparse",
"Inconsistency between row index and its range");
130 if (row[irowmin] < row_lwb) {
131 Info(
"TMatrixTSparse",
"row index lower bound adjusted to %d",row[irowmin]);
132 row_lwb = row[irowmin];
134 if (row[irowmax] > row_upb) {
135 Info(
"TMatrixTSparse",
"row index upper bound adjusted to %d",row[irowmax]);
136 col_lwb = col[irowmax];
139 if (col[icolmin] < col_lwb || col[icolmax] > col_upb) {
140 Error(
"TMatrixTSparse",
"Inconsistency between column index and its range");
141 if (col[icolmin] < col_lwb) {
142 Info(
"TMatrixTSparse",
"column index lower bound adjusted to %d",col[icolmin]);
143 col_lwb = col[icolmin];
145 if (col[icolmax] > col_upb) {
146 Info(
"TMatrixTSparse",
"column index upper bound adjusted to %d",col[icolmax]);
147 col_upb = col[icolmax];
151 Allocate(row_upb-row_lwb+1,col_upb-col_lwb+1,row_lwb,col_lwb,1,nr);
158template<
class Element>
171template<
class Element>
184template<
class Element>
189 Int_t nr_nonzeros = 0;
205 for (
Int_t j = colLwb; j <= colLwb+ncols-1; j++)
206 if (
i==j) nr_nonzeros++;
207 Allocate(nrows,ncols,rowLwb,colLwb,1,nr_nonzeros);
215 Transpose(prototype);
226 Error(
"TMatrixTSparse(EMatrixCreatorOp1)",
"operation %d not yet implemented", op);
234template<
class Element>
258 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",op);
266template<
class Element>
290 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",op);
298template<
class Element>
322 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",op);
331template<
class Element>
335 if ( (nr_nonzeros > 0 && (no_rows == 0 || no_cols == 0)) ||
336 (no_rows < 0 || no_cols < 0 || nr_nonzeros < 0) )
338 Error(
"Allocate",
"no_rows=%d no_cols=%d non_zeros=%d",no_rows,no_cols,nr_nonzeros);
351 this->
fTol = std::numeric_limits<Element>::epsilon();
373template<
class Element>
381 if (arown >= this->
fNrows || arown < 0) {
382 Error(
"InsertRow",
"row %d out of matrix range",rown);
386 if (acoln >= this->
fNcols || acoln < 0) {
387 Error(
"InsertRow",
"column %d out of matrix range",coln);
391 if (acoln+nr > this->
fNcols || nr < 0) {
392 Error(
"InsertRow",
"row length %d out of range",nr);
405 Int_t lIndex = sIndex-1;
406 Int_t rIndex = sIndex-1;
411 if (icol >= acoln+nr)
break;
412 if (icol >= acoln) nslots++;
420 const Int_t ndiff = nr-nslots;
425 for (
Int_t irow = arown+1; irow < this->
fNrows+1; irow++)
430 memmove(
fElements,elements_old,(lIndex+1)*
sizeof(Element));
433 if (nelems_old > 0 && nelems_old-rIndex > 0) {
434 memmove(
fColIndex+rIndex+ndiff,colIndex_old+rIndex,(nelems_old-rIndex)*
sizeof(
Int_t));
435 memmove(
fElements+rIndex+ndiff,elements_old+rIndex,(nelems_old-rIndex)*
sizeof(Element));
445 if (colIndex_old)
delete [] (
Int_t*) colIndex_old;
446 if (elements_old)
delete [] (Element*) elements_old;
456template<
class Element>
464 if (arown >= this->
fNrows || arown < 0) {
465 Error(
"ExtractRow",
"row %d out of matrix range",rown);
469 if (acoln >= this->
fNcols || acoln < 0) {
470 Error(
"ExtractRow",
"column %d out of matrix range",coln);
474 if (acoln+nr > this->
fNcols || nr < 0) {
475 Error(
"ExtractRow",
"row length %d out of range",nr);
483 memset(
v,0,nr*
sizeof(Element));
488 if (icol < acoln || icol >= acoln+nr)
continue;
489 v[icol-acoln] = pData[
index];
497template<
class Element>
504 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
505 Error(
"AMultBt",
"A and B columns incompatible");
510 Error(
"AMultB",
"this = &a");
515 Error(
"AMultB",
"this = &b");
520 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
521 const Int_t *
const pColIndexa =
a.GetColIndexArray();
522 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
523 const Int_t *
const pColIndexb =
b.GetColIndexArray();
531 Int_t nr_nonzero_rowa = 0;
533 for (
Int_t irowa = 0; irowa <
a.GetNrows(); irowa++)
534 if (pRowIndexa[irowa] < pRowIndexa[irowa+1])
537 Int_t nr_nonzero_rowb = 0;
539 for (
Int_t irowb = 0; irowb <
b.GetNrows(); irowb++)
540 if (pRowIndexb[irowb] < pRowIndexb[irowb+1])
544 const Int_t nc = nr_nonzero_rowa*nr_nonzero_rowb;
545 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
552 for (
Int_t irowa = 0; irowa <
a.GetNrows(); irowa++) {
553 pRowIndexc[irowa+1] = pRowIndexc[irowa];
554 if (pRowIndexa[irowa] >= pRowIndexa[irowa+1])
continue;
555 for (
Int_t irowb = 0; irowb <
b.GetNrows(); irowb++) {
556 if (pRowIndexb[irowb] >= pRowIndexb[irowb+1])
continue;
557 pRowIndexc[irowa+1]++;
558 pColIndexc[ielem++] = irowb;
566 const Element *
const pDataa =
a.GetMatrixArray();
567 const Element *
const pDatab =
b.GetMatrixArray();
571 const Int_t sIndexa = pRowIndexa[irowc];
572 const Int_t eIndexa = pRowIndexa[irowc+1];
574 const Int_t sIndexb = pRowIndexb[icolc];
575 const Int_t eIndexb = pRowIndexb[icolc+1];
577 Int_t indexb = sIndexb;
578 for (
Int_t indexa = sIndexa; indexa < eIndexa && indexb < eIndexb; indexa++) {
579 const Int_t icola = pColIndexa[indexa];
580 while (indexb < eIndexb && pColIndexb[indexb] <= icola) {
581 if (icola == pColIndexb[indexb]) {
582 sum += pDataa[indexa]*pDatab[indexb];
589 pColIndexc[indexc_r] = icolc;
590 pDatac[indexc_r] =
sum;
594 pRowIndexc[irowc+1] = indexc_r;
605template<
class Element>
612 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
613 Error(
"AMultBt",
"A and B columns incompatible");
618 Error(
"AMultB",
"this = &a");
623 Error(
"AMultB",
"this = &b");
628 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
629 const Int_t *
const pColIndexa =
a.GetColIndexArray();
637 Int_t nr_nonzero_rowa = 0;
639 for (
Int_t irowa = 0; irowa <
a.GetNrows(); irowa++)
640 if (pRowIndexa[irowa] < pRowIndexa[irowa+1])
643 Int_t nr_nonzero_rowb =
b.GetNrows();
645 const Int_t nc = nr_nonzero_rowa*nr_nonzero_rowb;
646 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
653 for (
Int_t irowa = 0; irowa <
a.GetNrows(); irowa++) {
654 pRowIndexc[irowa+1] = pRowIndexc[irowa];
655 for (
Int_t irowb = 0; irowb <
b.GetNrows(); irowb++) {
656 pRowIndexc[irowa+1]++;
657 pColIndexc[ielem++] = irowb;
665 const Element *
const pDataa =
a.GetMatrixArray();
666 const Element *
const pDatab =
b.GetMatrixArray();
670 const Int_t sIndexa = pRowIndexa[irowc];
671 const Int_t eIndexa = pRowIndexa[irowc+1];
673 const Int_t off = icolc*
b.GetNcols();
675 for (
Int_t indexa = sIndexa; indexa < eIndexa; indexa++) {
676 const Int_t icola = pColIndexa[indexa];
677 sum += pDataa[indexa]*pDatab[off+icola];
680 pColIndexc[indexc_r] = icolc;
681 pDatac[indexc_r] =
sum;
685 pRowIndexc[irowc+1]= indexc_r;
696template<
class Element>
703 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
704 Error(
"AMultBt",
"A and B columns incompatible");
709 Error(
"AMultB",
"this = &a");
714 Error(
"AMultB",
"this = &b");
719 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
720 const Int_t *
const pColIndexb =
b.GetColIndexArray();
728 Int_t nr_nonzero_rowa =
a.GetNrows();
729 Int_t nr_nonzero_rowb = 0;
731 for (
Int_t irowb = 0; irowb <
b.GetNrows(); irowb++)
732 if (pRowIndexb[irowb] < pRowIndexb[irowb+1])
736 const Int_t nc = nr_nonzero_rowa*nr_nonzero_rowb;
737 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
744 for (
Int_t irowa = 0; irowa <
a.GetNrows(); irowa++) {
745 pRowIndexc[irowa+1] = pRowIndexc[irowa];
746 for (
Int_t irowb = 0; irowb <
b.GetNrows(); irowb++) {
747 if (pRowIndexb[irowb] >= pRowIndexb[irowb+1])
continue;
748 pRowIndexc[irowa+1]++;
749 pColIndexc[ielem++] = irowb;
757 const Element *
const pDataa =
a.GetMatrixArray();
758 const Element *
const pDatab =
b.GetMatrixArray();
762 const Int_t off = irowc*
a.GetNcols();
764 const Int_t sIndexb = pRowIndexb[icolc];
765 const Int_t eIndexb = pRowIndexb[icolc+1];
767 for (
Int_t indexb = sIndexb; indexb < eIndexb; indexb++) {
768 const Int_t icolb = pColIndexb[indexb];
769 sum += pDataa[off+icolb]*pDatab[indexb];
772 pColIndexc[indexc_r] = icolc;
773 pDatac[indexc_r] =
sum;
777 pRowIndexc[irowc+1] = indexc_r;
788template<
class Element>
795 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
796 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
797 Error(
"APlusB(const TMatrixTSparse &,const TMatrixTSparse &",
"matrices not compatible");
802 Error(
"APlusB",
"this = &a");
807 Error(
"APlusB",
"this = &b");
812 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
813 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
814 const Int_t *
const pColIndexa =
a.GetColIndexArray();
815 const Int_t *
const pColIndexb =
b.GetColIndexArray();
818 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
825 const Element *
const pDataa =
a.GetMatrixArray();
826 const Element *
const pDatab =
b.GetMatrixArray();
830 const Int_t sIndexa = pRowIndexa[irowc];
831 const Int_t eIndexa = pRowIndexa[irowc+1];
832 const Int_t sIndexb = pRowIndexb[irowc];
833 const Int_t eIndexb = pRowIndexb[irowc+1];
834 Int_t indexa = sIndexa;
835 Int_t indexb = sIndexb;
838 while (indexa < eIndexa && pColIndexa[indexa] <= icolc) {
839 if (icolc == pColIndexa[indexa]) {
840 sum += pDataa[indexa];
845 while (indexb < eIndexb && pColIndexb[indexb] <= icolc) {
846 if (icolc == pColIndexb[indexb]) {
847 sum += pDatab[indexb];
854 pColIndexc[indexc_r] = icolc;
855 pDatac[indexc_r] =
sum;
859 pRowIndexc[irowc+1] = indexc_r;
870template<
class Element>
877 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
878 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
879 Error(
"APlusB(const TMatrixTSparse &,const TMatrixT &",
"matrices not compatible");
884 Error(
"APlusB",
"this = &a");
889 Error(
"APlusB",
"this = &b");
895 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
902 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
903 const Int_t *
const pColIndexa =
a.GetColIndexArray();
905 const Element *
const pDataa =
a.GetMatrixArray();
906 const Element *
const pDatab =
b.GetMatrixArray();
910 const Int_t sIndexa = pRowIndexa[irowc];
911 const Int_t eIndexa = pRowIndexa[irowc+1];
913 Int_t indexa = sIndexa;
914 for (
Int_t icolc = 0; icolc < this->GetNcols(); icolc++) {
915 Element
sum = pDatab[off+icolc];
916 while (indexa < eIndexa && pColIndexa[indexa] <= icolc) {
917 if (icolc == pColIndexa[indexa]) {
918 sum += pDataa[indexa];
925 pColIndexc[indexc_r] = icolc;
926 pDatac[indexc_r] =
sum;
930 pRowIndexc[irowc+1] = indexc_r;
941template<
class Element>
948 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
949 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
950 Error(
"AMinusB(const TMatrixTSparse &,const TMatrixTSparse &",
"matrices not compatible");
955 Error(
"AMinusB",
"this = &a");
960 Error(
"AMinusB",
"this = &b");
965 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
966 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
967 const Int_t *
const pColIndexa =
a.GetColIndexArray();
968 const Int_t *
const pColIndexb =
b.GetColIndexArray();
971 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
978 const Element *
const pDataa =
a.GetMatrixArray();
979 const Element *
const pDatab =
b.GetMatrixArray();
983 const Int_t sIndexa = pRowIndexa[irowc];
984 const Int_t eIndexa = pRowIndexa[irowc+1];
985 const Int_t sIndexb = pRowIndexb[irowc];
986 const Int_t eIndexb = pRowIndexb[irowc+1];
987 Int_t indexa = sIndexa;
988 Int_t indexb = sIndexb;
991 while (indexa < eIndexa && pColIndexa[indexa] <= icolc) {
992 if (icolc == pColIndexa[indexa]) {
993 sum += pDataa[indexa];
998 while (indexb < eIndexb && pColIndexb[indexb] <= icolc) {
999 if (icolc == pColIndexb[indexb]) {
1000 sum -= pDatab[indexb];
1007 pColIndexc[indexc_r] = icolc;
1008 pDatac[indexc_r] =
sum;
1012 pRowIndexc[irowc+1] = indexc_r;
1023template<
class Element>
1030 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1031 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1032 Error(
"AMinusB(const TMatrixTSparse &,const TMatrixT &",
"matrices not compatible");
1037 Error(
"AMinusB",
"this = &a");
1042 Error(
"AMinusB",
"this = &b");
1048 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1055 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
1056 const Int_t *
const pColIndexa =
a.GetColIndexArray();
1058 const Element *
const pDataa =
a.GetMatrixArray();
1059 const Element *
const pDatab =
b.GetMatrixArray();
1063 const Int_t sIndexa = pRowIndexa[irowc];
1064 const Int_t eIndexa = pRowIndexa[irowc+1];
1066 Int_t indexa = sIndexa;
1067 for (
Int_t icolc = 0; icolc < this->GetNcols(); icolc++) {
1068 Element
sum = -pDatab[off+icolc];
1069 while (indexa < eIndexa && pColIndexa[indexa] <= icolc) {
1070 if (icolc == pColIndexa[indexa]) {
1071 sum += pDataa[indexa];
1078 pColIndexc[indexc_r] = icolc;
1079 pDatac[indexc_r] =
sum;
1083 pRowIndexc[irowc+1] = indexc_r;
1094template<
class Element>
1101 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1102 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1103 Error(
"AMinusB(const TMatrixT &,const TMatrixTSparse &",
"matrices not compatible");
1108 Error(
"AMinusB",
"this = &a");
1113 Error(
"AMinusB",
"this = &b");
1119 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1126 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
1127 const Int_t *
const pColIndexb =
b.GetColIndexArray();
1129 const Element *
const pDataa =
a.GetMatrixArray();
1130 const Element *
const pDatab =
b.GetMatrixArray();
1134 const Int_t sIndexb = pRowIndexb[irowc];
1135 const Int_t eIndexb = pRowIndexb[irowc+1];
1137 Int_t indexb = sIndexb;
1138 for (
Int_t icolc = 0; icolc < this->GetNcols(); icolc++) {
1139 Element
sum = pDataa[off+icolc];
1140 while (indexb < eIndexb && pColIndexb[indexb] <= icolc) {
1141 if (icolc == pColIndexb[indexb]) {
1142 sum -= pDatab[indexb];
1149 pColIndexc[indexc_r] = icolc;
1150 pDatac[indexc_r] =
sum;
1154 pRowIndexc[irowc+1] = indexc_r;
1164template<
class Element>
1178template<
class Element>
1183 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1196 Error(
"SetMatrixArray",
"Inconsistency between row index and its range");
1197 if (row[irowmin] < this->
fRowLwb) {
1198 Info(
"SetMatrixArray",
"row index lower bound adjusted to %d",row[irowmin]);
1202 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d",row[irowmax]);
1207 Error(
"SetMatrixArray",
"Inconsistency between column index and its range");
1208 if (col[icolmin] < this->
fColLwb) {
1209 Info(
"SetMatrixArray",
"column index lower bound adjusted to %d",col[icolmin]);
1213 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d",col[icolmax]);
1220 Int_t nr_nonzeros = 0;
1221 const Element *ep =
data;
1222 const Element *
const fp =
data+nr;
1225 if (*ep++ != 0.0) nr_nonzeros++;
1227 if (nr_nonzeros != this->
fNelems) {
1246 for (
Int_t irow = 1; irow < this->
fNrows+1; irow++) {
1247 if (ielem < nr && row[ielem] - this->
fRowLwb < irow) {
1248 while (ielem < nr) {
1249 if (
data[ielem] != 0.0) {
1255 if (ielem >= nr || row[ielem] != row[ielem-1])
1265template <
class Element>
1271 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1275 if (nrows != this->
fNrows) {
1290 if (ncols != this->
fNcols) {
1309 Error(
"SetMatrixArray",
"Inconsistency between row index and its range");
1310 if (row[irowmin] < this->
fRowLwb) {
1311 Info(
"SetMatrixArray",
"row index lower bound adjusted to %d", row[irowmin]);
1315 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d", row[irowmax]);
1320 Error(
"SetMatrixArray",
"Inconsistency between column index and its range");
1321 if (col[icolmin] < this->
fColLwb) {
1322 Info(
"SetMatrixArray",
"column index lower bound adjusted to %d", col[icolmin]);
1326 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d", col[icolmax]);
1333 Int_t nr_nonzeros = 0;
1334 const Element *ep =
data;
1335 const Element *
const fp =
data + nr;
1341 if (nr_nonzeros != this->
fNelems) {
1366 for (
Int_t irow = 1; irow < this->
fNrows + 1; irow++) {
1367 if (ielem < nr && row[ielem] - this->
fRowLwb < irow) {
1368 while (ielem < nr) {
1369 if (
data[ielem] != 0.0) {
1375 if (ielem >= nr || row[ielem] != row[ielem - 1])
1388template<
class Element>
1391 if (nelems_new != this->
fNelems) {
1402 memmove(
fElements,oDp,nr*
sizeof(Element));
1406 if (nelems_new > nr) {
1407 memset(
fElements+nr,0,(nelems_new-nr)*
sizeof(Element));
1422template<
class Element>
1428 this->GetRowLwb() != source.
GetRowLwb() || this->GetColLwb() != source.
GetColLwb()) {
1429 Error(
"SetSparseIndex",
"matrices not compatible");
1436 if (nr_nonzeros != this->
fNelems)
1445 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
1447 for (
Int_t icol = 0; icol < this->
fNcols; icol++) {
1465template<
class Element>
1472 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1473 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1474 Error(
"SetSparseIndexAB",
"source matrices not compatible");
1478 if (this->
GetNrows() !=
a.GetNrows() || this->GetNcols() !=
a.GetNcols() ||
1479 this->GetRowLwb() !=
a.GetRowLwb() || this->GetColLwb() !=
a.GetColLwb()) {
1480 Error(
"SetSparseIndexAB",
"matrix not compatible with source matrices");
1485 const Int_t *
const pRowIndexa =
a.GetRowIndexArray();
1486 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
1487 const Int_t *
const pColIndexa =
a.GetColIndexArray();
1488 const Int_t *
const pColIndexb =
b.GetColIndexArray();
1492 for (
Int_t irowc = 0; irowc <
a.GetNrows(); irowc++) {
1493 const Int_t sIndexa = pRowIndexa[irowc];
1494 const Int_t eIndexa = pRowIndexa[irowc+1];
1495 const Int_t sIndexb = pRowIndexb[irowc];
1496 const Int_t eIndexb = pRowIndexb[irowc+1];
1497 nc += eIndexa-sIndexa;
1498 Int_t indexb = sIndexb;
1499 for (
Int_t indexa = sIndexa; indexa < eIndexa; indexa++) {
1500 const Int_t icola = pColIndexa[indexa];
1501 for (; indexb < eIndexb; indexb++) {
1502 if (pColIndexb[indexb] >= icola) {
1503 if (pColIndexb[indexb] == icola)
1510 while (indexb < eIndexb) {
1511 const Int_t icola = (eIndexa > sIndexa && eIndexa > 0) ? pColIndexa[eIndexa-1] : -1;
1512 if (pColIndexb[indexb++] > icola)
1526 for (
Int_t irowc = 0; irowc <
a.GetNrows(); irowc++) {
1527 const Int_t sIndexa = pRowIndexa[irowc];
1528 const Int_t eIndexa = pRowIndexa[irowc+1];
1529 const Int_t sIndexb = pRowIndexb[irowc];
1530 const Int_t eIndexb = pRowIndexb[irowc+1];
1531 Int_t indexb = sIndexb;
1532 for (
Int_t indexa = sIndexa; indexa < eIndexa; indexa++) {
1533 const Int_t icola = pColIndexa[indexa];
1534 for (; indexb < eIndexb; indexb++) {
1535 if (pColIndexb[indexb] >= icola) {
1536 if (pColIndexb[indexb] == icola)
1540 pColIndexc[nc++] = pColIndexb[indexb];
1542 pColIndexc[nc++] = pColIndexa[indexa];
1544 while (indexb < eIndexb) {
1545 const Int_t icola = (eIndexa > 0) ? pColIndexa[eIndexa-1] : -1;
1546 if (pColIndexb[indexb++] > icola)
1547 pColIndexc[nc++] = pColIndexb[indexb-1];
1549 pRowIndexc[irowc+1] = nc;
1559template<
class Element>
1566 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1567 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1568 Error(
"SetSparseIndexAB",
"source matrices not compatible");
1572 if (this->
GetNrows() !=
a.GetNrows() || this->GetNcols() !=
a.GetNcols() ||
1573 this->GetRowLwb() !=
a.GetRowLwb() || this->GetColLwb() !=
a.GetColLwb()) {
1574 Error(
"SetSparseIndexAB",
"matrix not compatible with source matrices");
1579 const Element *
const pDataa =
a.GetMatrixArray();
1581 const Int_t *
const pRowIndexb =
b.GetRowIndexArray();
1582 const Int_t *
const pColIndexb =
b.GetColIndexArray();
1587 const Int_t sIndexb = pRowIndexb[irowc];
1588 const Int_t eIndexb = pRowIndexb[irowc+1];
1590 Int_t indexb = sIndexb;
1591 for (
Int_t icolc = 0; icolc < this->GetNcols(); icolc++) {
1592 if (pDataa[off+icolc] != 0.0 || pColIndexb[indexb] > icolc)
continue;
1593 for (; indexb < eIndexb; indexb++) {
1594 if (pColIndexb[indexb] >= icolc) {
1595 if (pColIndexb[indexb] == icolc) {
1614 for (
Int_t irowc = 0; irowc < this->GetNrows(); irowc++) {
1615 const Int_t sIndexb = pRowIndexb[irowc];
1616 const Int_t eIndexb = pRowIndexb[irowc+1];
1618 Int_t indexb = sIndexb;
1619 for (
Int_t icolc = 0; icolc < this->GetNcols(); icolc++) {
1620 if (pDataa[off+icolc] != 0.0)
1621 pColIndexc[nc++] = icolc;
1622 else if (pColIndexb[indexb] <= icolc) {
1623 for (; indexb < eIndexb; indexb++) {
1624 if (pColIndexb[indexb] >= icolc) {
1625 if (pColIndexb[indexb] == icolc)
1626 pColIndexc[nc++] = pColIndexb[indexb++];
1632 pRowIndexc[irowc+1] = nc;
1644template<
class Element>
1649 Error(
"ResizeTo(Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1655 (this->
fNelems == nr_nonzeros || nr_nonzeros < 0))
1657 else if (nrows == 0 || ncols == 0 || nr_nonzeros == 0) {
1671 if (nr_nonzeros > 0)
1672 nelems_new = nr_nonzeros;
1675 for (
Int_t irow = 0; irow < nrows_old; irow++) {
1676 if (irow >= nrows)
continue;
1677 const Int_t sIndex = rowIndex_old[irow];
1678 const Int_t eIndex = rowIndex_old[irow+1];
1687 Allocate(nrows,ncols,0,0,1,nelems_new);
1694 Int_t nelems_copy = 0;
1695 rowIndex_new[0] = 0;
1697 for (
Int_t irow = 0; irow < nrows_old && cont; irow++) {
1698 if (irow >= nrows)
continue;
1699 const Int_t sIndex = rowIndex_old[irow];
1700 const Int_t eIndex = rowIndex_old[irow+1];
1704 rowIndex_new[irow+1] = nelems_copy+1;
1705 colIndex_new[nelems_copy] = icol;
1706 elements_new[nelems_copy] = elements_old[
index];
1709 if (nelems_copy >= nelems_new) {
1716 if (rowIndex_old)
delete [] (
Int_t*) rowIndex_old;
1717 if (colIndex_old)
delete [] (
Int_t*) colIndex_old;
1718 if (elements_old)
delete [] (Element*) elements_old;
1721 for (
Int_t irow = nrowIndex_old; irow < this->fNrowIndex; irow++)
1722 rowIndex_new[irow] = rowIndex_new[nrowIndex_old-1];
1725 const Int_t nelems_new = (nr_nonzeros >= 0) ? nr_nonzeros : 0;
1726 Allocate(nrows,ncols,0,0,1,nelems_new);
1738template<
class Element>
1744 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1748 const Int_t new_nrows = row_upb-row_lwb+1;
1749 const Int_t new_ncols = col_upb-col_lwb+1;
1752 if (this->
fNrows == new_nrows && this->
fNcols == new_ncols &&
1754 (this->
fNelems == nr_nonzeros || nr_nonzeros < 0))
1756 else if (new_nrows == 0 || new_ncols == 0 || nr_nonzeros == 0) {
1774 if (nr_nonzeros > 0)
1775 nelems_new = nr_nonzeros;
1778 for (
Int_t irow = 0; irow < nrows_old; irow++) {
1779 if (irow+rowLwb_old > row_upb || irow+rowLwb_old < row_lwb)
continue;
1780 const Int_t sIndex = rowIndex_old[irow];
1781 const Int_t eIndex = rowIndex_old[irow+1];
1784 if (icol+colLwb_old <= col_upb && icol+colLwb_old >= col_lwb)
1790 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1,nelems_new);
1797 Int_t nelems_copy = 0;
1798 rowIndex_new[0] = 0;
1799 const Int_t row_off = rowLwb_old-row_lwb;
1800 const Int_t col_off = colLwb_old-col_lwb;
1801 for (
Int_t irow = 0; irow < nrows_old; irow++) {
1802 if (irow+rowLwb_old > row_upb || irow+rowLwb_old < row_lwb)
continue;
1803 const Int_t sIndex = rowIndex_old[irow];
1804 const Int_t eIndex = rowIndex_old[irow+1];
1807 if (icol+colLwb_old <= col_upb && icol+colLwb_old >= col_lwb) {
1808 rowIndex_new[irow+row_off+1] = nelems_copy+1;
1809 colIndex_new[nelems_copy] = icol+col_off;
1810 elements_new[nelems_copy] = elements_old[
index];
1813 if (nelems_copy >= nelems_new) {
1819 if (rowIndex_old)
delete [] (
Int_t*) rowIndex_old;
1820 if (colIndex_old)
delete [] (
Int_t*) colIndex_old;
1821 if (elements_old)
delete [] (Element*) elements_old;
1824 for (
Int_t irow = nrowIndex_old; irow < this->fNrowIndex; irow++)
1825 rowIndex_new[irow] = rowIndex_new[nrowIndex_old-1];
1828 const Int_t nelems_new = (nr_nonzeros >= 0) ? nr_nonzeros : 0;
1829 Allocate(new_nrows,new_ncols,row_lwb,col_lwb,1,nelems_new);
1837template<
class Element>
1842 if (row_upb < row_lwb) {
1843 Error(
"Use",
"row_upb=%d < row_lwb=%d",row_upb,row_lwb);
1846 if (col_upb < col_lwb) {
1847 Error(
"Use",
"col_upb=%d < col_lwb=%d",col_upb,col_lwb);
1854 this->
fNrows = row_upb-row_lwb+1;
1855 this->
fNcols = col_upb-col_lwb+1;
1861 this->
fTol = std::numeric_limits<Element>::epsilon();
1877template<
class Element>
1884 Error(
"GetSub",
"row_lwb out-of-bounds");
1888 Error(
"GetSub",
"col_lwb out-of-bounds");
1892 Error(
"GetSub",
"row_upb out-of-bounds");
1896 Error(
"GetSub",
"col_upb out-of-bounds");
1899 if (row_upb < row_lwb || col_upb < col_lwb) {
1900 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1909 const Int_t row_lwb_sub = (shift) ? 0 : row_lwb;
1910 const Int_t row_upb_sub = (shift) ? row_upb-row_lwb : row_upb;
1911 const Int_t col_lwb_sub = (shift) ? 0 : col_lwb;
1912 const Int_t col_upb_sub = (shift) ? col_upb-col_lwb : col_upb;
1914 Int_t nr_nonzeros = 0;
1915 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
1916 if (irow+this->
fRowLwb > row_upb || irow+this->
fRowLwb < row_lwb)
continue;
1921 if (icol+this->fColLwb <= col_upb && icol+this->
fColLwb >= col_lwb)
1926 target.ResizeTo(row_lwb_sub,row_upb_sub,col_lwb_sub,col_upb_sub,nr_nonzeros);
1932 Element *ep_sub =
target.GetMatrixArray();
1934 if (
target.GetRowIndexArray() &&
target.GetColIndexArray()) {
1935 Int_t nelems_copy = 0;
1936 rowIndex_sub[0] = 0;
1939 for (
Int_t irow = 0; irow < this->fNrows; irow++) {
1940 if (irow+this->
fRowLwb > row_upb || irow+this->
fRowLwb < row_lwb)
continue;
1945 if (icol+this->fColLwb <= col_upb && icol+this->
fColLwb >= col_lwb) {
1946 rowIndex_sub[irow+row_off+1] = nelems_copy+1;
1947 colIndex_sub[nelems_copy] = icol+col_off;
1948 ep_sub[nelems_copy] = ep[
index];
1956 const Int_t ncols_sub = col_upb_sub-col_lwb_sub+1;
1957 for (
Int_t irow = 0; irow < this->fNrows; irow++) {
1958 if (irow+this->
fRowLwb > row_upb || irow+this->
fRowLwb < row_lwb)
continue;
1961 const Int_t off = (irow+row_off)*ncols_sub;
1964 if (icol+this->fColLwb <= col_upb && icol+this->
fColLwb >= col_lwb)
1965 ep_sub[off+icol+col_off] = ep[
index];
1977template<
class Element>
1985 Error(
"SetSub",
"row_lwb out-of-bounds");
1989 Error(
"SetSub",
"col_lwb out-of-bounds");
1992 if (row_lwb+source.
GetNrows() > this->fRowLwb+this->fNrows || col_lwb+source.
GetNcols() > this->fColLwb+this->fNcols) {
1993 Error(
"SetSub",
"source matrix too large");
2003 Int_t nr_nonzeros = 0;
2004 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
2005 if (irow+this->
fRowLwb >= row_lwb+nRows_source || irow+this->
fRowLwb < row_lwb)
continue;
2010 if (icol+this->fColLwb < col_lwb+nCols_source && icol+this->
fColLwb >= col_lwb)
2024 const Int_t nelems_new = nelems_old+source.
NonZeros()-nr_nonzeros;
2038 rowIndex_new[0] = 0;
2039 for (
Int_t irow = 0; irow < this->fNrows; irow++) {
2040 rowIndex_new[irow+1] = rowIndex_new[irow];
2042 if (irow+this->fRowLwb < row_lwb+nRows_source && irow+this->
fRowLwb >= row_lwb)
2045 const Int_t sIndex_o = rowIndex_old[irow];
2046 const Int_t eIndex_o = rowIndex_old[irow+1];
2049 const Int_t icol_left = col_off-1;
2052 rowIndex_new[irow+1]++;
2053 colIndex_new[nr] = colIndex_old[
index];
2054 elements_new[nr] = elements_old[
index];
2058 if (rowIndex_s && colIndex_s) {
2059 const Int_t sIndex_s = rowIndex_s[irow-row_off];
2060 const Int_t eIndex_s = rowIndex_s[irow-row_off+1];
2062 rowIndex_new[irow+1]++;
2063 colIndex_new[nr] = colIndex_s[
index]+col_off;
2064 elements_new[nr] = elements_s[
index];
2068 const Int_t off = (irow-row_off)*nCols_source;
2069 for (
Int_t icol = 0; icol < nCols_source; icol++) {
2070 rowIndex_new[irow+1]++;
2071 colIndex_new[nr] = icol+col_off;
2072 elements_new[nr] = elements_s[off+icol];
2077 const Int_t icol_right = col_off+nCols_source-1;
2080 while (right < eIndex_o-1 && colIndex_old[right+1] <= icol_right)
2085 rowIndex_new[irow+1]++;
2086 colIndex_new[nr] = colIndex_old[
index];
2087 elements_new[nr] = elements_old[
index];
2093 rowIndex_new[irow+1]++;
2094 colIndex_new[nr] = colIndex_old[
index];
2095 elements_new[nr] = elements_old[
index];
2103 if (rowIndex_old)
delete [] (
Int_t*) rowIndex_old;
2104 if (colIndex_old)
delete [] (
Int_t*) colIndex_old;
2105 if (elements_old)
delete [] (Element*) elements_old;
2113template<
class Element>
2132 Element *pData_t =
new Element[nr_nonzeros];
2135 for (
Int_t irow_s = 0; irow_s < source.
GetNrows(); irow_s++) {
2136 const Int_t sIndex = pRowIndex_s[irow_s];
2137 const Int_t eIndex = pRowIndex_s[irow_s+1];
2140 colnr[ielem] = irow_s+this->
fColLwb;
2141 pData_t[ielem] = pData_s[
index];
2156 if (pData_t)
delete [] pData_t;
2157 if (rownr)
delete [] rownr;
2158 if (colnr)
delete [] colnr;
2165template<
class Element>
2181template<
class Element>
2188 Int_t nr_nonzeros = 0;
2191 if (
i == j) nr_nonzeros++;
2193 if (nr_nonzeros != this->
fNelems) {
2197 if (oIp)
delete [] oIp;
2200 if (oDp)
delete [] oDp;
2223template<
class Element>
2229 const Element *
const fp = ep+this->
fNelems;
2234 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
2235 const Int_t sIndex = pR[irow];
2236 const Int_t eIndex = pR[irow+1];
2252template<
class Element>
2260 const Element *
const fp = ep+this->
fNcols;
2280template<
class Element>
2287 if (arown >= this->
fNrows || arown < 0) {
2288 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->
fNrows);
2291 if (acoln >= this->
fNcols || acoln < 0) {
2292 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->
fNcols);
2316 Error(
"operator()(Int_t,Int_t",
"Insert row failed");
2324template <
class Element>
2329 Error(
"operator()(Int_t,Int_t) const",
"row/col indices are not set");
2336 if (arown >= this->
fNrows || arown < 0) {
2337 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",rown,this->fRowLwb,this->fRowLwb+this->
fNrows);
2340 if (acoln >= this->
fNcols || acoln < 0) {
2341 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",coln,this->fColLwb,this->fColLwb+this->
fNcols);
2356template<
class Element>
2360 Error(
"operator=(const TMatrixTSparse &)",
"matrices not compatible");
2369 memcpy(tp,sp,this->
fNelems*
sizeof(Element));
2379template<
class Element>
2383 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
2392 for (
Int_t irow = 0; irow < this->
fNrows; irow++) {
2398 tp[
index] = sp[off+icol];
2410template<
class Element>
2416 Error(
"operator=(Element",
"row/col indices are not set");
2421 const Element *
const ep_last = ep+this->
fNelems;
2422 while (ep < ep_last)
2431template<
class Element>
2437 const Element *
const ep_last = ep+this->
fNelems;
2438 while (ep < ep_last)
2447template<
class Element>
2453 const Element *
const ep_last = ep+this->
fNelems;
2454 while (ep < ep_last)
2463template<
class Element>
2469 const Element *
const ep_last = ep+this->
fNelems;
2470 while (ep < ep_last)
2479template<
class Element>
2484 const Element scale = beta-alpha;
2485 const Element shift = alpha/scale;
2500 for (
Int_t k = 0; k < nn; k++) {
2501 const Element
r =
Drand(seed);
2503 if ((nn-k)*
r <
length-chosen) {
2504 pColIndex[chosen] = k%
n;
2507 if (irow > icurrent) {
2508 for ( ; icurrent < irow; icurrent++)
2509 pRowIndex[icurrent+1] = chosen;
2511 ep[chosen] = scale*(
Drand(seed)+shift);
2515 for ( ; icurrent <
m; icurrent++)
2516 pRowIndex[icurrent+1] =
length;
2526template<
class Element>
2529 const Element scale = beta-alpha;
2530 const Element shift = alpha/scale;
2536 Error(
"RandomizePD(Element &",
"matrix should be square");
2552 ep[0] = 1
e-8+scale*(
Drand(seed)+shift);
2572 for (
Int_t k = 0; k < nn; k++ ) {
2573 const Element
r =
Drand(seed);
2575 if( (nn-k)*
r <
length-chosen) {
2582 Int_t col = k-row*(row+1)/2;
2587 if (row > icurrent) {
2591 for ( ; icurrent < row; icurrent++) {
2594 for (
Int_t ll = pRowIndex[icurrent]; ll < nnz; ll++)
2596 ep[nnz] += 1
e-8+scale*(
Drand(seed)+shift);
2597 pColIndex[nnz] = icurrent;
2600 pRowIndex[icurrent+1] = nnz;
2603 ep[nnz] = scale*(
Drand(seed)+shift);
2604 pColIndex[nnz] = col;
2607 ep[pRowIndex[col+1]-1] +=
TMath::Abs(ep[nnz]);
2617 for ( ; icurrent <
n; icurrent++) {
2620 for(
Int_t ll = pRowIndex[icurrent]; ll < nnz; ll++)
2622 ep[nnz] += 1
e-8+scale*(
Drand(seed)+shift);
2623 pColIndex[nnz] = icurrent;
2626 pRowIndex[icurrent+1] = nnz;
2639 for (
Int_t irow = 0; irow < this->
fNrows+1; irow++) {
2640 const Int_t sIndex = pR[irow];
2641 const Int_t eIndex = pR[irow+1];
2655template<
class Element>
2664template<
class Element>
2673template<
class Element>
2682template<
class Element>
2692template<
class Element>
2702template<
class Element>
2711template<
class Element>
2720template<
class Element>
2729template<
class Element>
2739template<
class Element>
2749template<
class Element>
2758template<
class Element>
2767template<
class Element>
2776template<
class Element>
2786template<
class Element>
2797template<
class Element>
2800 target += scalar * source;
2807template<
class Element>
2811 ::Error(
"ElementMult(TMatrixTSparse &,const TMatrixTSparse &)",
"matrices not compatible");
2816 Element *tp =
target.GetMatrixArray();
2817 const Element *ftp = tp+
target.GetNoElements();
2827template<
class Element>
2831 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2836 Element *tp =
target.GetMatrixArray();
2837 const Element *ftp = tp+
target.GetNoElements();
2838 while ( tp < ftp ) {
2842 Error(
"ElementDiv",
"source element is zero");
2852template<
class Element>
2857 ::Error(
"AreCompatible",
"matrix 1 not valid");
2862 ::Error(
"AreCompatible",
"matrix 2 not valid");
2869 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
2876 if (memcmp(pR1,pR2,(nRows+1)*
sizeof(
Int_t))) {
2878 ::Error(
"AreCompatible",
"matrices 1 and 2 have different rowIndex");
2879 for (
Int_t i = 0;
i < nRows+1;
i++)
2880 printf(
"%d: %d %d\n",
i,pR1[
i],pR2[
i]);
2886 if (memcmp(pD1,pD2,nData*
sizeof(
Int_t))) {
2888 ::Error(
"AreCompatible",
"matrices 1 and 2 have different colIndex");
2890 printf(
"%d: %d %d\n",
i,pD1[
i],pD2[
i]);
2900template<
class Element>
#define templateClassImp(name)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
TMatrixTSparse< Double_t > TMatrixDSparse
TMatrixT< Double_t > TMatrixD
TMatrixTSparse< Float_t > TMatrixFSparse
TMatrixT< Float_t > TMatrixF
R__EXTERN Int_t gMatrixCheck
TMatrixTSparse< Element > & ElementDiv(TMatrixTSparse< Element > &target, const TMatrixTSparse< Element > &source)
Divide target by the source, element-by-element.
template TMatrixFSparse & ElementDiv< Float_t >(TMatrixFSparse &target, const TMatrixFSparse &source)
template TMatrixDSparse & Add< Double_t >(TMatrixDSparse &target, Double_t scalar, const TMatrixDSparse &source)
template Bool_t AreCompatible< Float_t >(const TMatrixFSparse &m1, const TMatrixFSparse &m2, Int_t verbose)
Bool_t AreCompatible(const TMatrixTSparse< Element > &m1, const TMatrixTSparse< Element > &m2, Int_t verbose)
template TMatrixDSparse & ElementDiv< Double_t >(TMatrixDSparse &target, const TMatrixDSparse &source)
TMatrixTSparse< Element > operator*(const TMatrixTSparse< Element > &source1, const TMatrixTSparse< Element > &source2)
TMatrixTSparse< Element > operator-(const TMatrixTSparse< Element > &source1, const TMatrixTSparse< Element > &source2)
TMatrixTSparse< Element > & Add(TMatrixTSparse< Element > &target, Element scalar, const TMatrixTSparse< Element > &source)
Modify addition: target += scalar * source.
template TMatrixFSparse & ElementMult< Float_t >(TMatrixFSparse &target, const TMatrixFSparse &source)
TMatrixTSparse< Element > operator+(const TMatrixTSparse< Element > &source1, const TMatrixTSparse< Element > &source2)
template Bool_t AreCompatible< Double_t >(const TMatrixDSparse &m1, const TMatrixDSparse &m2, Int_t verbose)
TMatrixTSparse< Element > & ElementMult(TMatrixTSparse< Element > &target, const TMatrixTSparse< Element > &source)
Multiply target by the source, element-by-element.
template TMatrixDSparse & ElementMult< Double_t >(TMatrixDSparse &target, const TMatrixDSparse &source)
template TMatrixFSparse & Add< Float_t >(TMatrixFSparse &target, Float_t scalar, const TMatrixFSparse &source)
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual const Element * GetMatrixArray() const =0
virtual const Int_t * GetRowIndexArray() const =0
virtual Int_t NonZeros() const
Compute the number of elements != 0.0.
virtual const Int_t * GetColIndexArray() const =0
Int_t GetNoElements() const
static void DoubleLexSort(Int_t n, Int_t *first, Int_t *second, Element *data)
default kTRUE, when Use array kFALSE
TMatrixTBase< Element > & Randomize(Element alpha, Element beta, Double_t &seed) override
randomize matrix element values
TMatrixTBase< Double_t > & SetMatrixArray(const Double_t *data, Option_t *="") override
TMatrixTBase< Element > & GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixTBase< Element > &target, Option_t *option="S") const override
Get submatrix [row_lwb..row_upb][col_lwb..col_upb]; The indexing range of the returned matrix depends...
TMatrixTSparse< Element > & operator+=(Element val)
Add val to every element of the matrix.
TMatrixTSparse< Double_t > & SetSparseIndex(Int_t nelem_new)
TMatrixTSparse< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros, Int_t *pRowIndex, Int_t *pColIndex, Element *pData)
TMatrixTBase< Element > & InsertRow(Int_t row, Int_t col, const Element *v, Int_t n=-1) override
Insert in row rown, n elements of array v at column coln.
Element ColNorm() const override
Column matrix norm, MAX{ SUM{ |M(i,j)|, over i}, over j}.
void Streamer(TBuffer &) override
Stream an object of class TMatrixTSparse.
const Int_t * GetRowIndexArray() const override
void AMinusB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix subtraction.
TMatrixTSparse< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
void AMultBt(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix multiplication.
void GetMatrix2Array(Element *data, Option_t *="") const override
Copy matrix data to array . It is assumed that array is of size >= fNelems.
TMatrixTSparse< Element > & Transpose(const TMatrixTSparse< Element > &source)
Transpose a matrix. Set the matrix to ncols x nrows if nrows != ncols.
TMatrixTSparse< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
Int_t NonZeros() const override
Compute the number of elements != 0.0.
TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source) override
Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part [row_lwb....
void Allocate(Int_t nrows, Int_t ncols, Int_t row_lwb=0, Int_t col_lwb=0, Int_t init=0, Int_t nr_nonzeros=0)
void Clear(Option_t *="") override
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1) override
Set size of the matrix to nrows x ncols with nr_nonzeros non-zero entries if nr_nonzeros > 0 .
void APlusB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix addition.
virtual TMatrixTSparse< Element > & RandomizePD(Element alpha, Element beta, Double_t &seed)
randomize matrix element values but keep matrix symmetric positive definite
TMatrixTBase< Element > & Zero() override
Set matrix elements to zero.
TMatrixTSparse< Element > & operator=(const TMatrixT< Element > &source)
Notice that the sparsity of the matrix is NOT changed : its fRowIndex/fColIndex are used !
const Int_t * GetColIndexArray() const override
Element operator()(Int_t rown, Int_t coln) const override
void ExtractRow(Int_t row, Int_t col, Element *v, Int_t n=-1) const override
Store in array v, n matrix elements of row rown starting at column coln.
TMatrixTBase< Double_t > & UnitMatrix() override
Element RowNorm() const override
Row matrix norm, MAX{ SUM{ |M(i,j)|, over j}, over i}.
TMatrixTSparse< Element > & SetSparseIndexAB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b)
Set the row/column indices to the "sum" of matrices a and b It is checked that enough space has been ...
const Element * GetMatrixArray() const override
const Element * GetMatrixArray() const override
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
Long64_t LocMin(Long64_t n, const T *a)
Returns index of array with the minimum element.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Long64_t LocMax(Long64_t n, const T *a)
Returns index of array with the maximum element.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
void AMultBt(const Element *const ap, Int_t na, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A*B^T.
void AMultB(const Element *const ap, Int_t na, Int_t ncolsa, const Element *const bp, Int_t nb, Int_t ncolsb, Element *cp)
Elementary routine to calculate matrix multiplication A*B.
static uint64_t sum(uint64_t i)