109template<
class Element>
119template <
class Element>
132template<
class Element>
142 Error(
"TMatrixTSparse",
"Inconsistency between row index and its range");
144 Info(
"TMatrixTSparse",
"row index lower bound adjusted to %d",row[
irowmin]);
148 Info(
"TMatrixTSparse",
"row index upper bound adjusted to %d",row[
irowmax]);
153 Error(
"TMatrixTSparse",
"Inconsistency between column index and its range");
155 Info(
"TMatrixTSparse",
"column index lower bound adjusted to %d",col[
icolmin]);
159 Info(
"TMatrixTSparse",
"column index upper bound adjusted to %d",col[
icolmax]);
176template <
class Element>
182 if (
n <= 0 ||
nr < 0) {
183 Error(
"TMatrixTSparse",
"Inconsistency in row indices");
193 Error(
"TMatrixTSparse",
"Inconsistency between column index and its range");
195 Info(
"TMatrixTSparse",
"column index lower bound adjusted to %d", col[
icolmin]);
199 Info(
"TMatrixTSparse",
"column index upper bound adjusted to %d", col[
icolmax]);
205 memcpy(fElements,
data, this->fNelems *
sizeof(Element));
207 memcpy(fColIndex, col, this->fNelems *
sizeof(
Int_t));
213template<
class Element>
226template<
class Element>
239template<
class Element>
281 Error(
"TMatrixTSparse(EMatrixCreatorOp1)",
"operation %d not yet implemented",
op);
289template<
class Element>
313 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",
op);
321template<
class Element>
345 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",
op);
353template<
class Element>
377 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",
op);
386template<
class Element>
403 this->fNrowIndex = this->fNrows+1;
405 this->fIsOwner =
kTRUE;
406 this->fTol = std::numeric_limits<Element>::epsilon();
408 fRowIndex =
new Int_t[this->fNrowIndex];
410 memset(fRowIndex,0,this->fNrowIndex*
sizeof(
Int_t));
412 if (this->fNelems > 0) {
413 fElements =
new Element[this->fNelems];
414 fColIndex =
new Int_t [this->fNelems];
416 memset(fElements,0,this->fNelems*
sizeof(Element));
428template<
class Element>
433 const Int_t nr = (
n > 0) ?
n : this->fNcols;
437 Error(
"InsertRow",
"row %d out of matrix range",
rown);
442 Error(
"InsertRow",
"column %d out of matrix range",
coln);
447 Error(
"InsertRow",
"row length %d out of range",
nr);
476 this->fNelems +=
ndiff;
477 fColIndex =
new Int_t[this->fNelems];
478 fElements =
new Element[this->fNelems];
494 for (
Int_t i = 0; i <
nr; i++) {
503 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
511template<
class Element>
516 const Int_t nr = (
n > 0) ?
n : this->fNcols;
520 Error(
"ExtractRow",
"row %d out of matrix range",
rown);
525 Error(
"ExtractRow",
"column %d out of matrix range",
coln);
530 Error(
"ExtractRow",
"row length %d out of range",
nr);
540 const Element *
const pData = GetMatrixArray();
554template <
class Element>
562 if (
lhs.GetNrows() !=
rhs.GetNcols() ||
rhs.GetColLwb() !=
lhs.GetRowLwb()) {
563 Error(
"conservative_sparse_sparse_product_impl",
"lhs and rhs columns incompatible");
574 auto mask = std::unique_ptr<bool[]>(
new bool[
rows]);
575 auto values = std::unique_ptr<Element[]>(
new Element[
rows]);
576 auto indices = std::unique_ptr<Int_t[]>(
new Int_t[
rows]);
578 std::memset(
mask.get(),
false,
sizeof(
bool) *
rows);
579 std::memset(values.get(), 0,
sizeof(Element) *
rows);
580 std::memset(indices.get(), 0,
sizeof(
Int_t) *
rows);
586 const Element *
lhsVal =
lhs.GetMatrixArray();
587 const Element *
rhsVal =
rhs.GetMatrixArray();
605 std::memset(
mask.get(),
false,
sizeof(
bool) *
rows);
618 Element *
pData = this->GetMatrixArray();
652 Error(
"conservative_sparse_sparse_product_impl",
"non zeros numbers do not match");
664template<
class Element>
671 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
672 Error(
"AMultBt",
"A and B columns incompatible");
676 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
677 Error(
"AMultB",
"this = &a");
681 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
682 Error(
"AMultB",
"this = &b");
705 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
724 const Element *
const pDataa =
a.GetMatrixArray();
725 const Element *
const pDatab =
b.GetMatrixArray();
726 Element *
const pDatac = this->GetMatrixArray();
755template<
class Element>
762 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
763 Error(
"AMultBt",
"A and B columns incompatible");
767 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
768 Error(
"AMultB",
"this = &a");
772 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
773 Error(
"AMultB",
"this = &b");
796 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
816 const Element *
const pDataa =
a.GetMatrixArray();
817 const Element *
const pDatab =
b.GetMatrixArray();
818 Element *
const pDatac = this->GetMatrixArray();
847template<
class Element>
854 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
855 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
856 Error(
"APlusB(const TMatrixTSparse &,const TMatrixTSparse &",
"matrices not compatible");
860 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
861 Error(
"APlusB",
"this = &a");
865 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
866 Error(
"APlusB",
"this = &b");
877 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
878 SetSparseIndexAB(
a,
b);
884 const Element *
const pDataa =
a.GetMatrixArray();
885 const Element *
const pDatab =
b.GetMatrixArray();
886 Element *
const pDatac = this->GetMatrixArray();
929template<
class Element>
936 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
937 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
938 Error(
"APlusB(const TMatrixTSparse &,const TMatrixT &",
"matrices not compatible");
942 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
943 Error(
"APlusB",
"this = &a");
947 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
948 Error(
"APlusB",
"this = &b");
954 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
955 SetSparseIndexAB(
a,
b);
964 const Element *
const pDataa =
a.GetMatrixArray();
965 const Element *
const pDatab =
b.GetMatrixArray();
966 Element *
const pDatac = this->GetMatrixArray();
1000template<
class Element>
1007 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1008 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1009 Error(
"AMinusB(const TMatrixTSparse &,const TMatrixTSparse &",
"matrices not compatible");
1013 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1014 Error(
"AMinusB",
"this = &a");
1018 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1019 Error(
"AMinusB",
"this = &b");
1030 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1031 SetSparseIndexAB(
a,
b);
1037 const Element *
const pDataa =
a.GetMatrixArray();
1038 const Element *
const pDatab =
b.GetMatrixArray();
1039 Element *
const pDatac = this->GetMatrixArray();
1082template<
class Element>
1089 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1090 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1091 Error(
"AMinusB(const TMatrixTSparse &,const TMatrixT &",
"matrices not compatible");
1095 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1096 Error(
"AMinusB",
"this = &a");
1100 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1101 Error(
"AMinusB",
"this = &b");
1107 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1108 SetSparseIndexAB(
a,
b);
1117 const Element *
const pDataa =
a.GetMatrixArray();
1118 const Element *
const pDatab =
b.GetMatrixArray();
1119 Element *
const pDatac = this->GetMatrixArray();
1153template<
class Element>
1160 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1161 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1162 Error(
"AMinusB(const TMatrixT &,const TMatrixTSparse &",
"matrices not compatible");
1166 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1167 Error(
"AMinusB",
"this = &a");
1171 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1172 Error(
"AMinusB",
"this = &b");
1178 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1179 SetSparseIndexAB(
a,
b);
1188 const Element *
const pDataa =
a.GetMatrixArray();
1189 const Element *
const pDatab =
b.GetMatrixArray();
1190 Element *
const pDatac = this->GetMatrixArray();
1223template<
class Element>
1228 const Element *
const elem = GetMatrixArray();
1237template<
class Element>
1242 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1254 if (row[
irowmin] < this->fRowLwb|| row[
irowmax] > this->fRowLwb+this->fNrows-1) {
1255 Error(
"SetMatrixArray",
"Inconsistency between row index and its range");
1256 if (row[
irowmin] < this->fRowLwb) {
1257 Info(
"SetMatrixArray",
"row index lower bound adjusted to %d",row[
irowmin]);
1260 if (row[
irowmax] > this->fRowLwb+this->fNrows-1) {
1261 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d",row[
irowmax]);
1262 this->fNrows = row[
irowmax]-this->fRowLwb+1;
1265 if (col[
icolmin] < this->fColLwb || col[
icolmax] > this->fColLwb+this->fNcols-1) {
1266 Error(
"SetMatrixArray",
"Inconsistency between column index and its range");
1267 if (col[
icolmin] < this->fColLwb) {
1268 Info(
"SetMatrixArray",
"column index lower bound adjusted to %d",col[
icolmin]);
1271 if (col[
icolmax] > this->fColLwb+this->fNcols-1) {
1272 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d",col[
icolmax]);
1273 this->fNcols = col[
icolmax]-this->fColLwb+1;
1278 nr = ReduceSparseMatrix(
nr, row, col,
data);
1281 const Element *
ep =
data;
1282 const Element *
const fp =
data+
nr;
1288 if (fColIndex) {
delete [] fColIndex; fColIndex =
nullptr; }
1289 if (fElements) {
delete [] fElements; fElements =
nullptr; }
1291 if (this->fNelems > 0) {
1295 fColIndex =
nullptr;
1296 fElements =
nullptr;
1300 if (this->fNelems <= 0)
1330template <
class Element>
1337 while (i <
nz - 1) {
1338 if ((row[i] == row[i + 1]) && (col[i] == col[i + 1])) {
1345 row[
j] = row[
j + 1];
1346 col[
j] = col[
j + 1];
1355template <
class Element>
1361 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1365 if (
nrows != this->fNrows) {
1368 fRowIndex =
nullptr;
1370 this->fNrows =
nrows;
1371 if (this->fNrows > 0) {
1373 this->fNrowIndex =
nrows + 1;
1375 fRowIndex =
nullptr;
1376 this->fNrowIndex = 0;
1380 if (
ncols != this->fNcols) {
1381 this->fNcols =
ncols;
1384 if (this->fRowLwb != this->fColLwb) {
1385 auto tmp = this->fRowLwb;
1386 this->fRowLwb = this->fColLwb;
1387 this->fColLwb = tmp;
1398 if (row[
irowmin] < this->fRowLwb || row[
irowmax] > this->fRowLwb + this->fNrows - 1) {
1399 Error(
"SetMatrixArray",
"Inconsistency between row index and its range");
1400 if (row[
irowmin] < this->fRowLwb) {
1401 Info(
"SetMatrixArray",
"row index lower bound adjusted to %d", row[
irowmin]);
1404 if (row[
irowmax] > this->fRowLwb + this->fNrows - 1) {
1405 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d", row[
irowmax]);
1406 this->fNrows = row[
irowmax] - this->fRowLwb + 1;
1409 if (col[
icolmin] < this->fColLwb || col[
icolmax] > this->fColLwb + this->fNcols - 1) {
1410 Error(
"SetMatrixArray",
"Inconsistency between column index and its range");
1411 if (col[
icolmin] < this->fColLwb) {
1412 Info(
"SetMatrixArray",
"column index lower bound adjusted to %d", col[
icolmin]);
1415 if (col[
icolmax] > this->fColLwb + this->fNcols - 1) {
1416 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d", col[
icolmax]);
1417 this->fNcols = col[
icolmax] - this->fColLwb + 1;
1422 nr = ReduceSparseMatrix(
nr, row, col,
data);
1425 const Element *
ep =
data;
1426 const Element *
const fp =
data +
nr;
1435 fColIndex =
nullptr;
1439 fElements =
nullptr;
1442 if (this->fNelems > 0) {
1446 fColIndex =
nullptr;
1447 fElements =
nullptr;
1451 if (this->fNelems <= 0)
1479template<
class Element>
1490 Element *
oDp = fElements;
1513template<
class Element>
1518 if (this->GetNrows() !=
source.GetNrows() ||
this->GetNcols() !=
source.GetNcols() ||
1520 Error(
"SetSparseIndex",
"matrices not compatible");
1530 if (
source.GetRowIndexArray() &&
source.GetColIndexArray()) {
1534 const Element *
ep =
source.GetMatrixArray();
1546 fRowIndex[this->fNrows] =
nr;
1556template<
class Element>
1563 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1564 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1565 Error(
"SetSparseIndexAB",
"source matrices not compatible");
1569 if (this->GetNrows() !=
a.GetNrows() ||
this->GetNcols() !=
a.GetNcols() ||
1570 this->GetRowLwb() !=
a.GetRowLwb() ||
this->GetColLwb() !=
a.GetColLwb()) {
1571 Error(
"SetSparseIndexAB",
"matrix not compatible with source matrices");
1609 if (this->NonZeros() != nc)
1650template<
class Element>
1657 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1658 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1659 Error(
"SetSparseIndexAB",
"source matrices not compatible");
1663 if (this->GetNrows() !=
a.GetNrows() ||
this->GetNcols() !=
a.GetNcols() ||
1664 this->GetRowLwb() !=
a.GetRowLwb() ||
this->GetColLwb() !=
a.GetColLwb()) {
1665 Error(
"SetSparseIndexAB",
"matrix not compatible with source matrices");
1670 const Element *
const pDataa =
a.GetMatrixArray();
1697 if (this->NonZeros() != nc)
1735template<
class Element>
1739 if (!this->fIsOwner) {
1740 Error(
"ResizeTo(Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1744 if (this->fNelems > 0) {
1745 if (this->fNrows ==
nrows && this->fNcols ==
ncols &&
1829template<
class Element>
1834 if (!this->fIsOwner) {
1835 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1842 if (this->fNelems > 0) {
1928template<
class Element>
1949 this->fNrowIndex = this->fNrows+1;
1952 this->fTol = std::numeric_limits<Element>::epsilon();
1968template<
class Element>
1975 Error(
"GetSub",
"row_lwb out-of-bounds");
1979 Error(
"GetSub",
"col_lwb out-of-bounds");
1983 Error(
"GetSub",
"row_upb out-of-bounds");
1987 Error(
"GetSub",
"col_upb out-of-bounds");
1991 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
2019 const Element *
ep = this->GetMatrixArray();
2025 if (
target.GetRowIndexArray() &&
target.GetColIndexArray()) {
2068template<
class Element>
2076 Error(
"SetSub",
"row_lwb out-of-bounds");
2080 Error(
"SetSub",
"col_lwb out-of-bounds");
2084 Error(
"SetSub",
"source matrix too large");
2116 fRowIndex =
new Int_t[this->fNrowIndex];
2192 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
2204template<
class Element>
2211 if (
source.NonZeros() <= 0)
2245 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
2256template<
class Element>
2261 if (fElements) {
delete [] fElements; fElements =
nullptr; }
2262 if (fColIndex) {
delete [] fColIndex; fColIndex =
nullptr; }
2264 memset(this->GetRowIndexArray(),0,this->fNrowIndex*
sizeof(
Int_t));
2272template<
class Element>
2280 for (i = this->fRowLwb; i <= this->fRowLwb+this->fNrows-1; i++)
2281 for (
Int_t j = this->fColLwb;
j <= this->fColLwb+this->fNcols-1;
j++)
2289 Element *
oDp = fElements;
2296 for (i = this->fRowLwb; i <= this->fRowLwb+this->fNrows-1; i++) {
2297 for (
Int_t j = this->fColLwb;
j <= this->fColLwb+this->fNcols-1;
j++) {
2301 fElements[
ielem] = 1.0;
2302 fColIndex[
ielem++] =
j-this->fColLwb;
2314template<
class Element>
2319 const Element *
ep = GetMatrixArray();
2320 const Element *
const fp =
ep+this->fNelems;
2321 const Int_t *
const pR = GetRowIndexArray();
2343template<
class Element>
2350 const Element *
ep = mt.GetMatrixArray();
2351 const Element *
const fp =
ep+this->fNcols;
2358 for (
Int_t i = 0; i < this->fNrows; i++,
ep += this->fNcols)
2360 ep -= this->fNelems-1;
2371template<
class Element>
2379 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
rown,this->fRowLwb,this->fRowLwb+this->fNrows);
2380 return fElements[0];
2383 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",
coln,this->fColLwb,this->fColLwb+this->fNcols);
2384 return fElements[0];
2390 if (this->fNrowIndex > 0 && fRowIndex[this->fNrowIndex-1] != 0) {
2397 return fElements[
index];
2405 return fElements[
index];
2407 Error(
"operator()(Int_t,Int_t",
"Insert row failed");
2408 return fElements[0];
2415template <
class Element>
2419 if (this->fNrowIndex > 0 && this->fRowIndex[this->fNrowIndex-1] == 0) {
2420 Error(
"operator()(Int_t,Int_t) const",
"row/col indices are not set");
2421 Info(
"operator()",
"fNrowIndex = %d fRowIndex[fNrowIndex-1] = %d\n",this->fNrowIndex,this->fRowIndex[this->fNrowIndex-1]);
2428 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
rown,this->fRowLwb,this->fRowLwb+this->fNrows);
2432 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",
coln,this->fColLwb,this->fColLwb+this->fNcols);
2440 else return fElements[
index];
2447template<
class Element>
2451 Error(
"operator=(const TMatrixTSparse &)",
"matrices not compatible");
2455 if (this->GetMatrixArray() !=
source.GetMatrixArray()) {
2458 const Element *
const sp =
source.GetMatrixArray();
2459 Element *
const tp = this->GetMatrixArray();
2461 this->fTol =
source.GetTol();
2470template<
class Element>
2474 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
2478 if (this->GetMatrixArray() !=
source.GetMatrixArray()) {
2481 const Element *
const sp =
source.GetMatrixArray();
2482 Element *
const tp = this->GetMatrixArray();
2492 this->fTol =
source.GetTol();
2501template<
class Element>
2506 if (fRowIndex[this->fNrowIndex-1] == 0) {
2507 Error(
"operator=(Element",
"row/col indices are not set");
2511 Element *
ep = this->GetMatrixArray();
2512 const Element *
const ep_last =
ep+this->fNelems;
2522template<
class Element>
2527 Element *
ep = this->GetMatrixArray();
2528 const Element *
const ep_last =
ep+this->fNelems;
2538template<
class Element>
2543 Element *
ep = this->GetMatrixArray();
2544 const Element *
const ep_last =
ep+this->fNelems;
2554template<
class Element>
2559 Element *
ep = this->GetMatrixArray();
2560 const Element *
const ep_last =
ep+this->fNelems;
2570template<
class Element>
2575 const Element
scale = beta-alpha;
2576 const Element shift = alpha/
scale;
2580 Element *
const ep = GetMatrixArray();
2582 const Int_t m = this->GetNrows();
2583 const Int_t n = this->GetNcols();
2586 const Int_t nn = this->GetNrows()*this->GetNcols();
2587 const Int_t length = (this->GetNoElements() <=
nn) ? this->GetNoElements() :
nn;
2591 for (
Int_t k = 0; k <
nn; k++) {
2592 const Element
r =
Drand(seed);
2617template<
class Element>
2620 const Element
scale = beta-alpha;
2621 const Element shift = alpha/
scale;
2626 if (this->fNrows != this->fNcols || this->fRowLwb != this->fColLwb) {
2627 Error(
"RandomizePD(Element &",
"matrix should be square");
2632 const Int_t n = this->fNcols;
2636 Element *
const ep = GetMatrixArray();
2663 for (
Int_t k = 0; k <
nn; k++ ) {
2664 const Element
r =
Drand(seed);
2673 Int_t col = k-row*(row+1)/2;
2719 this->fNelems =
nnz;
2727 const Int_t *
const pR = this->GetRowIndexArray();
2728 const Int_t *
const pC = this->GetColIndexArray();
2729 Element *
const pD = GetMatrixArray();
2746template<
class Element>
2755template<
class Element>
2764template<
class Element>
2773template<
class Element>
2783template<
class Element>
2793template<
class Element>
2802template<
class Element>
2811template<
class Element>
2820template<
class Element>
2830template<
class Element>
2840template<
class Element>
2849template<
class Element>
2858template<
class Element>
2867template<
class Element>
2877template<
class Element>
2888template<
class Element>
2898template<
class Element>
2902 ::Error(
"ElementMult(TMatrixTSparse &,const TMatrixTSparse &)",
"matrices not compatible");
2906 const Element *
sp =
source.GetMatrixArray();
2907 Element *
tp =
target.GetMatrixArray();
2918template<
class Element>
2922 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2926 const Element *
sp =
source.GetMatrixArray();
2927 Element *
tp =
target.GetMatrixArray();
2929 while (
tp <
ftp ) {
2933 Error(
"ElementDiv",
"source element is zero");
2943template<
class Element>
2946 if (!m1.IsValid()) {
2948 ::Error(
"AreCompatible",
"matrix 1 not valid");
2951 if (!m2.IsValid()) {
2953 ::Error(
"AreCompatible",
"matrix 2 not valid");
2957 if (m1.GetNrows() != m2.GetNrows() || m1.GetNcols() != m2.GetNcols() ||
2958 m1.GetRowLwb() != m2.GetRowLwb() || m1.GetColLwb() != m2.GetColLwb()) {
2960 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
2964 const Int_t *
pR1 = m1.GetRowIndexArray();
2965 const Int_t *
pR2 = m2.GetRowIndexArray();
2969 ::Error(
"AreCompatible",
"matrices 1 and 2 have different rowIndex");
2974 const Int_t *
pD1 = m1.GetColIndexArray();
2975 const Int_t *
pD2 = m2.GetColIndexArray();
2976 const Int_t nData = m1.GetNoElements();
2979 ::Error(
"AreCompatible",
"matrices 1 and 2 have different colIndex");
2980 for (
Int_t i = 0; i < nData; i++)
2991template<
class Element>
2994 if (
R__b.IsReading()) {
2999 if (this->fNelems < 0)
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
short Version_t
Class version identifier (short)
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
#define templateClassImp(name)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
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.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t 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
R__EXTERN Int_t gMatrixCheck
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)
template TMatrixDSparse & ElementDiv< Double_t >(TMatrixDSparse &target, const TMatrixDSparse &source)
template TMatrixFSparse & ElementMult< Float_t >(TMatrixFSparse &target, const TMatrixFSparse &source)
template Bool_t AreCompatible< Double_t >(const TMatrixDSparse &m1, const TMatrixDSparse &m2, Int_t verbose)
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.
TTime operator*(const TTime &t1, const TTime &t2)
TTime operator-(const TTime &t1, const TTime &t2)
Buffer base class used for serializing objects.
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< Element > & SetMatrixArray(const Element *data, Option_t *="") override
Copy array data to matrix .
Int_t ReduceSparseMatrix(Int_t nr, Int_t *row, Int_t *col, Element *data)
Sum matrix entries corresponding to the same matrix element (i,j).
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< Element > & SetSparseIndex(Int_t nelem_new)
Increase/decrease the number of non-zero elements to nelems_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.
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)
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.
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)
Allocate new matrix.
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 !
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< Element > & UnitMatrix() override
Make a unit matrix (matrix need not be a square one).
void conservative_sparse_sparse_product_impl(const TMatrixTSparse< Element > &lhs, const TMatrixTSparse< Element > &rhs, Int_t constr=0)
General Sparse Matrix Multiplication (SpMM).
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 ...
TObject & operator=(const TObject &rhs) noexcept
TObject assignment operator.
void ToUpper()
Change string to upper case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RPY_EXPORTED TCppObject_t Allocate(TCppType_t type)
ELogLevel operator+(ELogLevel severity, int offset)
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.
TMatrixT< Element > & ElementMult(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Multiply target by the source, element-by-element.
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
TMatrixT< Element > & ElementDiv(TMatrixT< Element > &target, const TMatrixT< Element > &source)
Divide target by the source, element-by-element.
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 .
static uint64_t sum(uint64_t i)