50 template<
class Element>
64 template<
class Element>
67 if (size == 0)
return 0;
69 if ( size <= kSizeMax )
72 Element *heap =
new Element[size];
81 template<
class Element>
85 Error(
"Add(TVectorT<Element> &)",
"vector's not compatible");
90 Element *tp = this->GetMatrixArray();
91 const Element *
const tp_last = tp+fNrows;
99 template<
class Element>
104 Error(
"Add(TVectorT<Element> &)",
"vectors not compatible");
111 Element *tp = this->GetMatrixArray();
112 const Element *
const tp_last = tp+fNrows;
114 *tp++ = *sv1++ + *sv2++;
121 template<
class Element>
125 if (copySize == 0 || oldp == newp)
return 0;
127 if ( newSize <= kSizeMax && oldSize <= kSizeMax ) {
130 for (
Int_t i = copySize-1; i >= 0; i--)
133 for (
Int_t i = 0; i < copySize; i++)
138 memcpy(newp,oldp,copySize*
sizeof(Element));
148 template<
class Element>
158 Error(
"Allocate",
"nrows=%d",nrows);
166 fElements = New_m(fNrows);
168 memset(fElements,0,fNrows*
sizeof(Element));
174 template<
class Element>
183 template<
class Element>
192 template<
class Element>
196 SetElements(elements);
202 template<
class Element>
206 SetElements(elements);
212 template<
class Element>
223 template<
class Element>
235 template<
class Element>
247 template<
class Element>
262 template<
class Element>
266 Error(
"TVectorT(Int_t, Int_t, ...)",
"upb(%d) < lwb(%d)",upb,lwb);
277 for (
Int_t i = lwb+1; i <= upb; i++)
278 (*
this)(i) = (Element)va_arg(args,
Double_t);
280 if (strcmp((
char *)va_arg(args,
char *),
"END"))
281 Error(
"TVectorT(Int_t, Int_t, ...)",
"argument list must be terminated by \"END\"");
291 template<
class Element>
296 Error(
"ResizeTo(lwb,upb)",
"Not owner of data array,cannot resize");
300 const Int_t new_nrows = upb-lwb+1;
306 else if (new_nrows == 0) {
319 else if (
fNrows > nrows_old)
325 const Int_t nrows_copy = rowUpb_copy-rowLwb_copy+1;
329 if (nrows_copy > 0) {
330 const Int_t rowOldOff = rowLwb_copy-rowLwb_old;
332 Memcpy_m(elements_new+rowNewOff,elements_old+rowOldOff,nrows_copy,nelems_new,nrows_old);
346 template<
class Element>
350 Error(
"Use",
"upb(%d) < lwb(%d)",upb,lwb);
370 template<
class Element>
376 Error(
"GetSub",
"row_lwb out of bounds");
380 Error(
"GetSub",
"row_upb out of bounds");
383 if (row_upb < row_lwb) {
384 Error(
"GetSub",
"row_upb < row_lwb");
397 row_upb_sub = row_upb-row_lwb;
399 row_lwb_sub = row_lwb;
400 row_upb_sub = row_upb;
403 target.
ResizeTo(row_lwb_sub,row_upb_sub);
404 const Int_t nrows_sub = row_upb_sub-row_lwb_sub+1;
409 for (
Int_t irow = 0; irow < nrows_sub; irow++)
419 template<
class Element>
427 Error(
"SetSub",
"row_lwb outof bounds");
431 Error(
"SetSub",
"source vector too large");
441 for (
Int_t irow = 0; irow < nRows_source; irow++)
450 template<
class Element>
461 template<
class Element>
467 const Element *
const fp = ep+
fNrows;
479 template<
class Element>
485 const Element *
const fp = ep+
fNrows;
497 template<
class Element>
503 const Element *
const fp = ep+
fNrows;
519 template<
class Element>
525 const Element *
const fp = ep+
fNrows;
541 template<
class Element>
545 Error(
"SelectNonZeros(const TVectorT<Element> &",
"vector's not compatible");
551 const Element *
const fp = ep+
fNrows;
564 template<
class Element>
571 const Element *
const fp = ep+
fNrows;
581 template<
class Element>
588 const Element *
const fp = ep+
fNrows;
590 norm += (*ep) * (*ep);
600 template<
class Element>
607 const Element *
const fp = ep+
fNrows;
617 template<
class Element>
622 Int_t nr_nonzeros = 0;
624 const Element *
const fp = ep+
fNrows;
626 if (*ep++) nr_nonzeros++;
634 template<
class Element>
641 const Element *
const fp = ep+
fNrows;
651 template<
class Element>
663 template<
class Element>
677 template<
class Element>
681 Error(
"operator=(const TVectorT<Element> &)",
"vectors not compatible");
695 template<
class Element>
704 Error(
"operator=(const TMatrixTRow_const &)",
"vector and row not compatible");
710 const Element *rp = mr.
GetPtr();
712 const Element *
const fp = ep+
fNrows;
726 template<
class Element>
735 Error(
"operator=(const TMatrixTColumn_const &)",
"vector and column not compatible");
741 const Element *cp = mc.
GetPtr();
743 const Element *
const fp = ep+
fNrows;
757 template<
class Element>
766 Error(
"operator=(const TMatrixTDiag_const &)",
"vector and matrix-diagonal not compatible");
772 const Element *dp = md.
GetPtr();
774 const Element *
const fp = ep+
fNrows;
789 template<
class Element>
798 Error(
"operator=(const TMatrixTSparseRow_const &)",
"vector and row not compatible");
804 const Element *
const prData = mr.
GetDataPtr();
808 memset(pvData,0,
fNrows*
sizeof(Element));
809 for (
Int_t index = 0; index < nIndex; index++) {
810 const Int_t icol = prCol[index];
811 pvData[icol] = prData[index];
820 template<
class Element>
829 Error(
"operator=(const TMatrixTSparseDiag_const &)",
"vector and matrix-diagonal not compatible");
836 pvData[idiag] = md(idiag);
844 template<
class Element>
850 const Element *
const fp = ep+
fNrows;
860 template<
class Element>
866 const Element *
const fp = ep+
fNrows;
876 template<
class Element>
882 const Element *
const fp = ep+
fNrows;
892 template<
class Element>
898 const Element *
const fp = ep+
fNrows;
908 template<
class Element>
912 Error(
"operator+=(const TVectorT<Element> &)",
"vector's not compatible");
918 const Element *
const tp_last = tp+
fNrows;
928 template<
class Element>
932 Error(
"operator-=(const TVectorT<Element> &)",
"vector's not compatible");
938 const Element *
const tp_last = tp+
fNrows;
949 template<
class Element>
956 Error(
"operator*=(const TMatrixT &)",
"vector and matrix incompatible");
963 Error(
"operator*=(const TMatrixT &)",
"vector has to be resized but not owner");
969 Element *elements_old = work;
973 elements_old =
new Element[nrows_old];
975 memcpy(elements_old,
fElements,nrows_old*
sizeof(Element));
980 ResizeTo(rowlwb_new,rowlwb_new+nrows_new-1);
987 if (
typeid(Element) ==
typeid(
Double_t))
989 a.
GetNcols(),elements_old,1,0.0,tp,1);
990 else if (
typeid(Element) !=
typeid(
Float_t))
992 a.
GetNcols(),elements_old,1,0.0,tp,1);
994 Error(
"operator*=",
"type %s not implemented in BLAS library",
typeid(Element));
996 const Element *
const tp_last = tp+
fNrows;
997 while (tp < tp_last) {
999 for (
const Element *sp = elements_old; sp < elements_old+nrows_old; )
1000 sum += *sp++ * *mp++;
1007 delete [] elements_old;
1016 template<
class Element>
1023 Error(
"operator*=(const TMatrixTSparse &)",
"vector and matrix incompatible");
1030 Error(
"operator*=(const TMatrixTSparse &)",
"vector has to be resized but not owner");
1036 Element *elements_old = work;
1039 isAllocated =
kTRUE;
1040 elements_old =
new Element[nrows_old];
1042 memcpy(elements_old,
fElements,nrows_old*
sizeof(Element));
1047 ResizeTo(rowlwb_new,rowlwb_new+nrows_new-1);
1055 const Element *
const sp = elements_old;
1059 const Int_t sIndex = pRowIndex[irow];
1060 const Int_t eIndex = pRowIndex[irow+1];
1062 for (
Int_t index = sIndex; index < eIndex; index++) {
1063 const Int_t icol = pColIndex[index];
1064 sum += mp[index]*sp[icol];
1070 delete [] elements_old;
1079 template<
class Element>
1086 Error(
"operator*=(const TMatrixTSym &)",
"vector and matrix incompatible");
1093 Element *elements_old = work;
1096 isAllocated =
kTRUE;
1097 elements_old =
new Element[nrows_old];
1099 memcpy(elements_old,
fElements,nrows_old*
sizeof(Element));
1105 if (
typeid(Element) ==
typeid(
Double_t))
1106 cblas_dsymv(CblasRowMajor,CblasUpper,
fNrows,1.0,mp,
1107 fNrows,elements_old,1,0.0,tp,1);
1108 else if (
typeid(Element) !=
typeid(
Float_t))
1109 cblas_ssymv(CblasRowMajor,CblasUpper,
fNrows,1.0,mp,
1110 fNrows,elements_old,1,0.0,tp,1);
1112 Error(
"operator*=",
"type %s not implemented in BLAS library",
typeid(Element));
1114 const Element *
const tp_last = tp+
fNrows;
1115 while (tp < tp_last) {
1117 for (
const Element *sp = elements_old; sp < elements_old+nrows_old; )
1118 sum += *sp++ * *mp++;
1125 delete [] elements_old;
1133 template<
class Element>
1139 const Element *
const fp = ep+
fNrows;
1141 if (!(*ep++ == val))
1150 template<
class Element>
1156 const Element *
const fp = ep+
fNrows;
1158 if (!(*ep++ != val))
1167 template<
class Element>
1173 const Element *
const fp = ep+
fNrows;
1184 template<
class Element>
1190 const Element *
const fp = ep+
fNrows;
1192 if (!(*ep++ <= val))
1201 template<
class Element>
1207 const Element *
const fp = ep+
fNrows;
1218 template<
class Element>
1224 const Element *
const fp = ep+
fNrows;
1226 if (!(*ep++ >= val))
1235 template<
class Element>
1239 Error(
"MatchesNonZeroPattern(const TVectorT&)",
"vector's not compatible");
1245 const Element *
const fp = ep+
fNrows;
1247 if (*sp == 0.0 && *ep != 0.0)
1258 template<
class Element>
1262 Error(
"SomePositive(const TVectorT&)",
"vector's not compatible");
1268 const Element *
const fp = ep+
fNrows;
1270 if (*sp != 0.0 && *ep <= 0.0)
1281 template<
class Element>
1285 Error(
"AddSomeConstant(Element,const TVectorT&)(const TVectorT&)",
"vector's not compatible");
1289 const Element *
const fp = ep+
fNrows;
1302 template<
class Element>
1307 const Element scale = beta-alpha;
1308 const Element shift = alpha/scale;
1311 const Element *
const fp = ep+
fNrows;
1313 *ep++ = scale*(
Drand(seed)+shift);
1319 template<
class Element>
1332 template<
class Element>
1350 template<
class Element>
1353 gROOT->ProcessLine(
Form(
"THistPainter::PaintSpecialObjects((TObject*)0x%lx,\"%s\");",
1360 template<
class Element>
1364 Error(
"Print",
"Vector is invalid");
1368 printf(
"\nVector (%d) %s is as follows",
fNrows,flag);
1370 printf(
"\n\n | %6d |", 1);
1371 printf(
"\n%s\n",
"------------------");
1375 printf(
"%g \n",(*
this)(i+
fRowLwb));
1383 template<
class Element>
1393 template<
class Element>
1398 Error(
"operator*(const TVectorT<Element> &,const TVectorT<Element> &)",
"vector's are incompatible");
1409 template<
class Element>
1420 template<
class Element>
1431 template<
class Element>
1436 return Add(target,Element(1.0),a,source);
1442 template<
class Element>
1447 return Add(target,Element(1.0),a,source);
1453 template<
class Element>
1458 return Add(target,Element(1.0),a,source);
1464 template<
class Element>
1475 template<
class Element>
1481 const Element *
const fv1p = v1p+v1.
GetNrows();
1483 sum += *v1p++ * *v2p++;
1491 template <
class Element1,
class Element2>
1507 template <
class Element1,
class Element2,
class Element3>
1514 const Element1 *
const m_last = mp + target.
GetNoElements();
1517 const Element2 *
const v1_last = v1p + v1.
GetNrows();
1520 const Element3 * v2p = v20;
1521 const Element3 *
const v2_last = v2p + v2.
GetNrows();
1523 while (v1p < v1_last) {
1525 while (v2p < v2_last) {
1526 *mp++ = *v1p * *v2p++ ;
1531 R__ASSERT(v1p == v1_last && mp == m_last && v2p == v2_last);
1539 template <
class Element1,
class Element2,
class Element3>
1545 ::Error(
"Mult",
"Vector v1 and matrix m incompatible");
1549 ::Error(
"Mult",
"Matrix m and vector v2 incompatible");
1555 const Element1 *
const v1_last = v1p + v1.
GetNrows();
1561 const Element3 * v2p = v20;
1562 const Element3 *
const v2_last = v2p + v2.
GetNrows();
1567 while (v1p < v1_last) {
1569 while (v2p < v2_last) {
1570 dot += *mp++ * *v2p++;
1572 sum += *v1p++ * dot;
1576 R__ASSERT(v1p == v1_last && mp == m_last && v2p == v2_last);
1584 template<
class Element>
1588 Error(
"Add(TVectorT<Element> &,Element,const TVectorT<Element> &)",
"vector's are incompatible");
1594 const Element *
const ftp = tp+target.
GetNrows();
1595 if (scalar == 1.0 ) {
1598 }
else if (scalar == -1.0) {
1603 *tp++ += scalar * *sp++;
1613 template<
class Element>
1621 Error(
"Add(TVectorT &,const TMatrixT &,const TVectorT &)",
"target vector and matrix are incompatible");
1627 Error(
"Add(TVectorT &,const TMatrixT &,const TVectorT &)",
"source vector and matrix are incompatible");
1636 if (
typeid(Element) ==
typeid(
Double_t))
1637 cblas_dsymv(CblasRowMajor,CblasUpper,
fNrows,scalar,mp,
1639 else if (
typeid(Element) !=
typeid(
Float_t))
1640 cblas_ssymv(CblasRowMajor,CblasUpper,
fNrows,scalar,mp,
1643 Error(
"operator*=",
"type %s not implemented in BLAS library",
typeid(Element));
1645 const Element *
const sp_last = sp+source.
GetNrows();
1646 const Element *
const tp_last = tp+target.
GetNrows();
1647 if (scalar == 1.0) {
1648 while (tp < tp_last) {
1649 const Element *sp1 = sp;
1651 while (sp1 < sp_last)
1652 sum += *sp1++ * *mp++;
1655 }
else if (scalar == 0.0) {
1656 while (tp < tp_last) {
1657 const Element *sp1 = sp;
1659 while (sp1 < sp_last)
1660 sum += *sp1++ * *mp++;
1663 }
else if (scalar == -1.0) {
1664 while (tp < tp_last) {
1665 const Element *sp1 = sp;
1667 while (sp1 < sp_last)
1668 sum += *sp1++ * *mp++;
1672 while (tp < tp_last) {
1673 const Element *sp1 = sp;
1675 while (sp1 < sp_last)
1676 sum += *sp1++ * *mp++;
1677 *tp++ += scalar *
sum;
1691 template<
class Element>
1700 Error(
"Add(TVectorT &,const TMatrixT &,const TVectorT &)",
"target vector and matrix are incompatible");
1709 if (
typeid(Element) ==
typeid(
Double_t))
1710 cblas_dsymv(CblasRowMajor,CblasUpper,
fNrows,1.0,mp,
1712 else if (
typeid(Element) !=
typeid(
Float_t))
1713 cblas_ssymv(CblasRowMajor,CblasUpper,
fNrows,1.0,mp,
1716 Error(
"operator*=",
"type %s not implemented in BLAS library",
typeid(Element));
1718 const Element *
const sp_last = sp+source.
GetNrows();
1719 const Element *
const tp_last = tp+target.
GetNrows();
1720 if (scalar == 1.0) {
1721 while (tp < tp_last) {
1722 const Element *sp1 = sp;
1724 while (sp1 < sp_last)
1725 sum += *sp1++ * *mp++;
1728 }
else if (scalar == 0.0) {
1729 while (tp < tp_last) {
1730 const Element *sp1 = sp;
1732 while (sp1 < sp_last)
1733 sum += *sp1++ * *mp++;
1736 }
else if (scalar == -1.0) {
1737 while (tp < tp_last) {
1738 const Element *sp1 = sp;
1740 while (sp1 < sp_last)
1741 sum += *sp1++ * *mp++;
1745 while (tp < tp_last) {
1746 const Element *sp1 = sp;
1748 while (sp1 < sp_last)
1749 sum += *sp1++ * *mp++;
1750 *tp++ += scalar *
sum;
1763 template<
class Element>
1771 Error(
"Add(TVectorT &,const TMatrixT &,const TVectorT &)",
"target vector and matrix are incompatible");
1777 Error(
"Add(TVectorT &,const TMatrixT &,const TVectorT &)",
"source vector and matrix are incompatible");
1789 if (scalar == 1.0) {
1791 const Int_t sIndex = pRowIndex[irow];
1792 const Int_t eIndex = pRowIndex[irow+1];
1794 for (
Int_t index = sIndex; index < eIndex; index++) {
1795 const Int_t icol = pColIndex[index];
1796 sum += mp[index]*sp[icol];
1800 }
else if (scalar == 0.0) {
1802 const Int_t sIndex = pRowIndex[irow];
1803 const Int_t eIndex = pRowIndex[irow+1];
1805 for (
Int_t index = sIndex; index < eIndex; index++) {
1806 const Int_t icol = pColIndex[index];
1807 sum += mp[index]*sp[icol];
1811 }
else if (scalar == -1.0) {
1813 const Int_t sIndex = pRowIndex[irow];
1814 const Int_t eIndex = pRowIndex[irow+1];
1816 for (
Int_t index = sIndex; index < eIndex; index++) {
1817 const Int_t icol = pColIndex[index];
1818 sum += mp[index]*sp[icol];
1824 const Int_t sIndex = pRowIndex[irow];
1825 const Int_t eIndex = pRowIndex[irow+1];
1827 for (
Int_t index = sIndex; index < eIndex; index++) {
1828 const Int_t icol = pColIndex[index];
1829 sum += mp[index]*sp[icol];
1831 tp[irow] += scalar *
sum;
1841 template<
class Element>
1846 Error(
"AddElemMult(TVectorT<Element> &,Element,const TVectorT<Element> &,const TVectorT<Element> &)",
1847 "vector's are incompatible");
1854 const Element *
const ftp = tp+target.
GetNrows();
1856 if (scalar == 1.0 ) {
1858 *tp++ += *sp1++ * *sp2++;
1859 }
else if (scalar == -1.0) {
1861 *tp++ -= *sp1++ * *sp2++;
1864 *tp++ += scalar * *sp1++ * *sp2++;
1874 template<
class Element>
1880 Error(
"AddElemMult(TVectorT<Element> &,Element,const TVectorT<Element> &,const TVectorT<Element> &,onst TVectorT<Element> &)",
1881 "vector's are incompatible");
1889 const Element *
const ftp = tp+target.
GetNrows();
1891 if (scalar == 1.0 ) {
1892 while ( tp < ftp ) {
1893 if (*mp) *tp += *sp1 * *sp2;
1894 mp++; tp++; sp1++; sp2++;
1896 }
else if (scalar == -1.0) {
1897 while ( tp < ftp ) {
1898 if (*mp) *tp -= *sp1 * *sp2;
1899 mp++; tp++; sp1++; sp2++;
1902 while ( tp < ftp ) {
1903 if (*mp) *tp += scalar * *sp1 * *sp2;
1904 mp++; tp++; sp1++; sp2++;
1914 template<
class Element>
1919 Error(
"AddElemDiv(TVectorT<Element> &,Element,const TVectorT<Element> &,const TVectorT<Element> &)",
1920 "vector's are incompatible");
1927 const Element *
const ftp = tp+target.
GetNrows();
1929 if (scalar == 1.0 ) {
1930 while ( tp < ftp ) {
1935 Error(
"AddElemDiv",
"source2 (%d) is zero",irow);
1939 }
else if (scalar == -1.0) {
1940 while ( tp < ftp ) {
1945 Error(
"AddElemDiv",
"source2 (%d) is zero",irow);
1950 while ( tp < ftp ) {
1952 *tp += scalar * *sp1 / *sp2;
1955 Error(
"AddElemDiv",
"source2 (%d) is zero",irow);
1968 template<
class Element>
1974 Error(
"AddElemDiv(TVectorT<Element> &,Element,const TVectorT<Element> &,const TVectorT<Element> &,onst TVectorT<Element> &)",
1975 "vector's are incompatible");
1983 const Element *
const ftp = tp+target.
GetNrows();
1985 if (scalar == 1.0 ) {
1986 while ( tp < ftp ) {
1992 Error(
"AddElemDiv",
"source2 (%d) is zero",irow);
1995 mp++; tp++; sp1++; sp2++;
1997 }
else if (scalar == -1.0) {
1998 while ( tp < ftp ) {
2004 Error(
"AddElemDiv",
"source2 (%d) is zero",irow);
2007 mp++; tp++; sp1++; sp2++;
2010 while ( tp < ftp ) {
2013 *tp += scalar * *sp1 / *sp2;
2016 Error(
"AddElemDiv",
"source2 (%d) is zero",irow);
2019 mp++; tp++; sp1++; sp2++;
2029 template<
class Element>
2033 Error(
"ElementMult(TVectorT<Element> &,const TVectorT<Element> &)",
"vector's are incompatible");
2039 const Element *
const ftp = tp+target.
GetNrows();
2049 template<
class Element>
2053 Error(
"ElementMult(TVectorT<Element> &,const TVectorT<Element> &,const TVectorT<Element> &)",
"vector's are incompatible");
2060 const Element *
const ftp = tp+target.
GetNrows();
2061 while ( tp < ftp ) {
2062 if (*mp) *tp *= *sp;
2072 template<
class Element>
2076 Error(
"ElementDiv(TVectorT<Element> &,const TVectorT<Element> &)",
"vector's are incompatible");
2082 const Element *
const ftp = tp+target.
GetNrows();
2083 while ( tp < ftp ) {
2088 Error(
"ElementDiv",
"source (%d) is zero",irow);
2098 template<
class Element>
2102 Error(
"ElementDiv(TVectorT<Element> &,const TVectorT<Element> &,const TVectorT<Element> &)",
"vector's are incompatible");
2109 const Element *
const ftp = tp+target.
GetNrows();
2110 while ( tp < ftp ) {
2116 Error(
"ElementDiv",
"source (%d) is zero",irow);
2128 template<
class Element1,
class Element2>
2133 ::Error(
"AreCompatible",
"vector 1 not valid");
2138 ::Error(
"AreCompatible",
"vector 2 not valid");
2144 ::Error(
"AreCompatible",
"matrices 1 and 2 not compatible");
2154 template<
class Element1,
class Element2>
2159 ::Error(
"AreCompatible",
"Matrix not valid");
2164 ::Error(
"AreCompatible",
"vector not valid");
2170 ::Error(
"AreCompatible",
"matrix and vector not compatible");
2180 template<
class Element1,
class Element2>
2185 ::Error(
"AreCompatible",
"Matrix not valid");
2190 ::Error(
"AreCompatible",
"vector not valid");
2196 ::Error(
"AreCompatible",
"vector and matrix not compatible");
2206 template<
class Element>
2210 Error(
"Compare(const TVectorT<Element> &,const TVectorT<Element> &)",
"vectors are incompatible");
2214 printf(
"\n\nComparison of two TVectorTs:\n");
2220 Element difmax = -1;
2225 const Element mv1 = *mp1++;
2226 const Element mv2 = *mp2++;
2229 if (diff > difmax) {
2239 printf(
"\nMaximal discrepancy \t\t%g",difmax);
2240 printf(
"\n occured at the point\t\t(%d)",imax);
2241 const Element mv1 = v1(imax);
2242 const Element mv2 = v2(imax);
2243 printf(
"\n Vector 1 element is \t\t%g",mv1);
2244 printf(
"\n Vector 2 element is \t\t%g",mv2);
2245 printf(
"\n Absolute error v2[i]-v1[i]\t\t%g",mv2-mv1);
2246 printf(
"\n Relative error\t\t\t\t%g\n",
2249 printf(
"\n||Vector 1|| \t\t\t%g",norm1);
2250 printf(
"\n||Vector 2|| \t\t\t%g",norm2);
2251 printf(
"\n||Vector1-Vector2||\t\t\t\t%g",ndiff);
2252 printf(
"\n||Vector1-Vector2||/sqrt(||Vector1|| ||Vector2||)\t%g\n\n",
2259 template<
class Element>
2264 Element maxDevObs = 0;
2271 if (dev > maxDevObs) {
2281 printf(
"Largest dev for (%d); dev = |%g - %g| = %g\n",imax,
v(imax),val,maxDevObs);
2282 if (maxDevObs > maxDevAllow)
2283 Error(
"VerifyVectorValue",
"Deviation > %g\n",maxDevAllow);
2286 if (maxDevObs > maxDevAllow)
2294 template<
class Element>
2299 Element maxDevObs = 0;
2309 if (dev > maxDevObs) {
2319 printf(
"Largest dev for (%d); dev = |%g - %g| = %g\n",imax,v1(imax),v2(imax),maxDevObs);
2320 if (maxDevObs > maxDevAllow)
2321 Error(
"VerifyVectorIdentity",
"Deviation > %g\n",maxDevAllow);
2324 if (maxDevObs > maxDevAllow) {
2333 template<
class Element>
2343 TObject::Streamer(R__b);
const TMatrixTBase< Element > * GetMatrix() const
virtual const Element * GetMatrixArray() const
static long int sum(long int i)
const Element * GetPtr() const
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Long64_t LocMax(Long64_t n, const T *a)
TVectorT< Element > & operator-=(Element val)
Subtract val from every element of the vector.
Bool_t operator!=(Element val) const
Are all vector elements not equal to val?
virtual const Int_t * GetRowIndexArray() const
void Add(const TVectorT< Element > &v)
Add vector v to this vector.
template Double_t Dot< Double_t >(const TVectorD &v1, const TVectorD &v2)
void Draw(Option_t *option="")
Draw this vector The histogram is named "TVectorT" by default and no title.
virtual const Element * GetMatrixArray() const
template void Compare< Double_t >(const TVectorD &v1, const TVectorD &v2)
TVectorT< Element > & AddElemDiv(TVectorT< Element > &target, Element scalar, const TVectorT< Element > &source1, const TVectorT< Element > &source2)
Modify addition: target += scalar * ElementDiv(source1,source2) .
TMatrixT< Element1 > OuterProduct(const TVectorT< Element1 > &v1, const TVectorT< Element2 > &v2)
Return the matrix M = v1 * v2'.
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
Bool_t fIsOwner
data container
template TVectorD & AddElemMult< Double_t >(TVectorD &target, Double_t scalar, const TVectorD &source1, const TVectorD &source2)
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
TVectorT< Element > & Invert()
v[i] = 1/v[i]
template TVectorF & ElementDiv< Float_t >(TVectorF &target, const TVectorF &source)
template Float_t Mult< Float_t, Float_t, Float_t >(const TVectorF &v1, const TMatrixF &m, const TVectorF &v2)
Short_t Min(Short_t a, Short_t b)
Element fDataStack[kSizeMax]
TVectorT< Element > operator-(const TVectorT< Element > &source1, const TVectorT< Element > &source2)
Return source1-source2.
Element NormInf() const
Compute the infinity-norm of the vector MAX{ |v[i]| }.
virtual const Element * GetMatrixArray() const
Bool_t VerifyVectorIdentity(const TVectorT< Element > &v1, const TVectorT< Element > &v2, Int_t verbose, Element maxDevAllow)
Verify that elements of the two vectors are equal within maxDevAllow .
template Bool_t AreCompatible< Float_t, Double_t >(const TVectorF &v1, const TVectorD &v2, Int_t verbose)
template TVectorD & ElementDiv< Double_t >(TVectorD &target, const TVectorD &source)
template TVectorF & AddElemDiv< Float_t >(TVectorF &target, Float_t scalar, const TVectorF &source1, const TVectorF &source2)
void Print(Option_t *option="") const
Print the vector as a list of elements.
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
const Element * GetPtr() const
TVectorT< Element > & Sqr()
Square each element of the vector.
double beta(double x, double y)
Calculates the beta function.
void Randomize(Element alpha, Element beta, Double_t &seed)
randomize vector elements value
Int_t GetNoElements() const
Element1 Mult(const TVectorT< Element1 > &v1, const TMatrixT< Element2 > &m, const TVectorT< Element3 > &v2)
Perform v1 * M * v2, a scalar result.
#define templateClassImp(name)
template TMatrixF OuterProduct< Float_t, Float_t >(const TVectorF &v1, const TVectorF &v2)
const Element * GetPtr() const
TVectorT< Element > & Use(Int_t lwb, Int_t upb, Element *data)
Use the array data to fill the vector lwb..upb].
template TVectorD & Add< Double_t >(TVectorD &target, Double_t scalar, const TVectorD &source)
virtual void Operation(Element &element) const =0
template TVectorF & AddElemMult< Float_t >(TVectorF &target, Float_t scalar, const TVectorF &source1, const TVectorF &source2)
Bool_t operator>=(Element val) const
Are all vector elements >= val?
const Element * GetDataPtr() const
TVectorT< Element > & SetSub(Int_t row_lwb, const TVectorT< Element > &source)
Insert vector source starting at [row_lwb], thereby overwriting the part [row_lwb..row_lwb+nrows_source];.
template void Compare< Float_t >(const TVectorF &v1, const TVectorF &v2)
Element operator*(const TVectorT< Element > &v1, const TVectorT< Element > &v2)
Compute the scalar product.
Element Dot(const TVectorT< Element > &v1, const TVectorT< Element > &v2)
return inner-produvt v1 . v2
TObject & operator=(const TObject &rhs)
TObject assignment operator.
void Delete_m(Int_t size, Element *&)
Delete data pointer m, if it was assigned on the heap.
template TVectorF & Add< Float_t >(TVectorF &target, Float_t scalar, const TVectorF &source)
void Clear(Option_t *="")
TVectorT< Element > & Sqrt()
Take square root of all elements.
template TMatrixF & OuterProduct< Float_t, Float_t, Float_t >(TMatrixF &target, const TVectorF &v1, const TVectorF &v2)
void Error(const char *location, const char *msgfmt,...)
TVectorT< Element > & ElementMult(TVectorT< Element > &target, const TVectorT< Element > &source)
Multiply target by the source, element-by-element.
void Allocate(Int_t nrows, Int_t row_lwb=0, Int_t init=0)
Allocate new vector.
TVectorT< Element > & GetSub(Int_t row_lwb, Int_t row_upb, TVectorT< Element > &target, Option_t *option="S") const
Get subvector [row_lwb..row_upb]; The indexing range of the returned vector depends on the argument o...
Element Sum() const
Compute sum of elements.
Element Min() const
return minimum vector element value
Element * GetMatrixArray()
template Bool_t AreCompatible< Double_t, Double_t >(const TVectorD &v1, const TVectorD &v2, Int_t verbose)
template Bool_t VerifyVectorIdentity< Float_t >(const TVectorF &m1, const TVectorF &m2, Int_t verbose, Float_t maxDevAllow)
template Bool_t VerifyVectorIdentity< Double_t >(const TVectorD &m1, const TVectorD &m2, Int_t verbose, Double_t maxDevAllow)
Bool_t operator==(Element val) const
Are all vector elements equal to val?
TVectorT< Element > & operator=(const TVectorT< Element > &source)
Notice that this assignment does NOT change the ownership : if the storage space was adopted...
TVectorT< Element > & operator*=(Element val)
Multiply every element of the vector with val.
TVectorT< Element > & Zero()
Set vector elements to zero.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
Bool_t operator>(Element val) const
Are all vector elements > val?
template TMatrixD & OuterProduct< Double_t, Double_t, Double_t >(TMatrixD &target, const TVectorD &v1, const TVectorD &v2)
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Element Norm2Sqr() const
Compute the square of the 2-norm SUM{ v[i]^2 }.
Bool_t operator<=(Element val) const
Are all vector elements <= val?
Element Norm1() const
Compute the 1-norm of the vector SUM{ |v[i]| }.
R__EXTERN Int_t gMatrixCheck
TVectorT< Element > operator+(const TVectorT< Element > &source1, const TVectorT< Element > &source2)
Return source1+source2.
const TMatrixTBase< Element > * GetMatrix() const
virtual const Int_t * GetColIndexArray() const
const Int_t * GetColPtr() const
template Bool_t AreCompatible< Double_t, Float_t >(const TVectorD &v1, const TVectorF &v2, Int_t verbose)
Int_t NonZeros() const
Compute the number of elements != 0.0.
TVectorT< Element > & SelectNonZeros(const TVectorT< Element > &select)
Keep only element as selected through array select non-zero.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
TVectorT< Element > & ElementDiv(TVectorT< Element > &target, const TVectorT< Element > &source)
Divide target by the source, element-by-element.
Bool_t VerifyVectorValue(const TVectorT< Element > &v, Element val, Int_t verbose, Element maxDevAllow)
Validate that all elements of vector have value val within maxDevAllow .
TVectorT< Element > & AddElemMult(TVectorT< Element > &target, Element scalar, const TVectorT< Element > &source1, const TVectorT< Element > &source2)
Modify addition: target += scalar * ElementMult(source1,source2) .
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
template TVectorD & ElementMult< Double_t >(TVectorD &target, const TVectorD &source)
const TMatrixTBase< Element > * GetMatrix() const
virtual void Operation(Element &element) const =0
TCppObject_t Allocate(TCppType_t type)
Mother of all ROOT objects.
const TMatrixTBase< Element > * GetMatrix() const
Int_t Memcpy_m(Element *newp, const Element *oldp, Int_t copySize, Int_t newSize, Int_t oldSize)
Copy copySize doubles from *oldp to *newp .
Short_t Max(Short_t a, Short_t b)
TVectorT< Element > & Abs()
Take an absolute value of a vector, i.e. apply Abs() to each element.
Bool_t MatchesNonZeroPattern(const TVectorT< Element > &select)
Check if vector elements as selected through array select are non-zero.
template Bool_t AreCompatible< Float_t, Float_t >(const TVectorF &v1, const TVectorF &v2, Int_t verbose)
template Double_t Mult< Double_t, Double_t, Double_t >(const TVectorD &v1, const TMatrixD &m, const TVectorD &v2)
Double_t Sqrt(Double_t x)
template Float_t Dot< Float_t >(const TVectorF &v1, const TVectorF &v2)
Bool_t AreCompatible(const TVectorT< Element1 > &v1, const TVectorT< Element2 > &v2, Int_t verbose)
Check if v1 and v2 are both valid and have the same shape.
Long64_t LocMin(Long64_t n, const T *a)
template Bool_t VerifyVectorValue< Float_t >(const TVectorF &m, Float_t val, Int_t verbose, Float_t maxDevAllow)
Element Max() const
return maximum vector element value
double norm(double *x, double *p)
Element * New_m(Int_t size)
default kTRUE, when Use array kFALSE
template Bool_t VerifyVectorValue< Double_t >(const TVectorD &m, Double_t val, Int_t verbose, Double_t maxDevAllow)
void AddSomeConstant(Element val, const TVectorT< Element > &select)
Add to vector elements as selected through array select the value val.
const TMatrixTBase< Element > * GetMatrix() const
template TVectorF & ElementMult< Float_t >(TVectorF &target, const TVectorF &source)
Bool_t SomePositive(const TVectorT< Element > &select)
Check if vector elements as selected through array select are all positive.
template TVectorD & AddElemDiv< Double_t >(TVectorD &target, Double_t scalar, const TVectorD &source1, const TVectorD &source2)
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Bool_t operator<(Element val) const
Are all vector elements < val?
TVectorT< Element > & operator+=(Element val)
Add val to every element of the vector.
TVectorT< Element > & Apply(const TElementActionT< Element > &action)
Apply action to each element of the vector.
virtual Int_t ReadArray(Bool_t *&b)=0
template TMatrixD OuterProduct< Double_t, Double_t >(const TVectorD &v1, const TVectorD &v2)
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.