108template<
class Element>
118template <
class Element>
131template<
class Element>
141 Error(
"TMatrixTSparse",
"Inconsistency between row index and its range");
143 Info(
"TMatrixTSparse",
"row index lower bound adjusted to %d",row[
irowmin]);
147 Info(
"TMatrixTSparse",
"row index upper bound adjusted to %d",row[
irowmax]);
152 Error(
"TMatrixTSparse",
"Inconsistency between column index and its range");
154 Info(
"TMatrixTSparse",
"column index lower bound adjusted to %d",col[
icolmin]);
158 Info(
"TMatrixTSparse",
"column index upper bound adjusted to %d",col[
icolmax]);
165 SetMatrixArray(
nr,row,col,
data);
175template <
class Element>
181 if (
n <= 0 ||
nr < 0) {
182 Error(
"TMatrixTSparse",
"Inconsistency in row indices");
192 Error(
"TMatrixTSparse",
"Inconsistency between column index and its range");
194 Info(
"TMatrixTSparse",
"column index lower bound adjusted to %d", col[
icolmin]);
198 Info(
"TMatrixTSparse",
"column index upper bound adjusted to %d", col[
icolmax]);
204 memcpy(fElements,
data, this->fNelems *
sizeof(Element));
206 memcpy(fColIndex, col, this->fNelems *
sizeof(
Int_t));
212template<
class Element>
225template<
class Element>
238template<
class Element>
280 Error(
"TMatrixTSparse(EMatrixCreatorOp1)",
"operation %d not yet implemented",
op);
288template<
class Element>
312 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",
op);
320template<
class Element>
344 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",
op);
352template<
class Element>
376 Error(
"TMatrixTSparse(EMatrixCreatorOp2)",
"operation %d not yet implemented",
op);
385template<
class Element>
402 this->fNrowIndex = this->fNrows+1;
404 this->fIsOwner =
kTRUE;
405 this->fTol = std::numeric_limits<Element>::epsilon();
407 fRowIndex =
new Int_t[this->fNrowIndex];
409 memset(fRowIndex,0,this->fNrowIndex*
sizeof(
Int_t));
411 if (this->fNelems > 0) {
412 fElements =
new Element[this->fNelems];
413 fColIndex =
new Int_t [this->fNelems];
415 memset(fElements,0,this->fNelems*
sizeof(Element));
427template<
class Element>
432 const Int_t nr = (
n > 0) ?
n : this->fNcols;
436 Error(
"InsertRow",
"row %d out of matrix range",
rown);
441 Error(
"InsertRow",
"column %d out of matrix range",
coln);
446 Error(
"InsertRow",
"row length %d out of range",
nr);
475 this->fNelems +=
ndiff;
476 fColIndex =
new Int_t[this->fNelems];
477 fElements =
new Element[this->fNelems];
493 for (
Int_t i = 0; i <
nr; i++) {
502 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
510template<
class Element>
515 const Int_t nr = (
n > 0) ?
n : this->fNcols;
519 Error(
"ExtractRow",
"row %d out of matrix range",
rown);
524 Error(
"ExtractRow",
"column %d out of matrix range",
coln);
529 Error(
"ExtractRow",
"row length %d out of range",
nr);
539 const Element *
const pData = GetMatrixArray();
553template <
class Element>
561 if (
lhs.GetNrows() !=
rhs.GetNcols() ||
rhs.GetColLwb() !=
lhs.GetRowLwb()) {
562 Error(
"conservative_sparse_sparse_product_impl",
"lhs and rhs columns incompatible");
573 auto mask = std::unique_ptr<bool[]>(
new bool[
rows]);
574 auto values = std::unique_ptr<Element[]>(
new Element[
rows]);
575 auto indices = std::unique_ptr<Int_t[]>(
new Int_t[
rows]);
577 std::memset(
mask.get(),
false,
sizeof(
bool) *
rows);
578 std::memset(values.get(), 0,
sizeof(Element) *
rows);
579 std::memset(indices.get(), 0,
sizeof(
Int_t) *
rows);
585 const Element *
lhsVal =
lhs.GetMatrixArray();
586 const Element *
rhsVal =
rhs.GetMatrixArray();
604 std::memset(
mask.get(),
false,
sizeof(
bool) *
rows);
617 Element *
pData = this->GetMatrixArray();
651 Error(
"conservative_sparse_sparse_product_impl",
"non zeros numbers do not match");
663template<
class Element>
670 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
671 Error(
"AMultBt",
"A and B columns incompatible");
675 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
676 Error(
"AMultB",
"this = &a");
680 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
681 Error(
"AMultB",
"this = &b");
704 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
723 const Element *
const pDataa =
a.GetMatrixArray();
724 const Element *
const pDatab =
b.GetMatrixArray();
725 Element *
const pDatac = this->GetMatrixArray();
754template<
class Element>
761 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
762 Error(
"AMultBt",
"A and B columns incompatible");
766 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
767 Error(
"AMultB",
"this = &a");
771 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
772 Error(
"AMultB",
"this = &b");
795 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
815 const Element *
const pDataa =
a.GetMatrixArray();
816 const Element *
const pDatab =
b.GetMatrixArray();
817 Element *
const pDatac = this->GetMatrixArray();
846template<
class Element>
853 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
854 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
855 Error(
"APlusB(const TMatrixTSparse &,const TMatrixTSparse &",
"matrices not compatible");
859 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
860 Error(
"APlusB",
"this = &a");
864 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
865 Error(
"APlusB",
"this = &b");
876 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
877 SetSparseIndexAB(
a,
b);
883 const Element *
const pDataa =
a.GetMatrixArray();
884 const Element *
const pDatab =
b.GetMatrixArray();
885 Element *
const pDatac = this->GetMatrixArray();
928template<
class Element>
935 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
936 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
937 Error(
"APlusB(const TMatrixTSparse &,const TMatrixT &",
"matrices not compatible");
941 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
942 Error(
"APlusB",
"this = &a");
946 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
947 Error(
"APlusB",
"this = &b");
953 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
954 SetSparseIndexAB(
a,
b);
963 const Element *
const pDataa =
a.GetMatrixArray();
964 const Element *
const pDatab =
b.GetMatrixArray();
965 Element *
const pDatac = this->GetMatrixArray();
999template<
class Element>
1006 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1007 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1008 Error(
"AMinusB(const TMatrixTSparse &,const TMatrixTSparse &",
"matrices not compatible");
1012 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1013 Error(
"AMinusB",
"this = &a");
1017 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1018 Error(
"AMinusB",
"this = &b");
1029 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1030 SetSparseIndexAB(
a,
b);
1036 const Element *
const pDataa =
a.GetMatrixArray();
1037 const Element *
const pDatab =
b.GetMatrixArray();
1038 Element *
const pDatac = this->GetMatrixArray();
1081template<
class Element>
1088 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1089 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1090 Error(
"AMinusB(const TMatrixTSparse &,const TMatrixT &",
"matrices not compatible");
1094 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1095 Error(
"AMinusB",
"this = &a");
1099 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1100 Error(
"AMinusB",
"this = &b");
1106 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1107 SetSparseIndexAB(
a,
b);
1116 const Element *
const pDataa =
a.GetMatrixArray();
1117 const Element *
const pDatab =
b.GetMatrixArray();
1118 Element *
const pDatac = this->GetMatrixArray();
1152template<
class Element>
1159 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1160 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1161 Error(
"AMinusB(const TMatrixT &,const TMatrixTSparse &",
"matrices not compatible");
1165 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1166 Error(
"AMinusB",
"this = &a");
1170 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1171 Error(
"AMinusB",
"this = &b");
1177 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1178 SetSparseIndexAB(
a,
b);
1187 const Element *
const pDataa =
a.GetMatrixArray();
1188 const Element *
const pDatab =
b.GetMatrixArray();
1189 Element *
const pDatac = this->GetMatrixArray();
1222template<
class Element>
1227 const Element *
const elem = GetMatrixArray();
1236template<
class Element>
1241 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1253 if (row[
irowmin] < this->fRowLwb|| row[
irowmax] > this->fRowLwb+this->fNrows-1) {
1254 Error(
"SetMatrixArray",
"Inconsistency between row index and its range");
1255 if (row[
irowmin] < this->fRowLwb) {
1256 Info(
"SetMatrixArray",
"row index lower bound adjusted to %d",row[
irowmin]);
1259 if (row[
irowmax] > this->fRowLwb+this->fNrows-1) {
1260 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d",row[
irowmax]);
1261 this->fNrows = row[
irowmax]-this->fRowLwb+1;
1264 if (col[
icolmin] < this->fColLwb || col[
icolmax] > this->fColLwb+this->fNcols-1) {
1265 Error(
"SetMatrixArray",
"Inconsistency between column index and its range");
1266 if (col[
icolmin] < this->fColLwb) {
1267 Info(
"SetMatrixArray",
"column index lower bound adjusted to %d",col[
icolmin]);
1270 if (col[
icolmax] > this->fColLwb+this->fNcols-1) {
1271 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d",col[
icolmax]);
1272 this->fNcols = col[
icolmax]-this->fColLwb+1;
1277 nr = ReduceSparseMatrix(
nr, row, col,
data);
1280 const Element *
ep =
data;
1281 const Element *
const fp =
data+
nr;
1287 if (fColIndex) {
delete [] fColIndex; fColIndex =
nullptr; }
1288 if (fElements) {
delete [] fElements; fElements =
nullptr; }
1290 if (this->fNelems > 0) {
1294 fColIndex =
nullptr;
1295 fElements =
nullptr;
1299 if (this->fNelems <= 0)
1329template <
class Element>
1336 while (i <
nz - 1) {
1337 if ((row[i] == row[i + 1]) && (col[i] == col[i + 1])) {
1344 row[
j] = row[
j + 1];
1345 col[
j] = col[
j + 1];
1354template <
class Element>
1360 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1364 if (
nrows != this->fNrows) {
1367 fRowIndex =
nullptr;
1369 this->fNrows =
nrows;
1370 if (this->fNrows > 0) {
1372 this->fNrowIndex =
nrows + 1;
1374 fRowIndex =
nullptr;
1375 this->fNrowIndex = 0;
1379 if (
ncols != this->fNcols) {
1380 this->fNcols =
ncols;
1383 if (this->fRowLwb != this->fColLwb) {
1384 auto tmp = this->fRowLwb;
1385 this->fRowLwb = this->fColLwb;
1386 this->fColLwb = tmp;
1397 if (row[
irowmin] < this->fRowLwb || row[
irowmax] > this->fRowLwb + this->fNrows - 1) {
1398 Error(
"SetMatrixArray",
"Inconsistency between row index and its range");
1399 if (row[
irowmin] < this->fRowLwb) {
1400 Info(
"SetMatrixArray",
"row index lower bound adjusted to %d", row[
irowmin]);
1403 if (row[
irowmax] > this->fRowLwb + this->fNrows - 1) {
1404 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d", row[
irowmax]);
1405 this->fNrows = row[
irowmax] - this->fRowLwb + 1;
1408 if (col[
icolmin] < this->fColLwb || col[
icolmax] > this->fColLwb + this->fNcols - 1) {
1409 Error(
"SetMatrixArray",
"Inconsistency between column index and its range");
1410 if (col[
icolmin] < this->fColLwb) {
1411 Info(
"SetMatrixArray",
"column index lower bound adjusted to %d", col[
icolmin]);
1414 if (col[
icolmax] > this->fColLwb + this->fNcols - 1) {
1415 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d", col[
icolmax]);
1416 this->fNcols = col[
icolmax] - this->fColLwb + 1;
1421 nr = ReduceSparseMatrix(
nr, row, col,
data);
1424 const Element *
ep =
data;
1425 const Element *
const fp =
data +
nr;
1434 fColIndex =
nullptr;
1438 fElements =
nullptr;
1441 if (this->fNelems > 0) {
1445 fColIndex =
nullptr;
1446 fElements =
nullptr;
1450 if (this->fNelems <= 0)
1478template<
class Element>
1489 Element *
oDp = fElements;
1512template<
class Element>
1517 if (this->GetNrows() !=
source.GetNrows() ||
this->GetNcols() !=
source.GetNcols() ||
1519 Error(
"SetSparseIndex",
"matrices not compatible");
1529 if (
source.GetRowIndexArray() &&
source.GetColIndexArray()) {
1533 const Element *
ep =
source.GetMatrixArray();
1545 fRowIndex[this->fNrows] =
nr;
1555template<
class Element>
1562 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1563 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1564 Error(
"SetSparseIndexAB",
"source matrices not compatible");
1568 if (this->GetNrows() !=
a.GetNrows() ||
this->GetNcols() !=
a.GetNcols() ||
1569 this->GetRowLwb() !=
a.GetRowLwb() ||
this->GetColLwb() !=
a.GetColLwb()) {
1570 Error(
"SetSparseIndexAB",
"matrix not compatible with source matrices");
1608 if (this->NonZeros() != nc)
1649template<
class Element>
1656 if (
a.GetNrows() !=
b.GetNrows() ||
a.GetNcols() !=
b.GetNcols() ||
1657 a.GetRowLwb() !=
b.GetRowLwb() ||
a.GetColLwb() !=
b.GetColLwb()) {
1658 Error(
"SetSparseIndexAB",
"source matrices not compatible");
1662 if (this->GetNrows() !=
a.GetNrows() ||
this->GetNcols() !=
a.GetNcols() ||
1663 this->GetRowLwb() !=
a.GetRowLwb() ||
this->GetColLwb() !=
a.GetColLwb()) {
1664 Error(
"SetSparseIndexAB",
"matrix not compatible with source matrices");
1669 const Element *
const pDataa =
a.GetMatrixArray();
1696 if (this->NonZeros() != nc)
1734template<
class Element>
1738 if (!this->fIsOwner) {
1739 Error(
"ResizeTo(Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1743 if (this->fNelems > 0) {
1744 if (this->fNrows ==
nrows && this->fNcols ==
ncols &&
1828template<
class Element>
1833 if (!this->fIsOwner) {
1834 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1841 if (this->fNelems > 0) {
1927template<
class Element>
1948 this->fNrowIndex = this->fNrows+1;
1951 this->fTol = std::numeric_limits<Element>::epsilon();
1967template<
class Element>
1974 Error(
"GetSub",
"row_lwb out-of-bounds");
1978 Error(
"GetSub",
"col_lwb out-of-bounds");
1982 Error(
"GetSub",
"row_upb out-of-bounds");
1986 Error(
"GetSub",
"col_upb out-of-bounds");
1990 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
2018 const Element *
ep = this->GetMatrixArray();
2024 if (
target.GetRowIndexArray() &&
target.GetColIndexArray()) {
2067template<
class Element>
2075 Error(
"SetSub",
"row_lwb out-of-bounds");
2079 Error(
"SetSub",
"col_lwb out-of-bounds");
2083 Error(
"SetSub",
"source matrix too large");
2115 fRowIndex =
new Int_t[this->fNrowIndex];
2191 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
2203template<
class Element>
2210 if (
source.NonZeros() <= 0)
2244 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
2255template<
class Element>
2260 if (fElements) {
delete [] fElements; fElements =
nullptr; }
2261 if (fColIndex) {
delete [] fColIndex; fColIndex =
nullptr; }
2263 memset(this->GetRowIndexArray(),0,this->fNrowIndex*
sizeof(
Int_t));
2271template<
class Element>
2279 for (i = this->fRowLwb; i <= this->fRowLwb+this->fNrows-1; i++)
2280 for (
Int_t j = this->fColLwb;
j <= this->fColLwb+this->fNcols-1;
j++)
2288 Element *
oDp = fElements;
2295 for (i = this->fRowLwb; i <= this->fRowLwb+this->fNrows-1; i++) {
2296 for (
Int_t j = this->fColLwb;
j <= this->fColLwb+this->fNcols-1;
j++) {
2300 fElements[
ielem] = 1.0;
2301 fColIndex[
ielem++] =
j-this->fColLwb;
2313template<
class Element>
2318 const Element *
ep = GetMatrixArray();
2319 const Element *
const fp =
ep+this->fNelems;
2320 const Int_t *
const pR = GetRowIndexArray();
2342template<
class Element>
2349 const Element *
ep = mt.GetMatrixArray();
2350 const Element *
const fp =
ep+this->fNcols;
2357 for (
Int_t i = 0; i < this->fNrows; i++,
ep += this->fNcols)
2359 ep -= this->fNelems-1;
2370template<
class Element>
2378 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
rown,this->fRowLwb,this->fRowLwb+this->fNrows);
2379 return fElements[0];
2382 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",
coln,this->fColLwb,this->fColLwb+this->fNcols);
2383 return fElements[0];
2389 if (this->fNrowIndex > 0 && fRowIndex[this->fNrowIndex-1] != 0) {
2396 return fElements[
index];
2404 return fElements[
index];
2406 Error(
"operator()(Int_t,Int_t",
"Insert row failed");
2407 return fElements[0];
2414template <
class Element>
2418 if (this->fNrowIndex > 0 && this->fRowIndex[this->fNrowIndex-1] == 0) {
2419 Error(
"operator()(Int_t,Int_t) const",
"row/col indices are not set");
2420 Info(
"operator()",
"fNrowIndex = %d fRowIndex[fNrowIndex-1] = %d\n",this->fNrowIndex,this->fRowIndex[this->fNrowIndex-1]);
2427 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
rown,this->fRowLwb,this->fRowLwb+this->fNrows);
2431 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",
coln,this->fColLwb,this->fColLwb+this->fNcols);
2439 else return fElements[
index];
2446template<
class Element>
2450 Error(
"operator=(const TMatrixTSparse &)",
"matrices not compatible");
2454 if (this->GetMatrixArray() !=
source.GetMatrixArray()) {
2457 const Element *
const sp =
source.GetMatrixArray();
2458 Element *
const tp = this->GetMatrixArray();
2460 this->fTol =
source.GetTol();
2469template<
class Element>
2473 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
2477 if (this->GetMatrixArray() !=
source.GetMatrixArray()) {
2480 const Element *
const sp =
source.GetMatrixArray();
2481 Element *
const tp = this->GetMatrixArray();
2491 this->fTol =
source.GetTol();
2500template<
class Element>
2505 if (fRowIndex[this->fNrowIndex-1] == 0) {
2506 Error(
"operator=(Element",
"row/col indices are not set");
2510 Element *
ep = this->GetMatrixArray();
2511 const Element *
const ep_last =
ep+this->fNelems;
2521template<
class Element>
2526 Element *
ep = this->GetMatrixArray();
2527 const Element *
const ep_last =
ep+this->fNelems;
2537template<
class Element>
2542 Element *
ep = this->GetMatrixArray();
2543 const Element *
const ep_last =
ep+this->fNelems;
2553template<
class Element>
2558 Element *
ep = this->GetMatrixArray();
2559 const Element *
const ep_last =
ep+this->fNelems;
2569template<
class Element>
2574 const Element
scale = beta-alpha;
2575 const Element shift = alpha/
scale;
2579 Element *
const ep = GetMatrixArray();
2581 const Int_t m = this->GetNrows();
2582 const Int_t n = this->GetNcols();
2585 const Int_t nn = this->GetNrows()*this->GetNcols();
2586 const Int_t length = (this->GetNoElements() <=
nn) ? this->GetNoElements() :
nn;
2590 for (
Int_t k = 0; k <
nn; k++) {
2591 const Element
r =
Drand(seed);
2616template<
class Element>
2619 const Element
scale = beta-alpha;
2620 const Element shift = alpha/
scale;
2625 if (this->fNrows != this->fNcols || this->fRowLwb != this->fColLwb) {
2626 Error(
"RandomizePD(Element &",
"matrix should be square");
2631 const Int_t n = this->fNcols;
2635 Element *
const ep = GetMatrixArray();
2662 for (
Int_t k = 0; k <
nn; k++ ) {
2663 const Element
r =
Drand(seed);
2672 Int_t col = k-row*(row+1)/2;
2718 this->fNelems =
nnz;
2726 const Int_t *
const pR = this->GetRowIndexArray();
2727 const Int_t *
const pC = this->GetColIndexArray();
2728 Element *
const pD = GetMatrixArray();
2745template<
class Element>
2754template<
class Element>
2763template<
class Element>
2772template<
class Element>
2782template<
class Element>
2792template<
class Element>
2801template<
class Element>
2810template<
class Element>
2819template<
class Element>
2829template<
class Element>
2839template<
class Element>
2848template<
class Element>
2857template<
class Element>
2866template<
class Element>
2876template<
class Element>
2887template<
class Element>
2897template<
class Element>
2901 ::Error(
"ElementMult(TMatrixTSparse &,const TMatrixTSparse &)",
"matrices not compatible");
2905 const Element *
sp =
source.GetMatrixArray();
2906 Element *
tp =
target.GetMatrixArray();
2917template<
class Element>
2921 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2925 const Element *
sp =
source.GetMatrixArray();
2926 Element *
tp =
target.GetMatrixArray();
2928 while (
tp <
ftp ) {
2932 Error(
"ElementDiv",
"source element is zero");
2942template<
class Element>
2945 if (!m1.IsValid()) {
2947 ::Error(
"AreCompatible",
"matrix 1 not valid");
2950 if (!m2.IsValid()) {
2952 ::Error(
"AreCompatible",
"matrix 2 not valid");
2956 if (m1.GetNrows() != m2.GetNrows() || m1.GetNcols() != m2.GetNcols() ||
2957 m1.GetRowLwb() != m2.GetRowLwb() || m1.GetColLwb() != m2.GetColLwb()) {
2959 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
2963 const Int_t *
pR1 = m1.GetRowIndexArray();
2964 const Int_t *
pR2 = m2.GetRowIndexArray();
2968 ::Error(
"AreCompatible",
"matrices 1 and 2 have different rowIndex");
2973 const Int_t *
pD1 = m1.GetColIndexArray();
2974 const Int_t *
pD2 = m2.GetColIndexArray();
2975 const Int_t nData = m1.GetNoElements();
2978 ::Error(
"AreCompatible",
"matrices 1 and 2 have different colIndex");
2979 for (
Int_t i = 0; i < nData; i++)
2990template<
class Element>
2993 if (
R__b.IsReading()) {
2998 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)
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
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)