99template<
class Element>
109template<
class Element>
119template<
class Element>
129 Error(
"TMatrixTSparse",
"Inconsistency between row index and its range");
131 Info(
"TMatrixTSparse",
"row index lower bound adjusted to %d",row[
irowmin]);
135 Info(
"TMatrixTSparse",
"row index upper bound adjusted to %d",row[
irowmax]);
140 Error(
"TMatrixTSparse",
"Inconsistency between column index and its range");
142 Info(
"TMatrixTSparse",
"column index lower bound adjusted to %d",col[
icolmin]);
146 Info(
"TMatrixTSparse",
"column index upper bound adjusted to %d",col[
icolmax]);
153 SetMatrixArray(
nr,row,col,
data);
158template<
class Element>
171template<
class Element>
184template<
class Element>
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>
348 this->fNrowIndex = this->fNrows+1;
350 this->fIsOwner =
kTRUE;
351 this->fTol = std::numeric_limits<Element>::epsilon();
353 fRowIndex =
new Int_t[this->fNrowIndex];
355 memset(fRowIndex,0,this->fNrowIndex*
sizeof(
Int_t));
357 if (this->fNelems > 0) {
358 fElements =
new Element[this->fNelems];
359 fColIndex =
new Int_t [this->fNelems];
361 memset(fElements,0,this->fNelems*
sizeof(Element));
373template<
class Element>
378 const Int_t nr = (
n > 0) ?
n : this->fNcols;
382 Error(
"InsertRow",
"row %d out of matrix range",
rown);
387 Error(
"InsertRow",
"column %d out of matrix range",
coln);
392 Error(
"InsertRow",
"row length %d out of range",
nr);
421 this->fNelems +=
ndiff;
422 fColIndex =
new Int_t[this->fNelems];
423 fElements =
new Element[this->fNelems];
439 for (
Int_t i = 0; i <
nr; i++) {
448 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
456template<
class Element>
461 const Int_t nr = (
n > 0) ?
n : this->fNcols;
465 Error(
"ExtractRow",
"row %d out of matrix range",
rown);
470 Error(
"ExtractRow",
"column %d out of matrix range",
coln);
475 Error(
"ExtractRow",
"row length %d out of range",
nr);
485 const Element *
const pData = GetMatrixArray();
497template<
class Element>
504 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
505 Error(
"AMultBt",
"A and B columns incompatible");
509 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
510 Error(
"AMultB",
"this = &a");
514 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
515 Error(
"AMultB",
"this = &b");
545 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
566 const Element *
const pDataa =
a.GetMatrixArray();
567 const Element *
const pDatab =
b.GetMatrixArray();
568 Element *
const pDatac = this->GetMatrixArray();
605template<
class Element>
612 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
613 Error(
"AMultBt",
"A and B columns incompatible");
617 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
618 Error(
"AMultB",
"this = &a");
622 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
623 Error(
"AMultB",
"this = &b");
646 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
665 const Element *
const pDataa =
a.GetMatrixArray();
666 const Element *
const pDatab =
b.GetMatrixArray();
667 Element *
const pDatac = this->GetMatrixArray();
696template<
class Element>
703 if (
a.GetNcols() !=
b.GetNcols() ||
a.GetColLwb() !=
b.GetColLwb()) {
704 Error(
"AMultBt",
"A and B columns incompatible");
708 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
709 Error(
"AMultB",
"this = &a");
713 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
714 Error(
"AMultB",
"this = &b");
737 Allocate(
a.GetNrows(),
b.GetNrows(),
a.GetRowLwb(),
b.GetRowLwb(),1,nc);
757 const Element *
const pDataa =
a.GetMatrixArray();
758 const Element *
const pDatab =
b.GetMatrixArray();
759 Element *
const pDatac = this->GetMatrixArray();
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");
801 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
802 Error(
"APlusB",
"this = &a");
806 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
807 Error(
"APlusB",
"this = &b");
818 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
819 SetSparseIndexAB(
a,
b);
825 const Element *
const pDataa =
a.GetMatrixArray();
826 const Element *
const pDatab =
b.GetMatrixArray();
827 Element *
const pDatac = this->GetMatrixArray();
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");
883 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
884 Error(
"APlusB",
"this = &a");
888 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
889 Error(
"APlusB",
"this = &b");
895 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
896 SetSparseIndexAB(
a,
b);
905 const Element *
const pDataa =
a.GetMatrixArray();
906 const Element *
const pDatab =
b.GetMatrixArray();
907 Element *
const pDatac = this->GetMatrixArray();
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");
954 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
955 Error(
"AMinusB",
"this = &a");
959 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
960 Error(
"AMinusB",
"this = &b");
971 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
972 SetSparseIndexAB(
a,
b);
978 const Element *
const pDataa =
a.GetMatrixArray();
979 const Element *
const pDatab =
b.GetMatrixArray();
980 Element *
const pDatac = this->GetMatrixArray();
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");
1036 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1037 Error(
"AMinusB",
"this = &a");
1041 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1042 Error(
"AMinusB",
"this = &b");
1048 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1049 SetSparseIndexAB(
a,
b);
1058 const Element *
const pDataa =
a.GetMatrixArray();
1059 const Element *
const pDatab =
b.GetMatrixArray();
1060 Element *
const pDatac = this->GetMatrixArray();
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");
1107 if (!
constr && this->GetMatrixArray() ==
a.GetMatrixArray()) {
1108 Error(
"AMinusB",
"this = &a");
1112 if (!
constr && this->GetMatrixArray() ==
b.GetMatrixArray()) {
1113 Error(
"AMinusB",
"this = &b");
1119 Allocate(
a.GetNrows(),
a.GetNcols(),
a.GetRowLwb(),
a.GetColLwb());
1120 SetSparseIndexAB(
a,
b);
1129 const Element *
const pDataa =
a.GetMatrixArray();
1130 const Element *
const pDatab =
b.GetMatrixArray();
1131 Element *
const pDatac = this->GetMatrixArray();
1164template<
class Element>
1169 const Element *
const elem = GetMatrixArray();
1178template<
class Element>
1183 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1195 if (row[
irowmin] < this->fRowLwb|| row[
irowmax] > this->fRowLwb+this->fNrows-1) {
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]);
1201 if (row[
irowmax] > this->fRowLwb+this->fNrows-1) {
1202 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d",row[
irowmax]);
1203 this->fNrows = row[
irowmax]-this->fRowLwb+1;
1206 if (col[
icolmin] < this->fColLwb || col[
icolmax] > this->fColLwb+this->fNcols-1) {
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]);
1212 if (col[
icolmax] > this->fColLwb+this->fNcols-1) {
1213 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d",col[
icolmax]);
1214 this->fNcols = col[
icolmax]-this->fColLwb+1;
1221 const Element *
ep =
data;
1222 const Element *
const fp =
data+
nr;
1228 if (fColIndex) {
delete [] fColIndex; fColIndex =
nullptr; }
1229 if (fElements) {
delete [] fElements; fElements =
nullptr; }
1231 if (this->fNelems > 0) {
1235 fColIndex =
nullptr;
1236 fElements =
nullptr;
1240 if (this->fNelems <= 0)
1265template <
class Element>
1271 Error(
"SetMatrixArray(Int_t,Int_t*,Int_t*,Element*",
"nr <= 0");
1275 if (
nrows != this->fNrows) {
1278 fRowIndex =
nullptr;
1280 this->fNrows =
nrows;
1281 if (this->fNrows > 0) {
1283 this->fNrowIndex =
nrows + 1;
1285 fRowIndex =
nullptr;
1286 this->fNrowIndex = 0;
1290 if (
ncols != this->fNcols) {
1291 this->fNcols =
ncols;
1294 if (this->fRowLwb != this->fColLwb) {
1295 auto tmp = this->fRowLwb;
1296 this->fRowLwb = this->fColLwb;
1297 this->fColLwb = tmp;
1308 if (row[
irowmin] < this->fRowLwb || row[
irowmax] > this->fRowLwb + this->fNrows - 1) {
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]);
1314 if (row[
irowmax] > this->fRowLwb + this->fNrows - 1) {
1315 Info(
"SetMatrixArray",
"row index upper bound adjusted to %d", row[
irowmax]);
1316 this->fNrows = row[
irowmax] - this->fRowLwb + 1;
1319 if (col[
icolmin] < this->fColLwb || col[
icolmax] > this->fColLwb + this->fNcols - 1) {
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]);
1325 if (col[
icolmax] > this->fColLwb + this->fNcols - 1) {
1326 Info(
"SetMatrixArray",
"column index upper bound adjusted to %d", col[
icolmax]);
1327 this->fNcols = col[
icolmax] - this->fColLwb + 1;
1334 const Element *
ep =
data;
1335 const Element *
const fp =
data +
nr;
1344 fColIndex =
nullptr;
1348 fElements =
nullptr;
1351 if (this->fNelems > 0) {
1355 fColIndex =
nullptr;
1356 fElements =
nullptr;
1360 if (this->fNelems <= 0)
1388template<
class Element>
1399 Element *
oDp = fElements;
1422template<
class Element>
1427 if (this->GetNrows() !=
source.GetNrows() ||
this->GetNcols() !=
source.GetNcols() ||
1429 Error(
"SetSparseIndex",
"matrices not compatible");
1439 if (
source.GetRowIndexArray() &&
source.GetColIndexArray()) {
1443 const Element *
ep =
source.GetMatrixArray();
1455 fRowIndex[this->fNrows] =
nr;
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");
1518 if (this->NonZeros() != 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();
1606 if (this->NonZeros() != nc)
1644template<
class Element>
1648 if (!this->fIsOwner) {
1649 Error(
"ResizeTo(Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1653 if (this->fNelems > 0) {
1654 if (this->fNrows ==
nrows && this->fNcols ==
ncols &&
1738template<
class Element>
1743 if (!this->fIsOwner) {
1744 Error(
"ResizeTo(Int_t,Int_t,Int_t,Int_t,Int_t)",
"Not owner of data array,cannot resize");
1751 if (this->fNelems > 0) {
1837template<
class Element>
1858 this->fNrowIndex = this->fNrows+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");
1900 Error(
"GetSub",
"row_upb < row_lwb || col_upb < col_lwb");
1928 const Element *
ep = this->GetMatrixArray();
1934 if (
target.GetRowIndexArray() &&
target.GetColIndexArray()) {
1977template<
class Element>
1985 Error(
"SetSub",
"row_lwb out-of-bounds");
1989 Error(
"SetSub",
"col_lwb out-of-bounds");
1993 Error(
"SetSub",
"source matrix too large");
2025 fRowIndex =
new Int_t[this->fNrowIndex];
2101 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
2113template<
class Element>
2120 if (
source.NonZeros() <= 0)
2154 R__ASSERT(this->fNelems == fRowIndex[this->fNrowIndex-1]);
2165template<
class Element>
2170 if (fElements) {
delete [] fElements; fElements =
nullptr; }
2171 if (fColIndex) {
delete [] fColIndex; fColIndex =
nullptr; }
2173 memset(this->GetRowIndexArray(),0,this->fNrowIndex*
sizeof(
Int_t));
2181template<
class Element>
2189 for (i = this->fRowLwb; i <= this->fRowLwb+this->fNrows-1; i++)
2190 for (
Int_t j = this->fColLwb;
j <= this->fColLwb+this->fNcols-1;
j++)
2198 Element *
oDp = fElements;
2205 for (i = this->fRowLwb; i <= this->fRowLwb+this->fNrows-1; i++) {
2206 for (
Int_t j = this->fColLwb;
j <= this->fColLwb+this->fNcols-1;
j++) {
2210 fElements[
ielem] = 1.0;
2211 fColIndex[
ielem++] =
j-this->fColLwb;
2223template<
class Element>
2228 const Element *
ep = GetMatrixArray();
2229 const Element *
const fp =
ep+this->fNelems;
2230 const Int_t *
const pR = GetRowIndexArray();
2252template<
class Element>
2259 const Element *
ep = mt.GetMatrixArray();
2260 const Element *
const fp =
ep+this->fNcols;
2267 for (
Int_t i = 0; i < this->fNrows; i++,
ep += this->fNcols)
2269 ep -= this->fNelems-1;
2280template<
class Element>
2288 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
rown,this->fRowLwb,this->fRowLwb+this->fNrows);
2289 return fElements[0];
2292 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",
coln,this->fColLwb,this->fColLwb+this->fNcols);
2293 return fElements[0];
2299 if (this->fNrowIndex > 0 && fRowIndex[this->fNrowIndex-1] != 0) {
2306 return fElements[
index];
2314 return fElements[
index];
2316 Error(
"operator()(Int_t,Int_t",
"Insert row failed");
2317 return fElements[0];
2324template <
class Element>
2328 if (this->fNrowIndex > 0 && this->fRowIndex[this->fNrowIndex-1] == 0) {
2329 Error(
"operator()(Int_t,Int_t) const",
"row/col indices are not set");
2330 Info(
"operator()",
"fNrowIndex = %d fRowIndex[fNrowIndex-1] = %d\n",this->fNrowIndex,this->fRowIndex[this->fNrowIndex-1]);
2337 Error(
"operator()",
"Request row(%d) outside matrix range of %d - %d",
rown,this->fRowLwb,this->fRowLwb+this->fNrows);
2341 Error(
"operator()",
"Request column(%d) outside matrix range of %d - %d",
coln,this->fColLwb,this->fColLwb+this->fNcols);
2349 else return fElements[
index];
2356template<
class Element>
2360 Error(
"operator=(const TMatrixTSparse &)",
"matrices not compatible");
2364 if (this->GetMatrixArray() !=
source.GetMatrixArray()) {
2367 const Element *
const sp =
source.GetMatrixArray();
2368 Element *
const tp = this->GetMatrixArray();
2370 this->fTol =
source.GetTol();
2379template<
class Element>
2383 Error(
"operator=(const TMatrixT &)",
"matrices not compatible");
2387 if (this->GetMatrixArray() !=
source.GetMatrixArray()) {
2390 const Element *
const sp =
source.GetMatrixArray();
2391 Element *
const tp = this->GetMatrixArray();
2401 this->fTol =
source.GetTol();
2410template<
class Element>
2415 if (fRowIndex[this->fNrowIndex-1] == 0) {
2416 Error(
"operator=(Element",
"row/col indices are not set");
2420 Element *
ep = this->GetMatrixArray();
2421 const Element *
const ep_last =
ep+this->fNelems;
2431template<
class Element>
2436 Element *
ep = this->GetMatrixArray();
2437 const Element *
const ep_last =
ep+this->fNelems;
2447template<
class Element>
2452 Element *
ep = this->GetMatrixArray();
2453 const Element *
const ep_last =
ep+this->fNelems;
2463template<
class Element>
2468 Element *
ep = this->GetMatrixArray();
2469 const Element *
const ep_last =
ep+this->fNelems;
2479template<
class Element>
2484 const Element
scale = beta-alpha;
2485 const Element shift = alpha/
scale;
2489 Element *
const ep = GetMatrixArray();
2491 const Int_t m = this->GetNrows();
2492 const Int_t n = this->GetNcols();
2495 const Int_t nn = this->GetNrows()*this->GetNcols();
2496 const Int_t length = (this->GetNoElements() <= nn) ? this->GetNoElements() : nn;
2500 for (
Int_t k = 0; k < nn; k++) {
2501 const Element
r =
Drand(seed);
2526template<
class Element>
2529 const Element
scale = beta-alpha;
2530 const Element shift = alpha/
scale;
2535 if (this->fNrows != this->fNcols || this->fRowLwb != this->fColLwb) {
2536 Error(
"RandomizePD(Element &",
"matrix should be square");
2541 const Int_t n = this->fNcols;
2545 Element *
const ep = GetMatrixArray();
2572 for (
Int_t k = 0; k < nn; k++ ) {
2573 const Element
r =
Drand(seed);
2582 Int_t col = k-row*(row+1)/2;
2628 this->fNelems =
nnz;
2636 const Int_t *
const pR = this->GetRowIndexArray();
2637 const Int_t *
const pC = this->GetColIndexArray();
2638 Element *
const pD = GetMatrixArray();
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>
2807template<
class Element>
2811 ::Error(
"ElementMult(TMatrixTSparse &,const TMatrixTSparse &)",
"matrices not compatible");
2815 const Element *
sp =
source.GetMatrixArray();
2816 Element *
tp =
target.GetMatrixArray();
2827template<
class Element>
2831 ::Error(
"ElementDiv(TMatrixT &,const TMatrixT &)",
"matrices not compatible");
2835 const Element *
sp =
source.GetMatrixArray();
2836 Element *
tp =
target.GetMatrixArray();
2838 while (
tp <
ftp ) {
2842 Error(
"ElementDiv",
"source element is zero");
2852template<
class Element>
2855 if (!m1.IsValid()) {
2857 ::Error(
"AreCompatible",
"matrix 1 not valid");
2860 if (!m2.IsValid()) {
2862 ::Error(
"AreCompatible",
"matrix 2 not valid");
2866 if (m1.GetNrows() != m2.GetNrows() || m1.GetNcols() != m2.GetNcols() ||
2867 m1.GetRowLwb() != m2.GetRowLwb() || m1.GetColLwb() != m2.GetColLwb()) {
2869 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
2873 const Int_t *
pR1 = m1.GetRowIndexArray();
2874 const Int_t *
pR2 = m2.GetRowIndexArray();
2878 ::Error(
"AreCompatible",
"matrices 1 and 2 have different rowIndex");
2883 const Int_t *
pD1 = m1.GetColIndexArray();
2884 const Int_t *
pD2 = m2.GetColIndexArray();
2885 const Int_t nData = m1.GetNoElements();
2888 ::Error(
"AreCompatible",
"matrices 1 and 2 have different colIndex");
2889 for (
Int_t i = 0; i < nData; i++)
2900template<
class Element>
2903 if (
R__b.IsReading()) {
2908 if (this->fNelems < 0)
#define templateClassImp(name)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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.
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
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 .
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)
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.
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).
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)
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.
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)