141 pmin =
gPad->PadtoX(
gPad->GetUxmin());
142 pmax =
gPad->PadtoX(
gPad->GetUxmax());
146 if (xmax < pmin)
return;
147 if (xmin > pmax)
return;
148 if (xmin < pmin) xmin = pmin;
149 if (xmax > pmax) xmax = pmax;
166 if (xmin > 0 &&
gPad->GetLogx()) {
171 for (i=0;i<=
fNpx;i++) {
172 xbins[i] =
gPad->PadtoX(xlogmin+ i*dlogx);
183 for (i=1;i<=
fNpx;i++) {
201 char *o = (
char *) opt.
Data();
206 if(o[i]==
'p') graph=
kTRUE ;
else o[j++]=o[i];
234 void TSpline::Streamer(
TBuffer &R__b)
244 TNamed::Streamer(R__b);
245 TAttLine::Streamer(R__b);
246 TAttFill::Streamer(R__b);
247 TAttMarker::Streamer(R__b);
385 fValBeg(valbeg), fValEnd(valend), fBegCond(0), fEndCond(0)
395 for (
Int_t i=0; i<
n; ++i) {
414 fValBeg(valbeg), fValEnd(valend),
415 fBegCond(0), fEndCond(0)
425 for (
Int_t i=0; i<
n; ++i) {
444 fValBeg(valbeg), fValEnd(valend),
445 fBegCond(0), fEndCond(0)
455 for (
Int_t i=0; i<
n; ++i) {
475 fValBeg(valbeg), fValEnd(valend),
476 fBegCond(0), fEndCond(0)
489 for (
Int_t i=0; i<
n; ++i) {
506 const TGraph *
g,
const char *opt,
509 fValBeg(valbeg), fValEnd(valend),
510 fBegCond(0), fEndCond(0)
540 fValBeg(valbeg), fValEnd(valend),
541 fBegCond(0), fEndCond(0)
569 fValBeg(sp3.fValBeg),
570 fValEnd(sp3.fValEnd),
571 fBegCond(sp3.fBegCond),
572 fEndCond(sp3.fEndCond)
606 const char *b1 = strstr(opt,
"b1");
607 const char *e1 = strstr(opt,
"e1");
608 const char *b2 = strstr(opt,
"b2");
609 const char *e2 = strstr(opt,
"e2");
611 Error(
"SetCond",
"Cannot specify first and second derivative at first point");
613 Error(
"SetCond",
"Cannot specify first and second derivative at last point");
653 printf(
"1 TEST OF TSpline3 WITH NONEQUIDISTANT KNOTS\n");
668 printf(
"\n-N = %3d M =%2d\n",n,m);
670 for (i = 0; i <
n; ++i)
671 spline->
GetCoeff(i,hx, a[i],a[i+200],a[i+400],a[i+600]);
673 for (i = 0; i < mm1; ++i) diff[i] = com[i] = 0;
674 for (k = 0; k <
n; ++k) {
675 for (i = 0; i < mm; ++i) c[i] = a[k+i*200];
676 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
681 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
683 for (i = 0; i < mm1; ++i)
684 if ((z=
TMath::Abs(a[k+i*200])) > com[i]) com[i] =
z;
686 for (i = 1; i < mm; ++i)
687 for (jj = i; jj < mm; ++jj) {
689 c[j-2] = c[j-1]*z+c[j-2];
691 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
693 for (i = 0; i < mm1; ++i)
694 if (!(k >= n-2 && i != 0))
696 > diff[i]) diff[i] =
z;
699 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
700 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
702 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
705 for (i = 0; i < mm1; ++i)
printf(
"%16.8f",com[i]);
708 for (n = 10; n <= 100; n += 10) {
712 for (i = 0; i < nm1; i += 2) {
722 printf(
"\n-N = %3d M =%2d\n",n,m);
723 spline =
new TSpline3(
"Test",x,y,n);
724 for (i = 0; i <
n; ++i)
725 spline->
GetCoeff(i,hx,a[i],a[i+200],a[i+400],a[i+600]);
727 for (i = 0; i < mm1; ++i)
728 diff[i] = com[i] = 0;
729 for (k = 0; k <
n; ++k) {
730 for (i = 0; i < mm; ++i)
733 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
735 if (k == n-1)
printf(
"%16.8f\n",c[0]);
739 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
742 for (i = 0; i < mm1; ++i)
746 for (i = 1; i < mm; ++i)
747 for (jj = i; jj < mm; ++jj) {
749 c[j-2] = c[j-1]*z+c[j-2];
752 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
755 for (i = 0; i < mm1; ++i)
756 if (!(k >= n-2 && i != 0))
758 > diff[i]) diff[i] =
z;
760 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
761 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
763 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
766 for (i = 0; i < mm1; ++i)
printf(
"%16.8E",com[i]);
782 else if(x>=
fXmax) klow=khig;
791 else if (klow < khig) {
792 if (x >
fPoly[klow+1].
X()) ++klow;
799 if(x>
fPoly[khalf=(klow+khig)/2].
X())
807 "Binary search failed x(%d) = %f < x= %f < x(%d) = %f\n",
821 if (klow >=
fNp-1 &&
fNp > 1) klow =
fNp-2;
832 if (klow >=
fNp-1) klow =
fNp-2;
846 Error(
"SaveAs",
"Cannot open file:%s\n",filename);
852 Int_t nch = strlen(filename);
853 snprintf(buffer,512,
"double %s",filename);
854 char *
dot = strstr(buffer,
".");
856 strlcat(buffer,
"(double x) {\n",512);
857 nch = strlen(buffer); f->write(buffer,nch);
858 snprintf(buffer,512,
" const int fNp = %d, fKstep = %d;\n",
fNp,
fKstep);
859 nch = strlen(buffer); f->write(buffer,nch);
860 snprintf(buffer,512,
" const double fDelta = %g, fXmin = %g, fXmax = %g;\n",
fDelta,
fXmin,
fXmax);
861 nch = strlen(buffer); f->write(buffer,nch);
865 snprintf(buffer,512,
" const double fX[%d] = {",
fNp);
866 nch = strlen(buffer); f->write(buffer,nch);
870 for (i=0;i<
fNp;i++) {
871 snprintf(numb,20,
" %g,",
fPoly[i].
X());
873 if (i == fNp-1) numb[nch-1]=0;
874 strlcat(buffer,numb,512);
875 if (i%5 == 4 || i == fNp-1) {
876 nch = strlen(buffer); f->write(buffer,nch);
877 if (i != fNp-1) snprintf(buffer,512,
"\n ");
880 snprintf(buffer,512,
" };\n");
881 nch = strlen(buffer); f->write(buffer,nch);
883 snprintf(buffer,512,
" const double fY[%d] = {",fNp);
884 nch = strlen(buffer); f->write(buffer,nch);
886 for (i=0;i<
fNp;i++) {
887 snprintf(numb,20,
" %g,",
fPoly[i].
Y());
889 if (i == fNp-1) numb[nch-1]=0;
890 strlcat(buffer,numb,512);
891 if (i%5 == 4 || i == fNp-1) {
892 nch = strlen(buffer); f->write(buffer,nch);
893 if (i != fNp-1) snprintf(buffer,512,
"\n ");
896 snprintf(buffer,512,
" };\n");
897 nch = strlen(buffer); f->write(buffer,nch);
899 snprintf(buffer,512,
" const double fB[%d] = {",fNp);
900 nch = strlen(buffer); f->write(buffer,nch);
902 for (i=0;i<
fNp;i++) {
903 snprintf(numb,20,
" %g,",
fPoly[i].
B());
905 if (i == fNp-1) numb[nch-1]=0;
906 strlcat(buffer,numb,512);
907 if (i%5 == 4 || i == fNp-1) {
908 nch = strlen(buffer); f->write(buffer,nch);
909 if (i != fNp-1) snprintf(buffer,512,
"\n ");
912 snprintf(buffer,512,
" };\n");
913 nch = strlen(buffer); f->write(buffer,nch);
915 snprintf(buffer,512,
" const double fC[%d] = {",fNp);
916 nch = strlen(buffer); f->write(buffer,nch);
918 for (i=0;i<
fNp;i++) {
919 snprintf(numb,20,
" %g,",
fPoly[i].
C());
921 if (i == fNp-1) numb[nch-1]=0;
922 strlcat(buffer,numb,512);
923 if (i%5 == 4 || i == fNp-1) {
924 nch = strlen(buffer); f->write(buffer,nch);
925 if (i != fNp-1) snprintf(buffer,512,
"\n ");
928 snprintf(buffer,512,
" };\n");
929 nch = strlen(buffer); f->write(buffer,nch);
931 snprintf(buffer,512,
" const double fD[%d] = {",fNp);
932 nch = strlen(buffer); f->write(buffer,nch);
934 for (i=0;i<
fNp;i++) {
935 snprintf(numb,20,
" %g,",
fPoly[i].D());
937 if (i == fNp-1) numb[nch-1]=0;
938 strlcat(buffer,numb,512);
939 if (i%5 == 4 || i == fNp-1) {
940 nch = strlen(buffer); f->write(buffer,nch);
941 if (i != fNp-1) snprintf(buffer,512,
"\n ");
944 snprintf(buffer,512,
" };\n");
945 nch = strlen(buffer); f->write(buffer,nch);
948 snprintf(buffer,512,
" int klow=0;\n");
949 nch = strlen(buffer); f->write(buffer,nch);
951 snprintf(buffer,512,
" // If out of boundaries, extrapolate. It may be badly wrong\n");
952 snprintf(buffer,512,
" if(x<=fXmin) klow=0;\n");
953 nch = strlen(buffer); f->write(buffer,nch);
954 snprintf(buffer,512,
" else if(x>=fXmax) klow=fNp-1;\n");
955 nch = strlen(buffer); f->write(buffer,nch);
956 snprintf(buffer,512,
" else {\n");
957 nch = strlen(buffer); f->write(buffer,nch);
958 snprintf(buffer,512,
" if(fKstep) {\n");
959 nch = strlen(buffer); f->write(buffer,nch);
961 snprintf(buffer,512,
" // Equidistant knots, use histogramming\n");
962 nch = strlen(buffer); f->write(buffer,nch);
963 snprintf(buffer,512,
" klow = int((x-fXmin)/fDelta);\n");
964 nch = strlen(buffer); f->write(buffer,nch);
965 snprintf(buffer,512,
" if (klow < fNp-1) klow = fNp-1;\n");
966 nch = strlen(buffer); f->write(buffer,nch);
967 snprintf(buffer,512,
" } else {\n");
968 nch = strlen(buffer); f->write(buffer,nch);
969 snprintf(buffer,512,
" int khig=fNp-1, khalf;\n");
970 nch = strlen(buffer); f->write(buffer,nch);
972 snprintf(buffer,512,
" // Non equidistant knots, binary search\n");
973 nch = strlen(buffer); f->write(buffer,nch);
974 snprintf(buffer,512,
" while(khig-klow>1)\n");
975 nch = strlen(buffer); f->write(buffer,nch);
976 snprintf(buffer,512,
" if(x>fX[khalf=(klow+khig)/2]) klow=khalf;\n");
977 nch = strlen(buffer); f->write(buffer,nch);
978 snprintf(buffer,512,
" else khig=khalf;\n");
979 nch = strlen(buffer); f->write(buffer,nch);
980 snprintf(buffer,512,
" }\n");
981 nch = strlen(buffer); f->write(buffer,nch);
982 snprintf(buffer,512,
" }\n");
983 nch = strlen(buffer); f->write(buffer,nch);
984 snprintf(buffer,512,
" // Evaluate now\n");
985 nch = strlen(buffer); f->write(buffer,nch);
986 snprintf(buffer,512,
" double dx=x-fX[klow];\n");
987 nch = strlen(buffer); f->write(buffer,nch);
988 snprintf(buffer,512,
" return (fY[klow]+dx*(fB[klow]+dx*(fC[klow]+dx*fD[klow])));\n");
989 nch = strlen(buffer); f->write(buffer,nch);
994 if (f) { f->close();
delete f;}
1004 out<<
" "<<std::endl;
1010 out<<
"spline3 = new TSpline3("<<quote<<
GetTitle()<<quote<<
","
1011 <<
fXmin<<
","<<
fXmax<<
",(TF1*)0,"<<
fNp<<
","<<quote<<quote<<
","
1013 out<<
" spline3->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
1018 if (
fNpx != 100) out<<
" spline3->SetNpx("<<
fNpx<<
");"<<std::endl;
1021 out<<
" spline3->SetPoint("<<i<<
","<<
fPoly[i].
X()<<
","<<
fPoly[i].
Y()<<
");"<<std::endl;
1022 out<<
" spline3->SetPointCoeff("<<i<<
","<<
fPoly[i].
B()<<
","<<
fPoly[i].
C()<<
","<<
fPoly[i].
D()<<
");"<<std::endl;
1024 out<<
" spline3->Draw("<<quote<<option<<quote<<
");"<<std::endl;
1033 if (i < 0 || i >=
fNp)
return;
1043 if (i < 0 || i >=
fNp)
return;
1091 for (m=1; m<
fNp ; ++
m) {
1124 for (m=1; m<
l; ++
m) {
1148 g = -1./
fPoly[fNp-2].
D();
1157 g = -1./
fPoly[fNp-2].
D();
1166 g = -1./
fPoly[fNp-2].
D();
1179 g = -1./
fPoly[fNp-2].
D();
1193 for (i=1; i<
fNp; ++i) {
1197 fPoly[i-1].
C() = (divdf1 -
fPoly[i-1].
B() - divdf3)/dtau;
1198 fPoly[i-1].
D() = (divdf3/dtau)/dtau;
1206 void TSpline3::Streamer(
TBuffer &R__b)
1216 TSpline::Streamer(R__b);
1220 fPoly[i].Streamer(R__b);
1258 const char *cb1, *ce1, *cb2, *ce2;
1267 for (
Int_t i=0; i<
n; ++i) {
1293 const char *cb1, *ce1, *cb2, *ce2;
1302 for (
Int_t i=0; i<
n; ++i) {
1327 const char *cb1, *ce1, *cb2, *ce2;
1336 for (
Int_t i=0; i<
n; i++) {
1338 fPoly[i+beg].
Y() = ((
TF1*)func)->Eval(x[i]);
1362 const char *cb1, *ce1, *cb2, *ce2;
1371 for (
Int_t i=0; i<
n; ++i) {
1374 if (func)
fPoly[i+beg].
Y() = ((
TF1*)func)->Eval(x);
1398 const char *cb1, *ce1, *cb2, *ce2;
1433 const char *cb1, *ce1, *cb2, *ce2;
1493 const char *&cb1,
const char *&ce1,
1494 const char *&cb2,
const char *&ce2)
1499 cb1 = strstr(opt,
"b1");
1500 ce1 = strstr(opt,
"e1");
1501 cb2 = strstr(opt,
"b2");
1502 ce2 = strstr(opt,
"e2");
1525 const char *cb1,
const char *ce1,
const char *cb2,
1580 if(x<=
fXmin) klow=0;
1592 if(x>
fPoly[khalf=(klow+khig)/2].
X())
1601 "Binary search failed x(%d) = %f < x(%d) = %f\n",
1637 Error(
"SaveAs",
"Cannot open file:%s\n",filename);
1643 Int_t nch = strlen(filename);
1644 snprintf(buffer,512,
"double %s",filename);
1645 char *
dot = strstr(buffer,
".");
1647 strlcat(buffer,
"(double x) {\n",512);
1648 nch = strlen(buffer); f->write(buffer,nch);
1649 snprintf(buffer,512,
" const int fNp = %d, fKstep = %d;\n",
fNp,
fKstep);
1650 nch = strlen(buffer); f->write(buffer,nch);
1651 snprintf(buffer,512,
" const double fDelta = %g, fXmin = %g, fXmax = %g;\n",
fDelta,
fXmin,
fXmax);
1652 nch = strlen(buffer); f->write(buffer,nch);
1656 snprintf(buffer,512,
" const double fX[%d] = {",
fNp);
1657 nch = strlen(buffer); f->write(buffer,nch);
1661 for (i=0;i<
fNp;i++) {
1662 snprintf(numb,20,
" %g,",
fPoly[i].
X());
1664 if (i == fNp-1) numb[nch-1]=0;
1665 strlcat(buffer,numb,512);
1666 if (i%5 == 4 || i == fNp-1) {
1667 nch = strlen(buffer); f->write(buffer,nch);
1668 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1671 snprintf(buffer,512,
" };\n");
1672 nch = strlen(buffer); f->write(buffer,nch);
1674 snprintf(buffer,512,
" const double fY[%d] = {",fNp);
1675 nch = strlen(buffer); f->write(buffer,nch);
1677 for (i=0;i<
fNp;i++) {
1678 snprintf(numb,20,
" %g,",
fPoly[i].
Y());
1680 if (i == fNp-1) numb[nch-1]=0;
1681 strlcat(buffer,numb,512);
1682 if (i%5 == 4 || i == fNp-1) {
1683 nch = strlen(buffer); f->write(buffer,nch);
1684 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1687 snprintf(buffer,512,
" };\n");
1688 nch = strlen(buffer); f->write(buffer,nch);
1690 snprintf(buffer,512,
" const double fB[%d] = {",fNp);
1691 nch = strlen(buffer); f->write(buffer,nch);
1693 for (i=0;i<
fNp;i++) {
1694 snprintf(numb,20,
" %g,",
fPoly[i].
B());
1696 if (i == fNp-1) numb[nch-1]=0;
1697 strlcat(buffer,numb,512);
1698 if (i%5 == 4 || i == fNp-1) {
1699 nch = strlen(buffer); f->write(buffer,nch);
1700 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1703 snprintf(buffer,512,
" };\n");
1704 nch = strlen(buffer); f->write(buffer,nch);
1706 snprintf(buffer,512,
" const double fC[%d] = {",fNp);
1707 nch = strlen(buffer); f->write(buffer,nch);
1709 for (i=0;i<
fNp;i++) {
1710 snprintf(numb,20,
" %g,",
fPoly[i].
C());
1712 if (i == fNp-1) numb[nch-1]=0;
1713 strlcat(buffer,numb,512);
1714 if (i%5 == 4 || i == fNp-1) {
1715 nch = strlen(buffer); f->write(buffer,nch);
1716 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1719 snprintf(buffer,512,
" };\n");
1720 nch = strlen(buffer); f->write(buffer,nch);
1722 snprintf(buffer,512,
" const double fD[%d] = {",fNp);
1723 nch = strlen(buffer); f->write(buffer,nch);
1725 for (i=0;i<
fNp;i++) {
1726 snprintf(numb,20,
" %g,",
fPoly[i].D());
1728 if (i == fNp-1) numb[nch-1]=0;
1729 strlcat(buffer,numb,512);
1730 if (i%5 == 4 || i == fNp-1) {
1731 nch = strlen(buffer); f->write(buffer,nch);
1732 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1735 snprintf(buffer,512,
" };\n");
1736 nch = strlen(buffer); f->write(buffer,nch);
1738 snprintf(buffer,512,
" const double fE[%d] = {",fNp);
1739 nch = strlen(buffer); f->write(buffer,nch);
1741 for (i=0;i<
fNp;i++) {
1742 snprintf(numb,20,
" %g,",
fPoly[i].
E());
1744 if (i == fNp-1) numb[nch-1]=0;
1745 strlcat(buffer,numb,512);
1746 if (i%5 == 4 || i == fNp-1) {
1747 nch = strlen(buffer); f->write(buffer,nch);
1748 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1751 snprintf(buffer,512,
" };\n");
1752 nch = strlen(buffer); f->write(buffer,nch);
1754 snprintf(buffer,512,
" const double fF[%d] = {",fNp);
1755 nch = strlen(buffer); f->write(buffer,nch);
1757 for (i=0;i<
fNp;i++) {
1758 snprintf(numb,20,
" %g,",
fPoly[i].
F());
1760 if (i == fNp-1) numb[nch-1]=0;
1761 strlcat(buffer,numb,512);
1762 if (i%5 == 4 || i == fNp-1) {
1763 nch = strlen(buffer); f->write(buffer,nch);
1764 if (i != fNp-1) snprintf(buffer,512,
"\n ");
1767 snprintf(buffer,512,
" };\n");
1768 nch = strlen(buffer); f->write(buffer,nch);
1771 snprintf(buffer,512,
" int klow=0;\n");
1772 nch = strlen(buffer); f->write(buffer,nch);
1774 snprintf(buffer,512,
" // If out of boundaries, extrapolate. It may be badly wrong\n");
1775 snprintf(buffer,512,
" if(x<=fXmin) klow=0;\n");
1776 nch = strlen(buffer); f->write(buffer,nch);
1777 snprintf(buffer,512,
" else if(x>=fXmax) klow=fNp-1;\n");
1778 nch = strlen(buffer); f->write(buffer,nch);
1779 snprintf(buffer,512,
" else {\n");
1780 nch = strlen(buffer); f->write(buffer,nch);
1781 snprintf(buffer,512,
" if(fKstep) {\n");
1782 nch = strlen(buffer); f->write(buffer,nch);
1784 snprintf(buffer,512,
" // Equidistant knots, use histogramming\n");
1785 nch = strlen(buffer); f->write(buffer,nch);
1786 snprintf(buffer,512,
" klow = int((x-fXmin)/fDelta);\n");
1787 nch = strlen(buffer); f->write(buffer,nch);
1788 snprintf(buffer,512,
" if (klow < fNp-1) klow = fNp-1;\n");
1789 nch = strlen(buffer); f->write(buffer,nch);
1790 snprintf(buffer,512,
" } else {\n");
1791 nch = strlen(buffer); f->write(buffer,nch);
1792 snprintf(buffer,512,
" int khig=fNp-1, khalf;\n");
1793 nch = strlen(buffer); f->write(buffer,nch);
1795 snprintf(buffer,512,
" // Non equidistant knots, binary search\n");
1796 nch = strlen(buffer); f->write(buffer,nch);
1797 snprintf(buffer,512,
" while(khig-klow>1)\n");
1798 nch = strlen(buffer); f->write(buffer,nch);
1799 snprintf(buffer,512,
" if(x>fX[khalf=(klow+khig)/2]) klow=khalf;\n");
1800 nch = strlen(buffer); f->write(buffer,nch);
1801 snprintf(buffer,512,
" else khig=khalf;\n");
1802 nch = strlen(buffer); f->write(buffer,nch);
1803 snprintf(buffer,512,
" }\n");
1804 nch = strlen(buffer); f->write(buffer,nch);
1805 snprintf(buffer,512,
" }\n");
1806 nch = strlen(buffer); f->write(buffer,nch);
1807 snprintf(buffer,512,
" // Evaluate now\n");
1808 nch = strlen(buffer); f->write(buffer,nch);
1809 snprintf(buffer,512,
" double dx=x-fX[klow];\n");
1810 nch = strlen(buffer); f->write(buffer,nch);
1811 snprintf(buffer,512,
" return (fY[klow]+dx*(fB[klow]+dx*(fC[klow]+dx*(fD[klow]+dx*(fE[klow]+dx*fF[klow])))));\n");
1812 nch = strlen(buffer); f->write(buffer,nch);
1817 if (f) { f->close();
delete f;}
1827 out<<
" "<<std::endl;
1837 out<<
"spline5 = new TSpline5("<<quote<<
GetTitle()<<quote<<
","
1838 <<
fXmin<<
","<<
fXmax<<
",(TF1*)0,"<<
fNp<<
","<<quote<<quote<<
","
1839 <<b1<<
","<<e1<<
","<<b2<<
","<<e2<<
");"<<std::endl;
1840 out<<
" spline5->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
1845 if (
fNpx != 100) out<<
" spline5->SetNpx("<<
fNpx<<
");"<<std::endl;
1848 out<<
" spline5->SetPoint("<<i<<
","<<
fPoly[i].
X()<<
","<<
fPoly[i].
Y()<<
");"<<std::endl;
1849 out<<
" spline5->SetPointCoeff("<<i<<
","<<
fPoly[i].
B()<<
","<<
fPoly[i].
C()<<
","<<
fPoly[i].
D()<<
","<<
fPoly[i].
E()<<
","<<
fPoly[i].
F()<<
");"<<std::endl;
1851 out<<
" spline5->Draw("<<quote<<option<<quote<<
");"<<std::endl;
1861 if (i < 0 || i >=
fNp)
return;
1872 if (i < 0 || i >=
fNp)
return;
1952 b1,
p2,
p3, q2, q3,
r2, pq, pr, qr;
1967 if (q)
fPoly[1].
D() = q*6.*q2/(qr*qr);
1971 for (i = 1; i <
m; ++i) {
1984 fPoly[i+1].
D() = q3*6./(qr*qr);
1985 fPoly[i].
D() += (q+
q)*(pr*15.*pr+(p+r)*q
1986 *(pr* 20.+q2*7.)+q2*
1987 ((p2+
r2)*8.+pr*21.+q2+q2))/(pqqr*pqqr);
1988 fPoly[i-1].
D() += q3*6./(pq*pq);
1989 fPoly[i].
E() = q2*(p*qr+pq*3.*(qr+r+
r))/(pqqr*qr);
1990 fPoly[i-1].
E() += q2*(r*pq+qr*3.*(pq+p+p))/(pqqr*pq);
1991 fPoly[i-1].
F() = q3/pqqr;
1996 if (r)
fPoly[m-1].
D() += r*6.*r2/(qr*qr);
2001 for (i = 1; i <
fNp; ++i) {
2010 for (i = 2; i <
fNp; ++i) {
2028 for (i = 2; i <
m; ++i) {
2041 for (i=fNp-3; i > 0; --i)
2059 for (i = 1; i <
m; ++i) {
2080 p3-(v+
fPoly[i].
E())*q3)/pq;
2138 printf(
"1 TEST OF TSpline5 WITH NONEQUIDISTANT KNOTS\n");
2153 printf(
"\n-N = %3d M =%2d\n",n,m);
2155 for (i = 0; i <
n; ++i)
2156 spline->
GetCoeff(i,hx, a[i],a[i+200],a[i+400],
2157 a[i+600],a[i+800],a[i+1000]);
2159 for (i = 0; i < mm1; ++i) diff[i] = com[i] = 0;
2160 for (k = 0; k <
n; ++k) {
2161 for (i = 0; i < mm; ++i) c[i] = a[k+i*200];
2162 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
2167 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2169 for (i = 0; i < mm1; ++i)
2170 if ((z=
TMath::Abs(a[k+i*200])) > com[i]) com[i] =
z;
2172 for (i = 1; i < mm; ++i)
2173 for (jj = i; jj < mm; ++jj) {
2175 c[j-2] = c[j-1]*z+c[j-2];
2177 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2179 for (i = 0; i < mm1; ++i)
2180 if (!(k >= n-2 && i != 0))
2182 > diff[i]) diff[i] =
z;
2185 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
2186 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
2188 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
2191 for (i = 0; i < mm1; ++i)
printf(
"%16.8f",com[i]);
2194 for (n = 10; n <= 100; n += 10) {
2198 for (i = 0; i < nm1; i += 2) {
2208 printf(
"\n-N = %3d M =%2d\n",n,m);
2209 spline =
new TSpline5(
"Test",x,y,n);
2210 for (i = 0; i <
n; ++i)
2211 spline->
GetCoeff(i,hx,a[i],a[i+200],a[i+400],
2212 a[i+600],a[i+800],a[i+1000]);
2214 for (i = 0; i < mm1; ++i)
2215 diff[i] = com[i] = 0;
2216 for (k = 0; k <
n; ++k) {
2217 for (i = 0; i < mm; ++i)
2220 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
2222 if (k == n-1)
printf(
"%16.8f\n",c[0]);
2224 if (k == n-1)
break;
2226 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2229 for (i = 0; i < mm1; ++i)
2233 for (i = 1; i < mm; ++i)
2234 for (jj = i; jj < mm; ++jj) {
2236 c[j-2] = c[j-1]*z+c[j-2];
2239 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2242 for (i = 0; i < mm1; ++i)
2243 if (!(k >= n-2 && i != 0))
2245 > diff[i]) diff[i] =
z;
2247 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
2248 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
2250 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
2253 for (i = 0; i < mm1; ++i)
printf(
"%16.8E",com[i]);
2258 printf(
"1 TEST OF TSpline5 WITH NONEQUIDISTANT DOUBLE KNOTS\n");
2284 printf(
"-N = %3d M =%2d\n",n,m);
2285 spline =
new TSpline5(
"Test",x,y,nn);
2286 for (i = 0; i < nn; ++i)
2287 spline->
GetCoeff(i,hx,a[i],a[i+200],a[i+400],
2288 a[i+600],a[i+800],a[i+1000]);
2290 for (i = 0; i < mm1; ++i)
2291 diff[i] = com[i] = 0;
2292 for (k = 0; k < nn; ++k) {
2293 for (i = 0; i < mm; ++i)
2295 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
2301 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2303 for (i = 0; i < mm1; ++i)
2304 if ((z=
TMath::Abs(a[k+i*200])) > com[i]) com[i] =
z;
2306 for (i = 1; i < mm; ++i)
2307 for (jj = i; jj < mm; ++jj) {
2309 c[j-2] = c[j-1]*z+c[j-2];
2311 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2313 for (i = 0; i < mm1; ++i)
2314 if (!(k >= nn-2 && i != 0))
2316 > diff[i]) diff[i] =
z;
2318 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
2319 for (i = 1; i <= mm1; ++i) {
2320 printf(
"%18.9E",diff[i-1]);
2325 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
2326 for (i = 0; i < mm1; ++i)
printf(
"%16.8f",com[i]);
2329 for (n = 10; n <= 100; n += 10) {
2334 for (i = 0; i <
n; ++i) {
2341 printf(
"-N = %3d M =%2d\n",n,m);
2342 spline =
new TSpline5(
"Test",x,y,nn);
2343 for (i = 0; i < nn; ++i)
2344 spline->
GetCoeff(i,hx,a[i],a[i+200],a[i+400],
2345 a[i+600],a[i+800],a[i+1000]);
2347 for (i = 0; i < mm1; ++i)
2348 diff[i] = com[i] = 0;
2349 for (k = 0; k < nn; ++k) {
2350 for (i = 0; i < mm; ++i)
2353 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
2355 if (k == nn-1)
printf(
"%16.8f\n",c[0]);
2357 if (k == nn-1)
break;
2359 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2362 for (i = 0; i < mm1; ++i)
2363 if ((z=
TMath::Abs(a[k+i*200])) > com[i]) com[i] =
z;
2365 for (i = 1; i < mm; ++i) {
2366 for (jj = i; jj < mm; ++jj) {
2368 c[j-2] = c[j-1]*z+c[j-2];
2372 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2375 for (i = 0; i < mm1; ++i)
2376 if (!(k >= nn-2 && i != 0))
2378 > diff[i]) diff[i] =
z;
2380 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
2381 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
2383 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
2386 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",com[i]);
2392 printf(
"1 TEST OF TSpline5 WITH NONEQUIDISTANT KNOTS,\n");
2393 printf(
" ONE DOUBLE, ONE TRIPLE KNOT\n");
2414 printf(
"-N = %3d M =%2d\n",n,m);
2416 for (i = 0; i <
n; ++i)
2417 spline->
GetCoeff(i,hx,a[i],a[i+200],a[i+400],
2418 a[i+600],a[i+800],a[i+1000]);
2420 for (i = 0; i < mm1; ++i)
2421 diff[i] = com[i] = 0;
2422 for (k = 0; k <
n; ++k) {
2423 for (i = 0; i < mm; ++i)
2425 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
2431 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2433 for (i = 0; i < mm1; ++i)
2434 if ((z=
TMath::Abs(a[k+i*200])) > com[i]) com[i] =
z;
2436 for (i = 1; i < mm; ++i)
2437 for (jj = i; jj < mm; ++jj) {
2439 c[j-2] = c[j-1]*z+c[j-2];
2441 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2443 for (i = 0; i < mm1; ++i)
2444 if (!(k >= n-2 && i != 0))
2446 > diff[i]) diff[i] =
z;
2448 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
2449 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
2451 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
2454 for (i = 0; i < mm1; ++i)
printf(
"%16.8f",com[i]);
2459 printf(
"1 TEST OF TSpline5 WITH NONEQUIDISTANT KNOTS,\n");
2460 printf(
" TWO DOUBLE, ONE TRIPLE KNOT\n");
2485 printf(
"-N = %3d M =%2d\n",n,m);
2486 spline =
new TSpline5(
"Test",x,y,n);
2487 for (i = 0; i <
n; ++i)
2488 spline->
GetCoeff(i,hx,a[i],a[i+200],a[i+400],
2489 a[i+600],a[i+800],a[i+1000]);
2491 for (i = 0; i < mm1; ++i)
2492 diff[i] = com[i] = 0;
2493 for (k = 0; k <
n; ++k) {
2494 for (i = 0; i < mm; ++i)
2496 printf(
" ---------------------------------------%3d --------------------------------------------\n",k+1);
2502 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2504 for (i = 0; i < mm1; ++i)
2505 if ((z=
TMath::Abs(a[k+i*200])) > com[i]) com[i] =
z;
2507 for (i = 1; i < mm; ++i)
2508 for (jj = i; jj < mm; ++jj) {
2510 c[j-2] = c[j-1]*z+c[j-2];
2512 for (i = 0; i < mm; ++i)
printf(
"%16.8f",c[i]);
2514 for (i = 0; i < mm1; ++i)
2515 if (!(k >= n-2 && i != 0))
2517 > diff[i]) diff[i] =
z;
2519 printf(
" MAXIMUM ABSOLUTE VALUES OF DIFFERENCES \n");
2520 for (i = 0; i < mm1; ++i)
printf(
"%18.9E",diff[i]);
2522 printf(
" MAXIMUM ABSOLUTE VALUES OF COEFFICIENTS \n");
2525 for (i = 0; i < mm1; ++i)
printf(
"%16.8f",com[i]);
2533 void TSpline5::Streamer(
TBuffer &R__b)
2543 TSpline::Streamer(R__b);
2547 fPoly[i].Streamer(R__b);
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
set point number i.
virtual const char * GetTitle() const
Returns title of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Style_t GetLineStyle() const
virtual Style_t GetFillStyle() const
virtual void SetLineWidth(Width_t lwidth)
TSplinePoly3 & operator=(TSplinePoly3 const &other)
assignment operator
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
TSplinePoly & operator=(TSplinePoly const &other)
assignment operator
static void Test()
Test method for TSpline5.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
static double p3(double t, double a, double b, double c, double d)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual void SetLimits(Double_t xmin, Double_t xmax)
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a spline.
Double_t Eval(Double_t x) const
void BoundaryConditions(const char *opt, Int_t &beg, Int_t &end, const char *&cb1, const char *&ce1, const char *&cb2, const char *&ce2)
Check the boundary conditions and the amount of extra double knots needed.
Base class for spline implementation containing the Draw/Paint methods //.
Double_t Eval(Double_t x) const
Eval this spline at x.
Buffer base class used for serializing objects.
Double_t Derivative(Double_t x) const
void CopyPoly(TSplinePoly3 const &other)
utility called by the copy constructors and = operator
static const char * filename()
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
1-D histogram with a float per channel (see TH1 documentation)}
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual void SetFillStyle(Style_t fstyle)
Int_t FindX(Double_t x) const
Find X.
Int_t FloorNint(Double_t x)
static void Test()
Test method for TSpline5.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
const char * Data() const
Double_t dot(const TVector2 &v1, const TVector2 &v2)
Fill Area Attributes class.
virtual void Paint(Option_t *chopt="")
Draw this graph with its current attributes.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
The TNamed class is the base class for all named ROOT classes.
Double_t Eval(Double_t x) const
Eval this spline at x.
Double_t Log10(Double_t x)
static double p2(double t, double a, double b, double c)
void CopyPoly(TSplinePoly const &other)
utility called by the copy constructors and = operator
virtual void SetMarkerColor(Color_t mcolor=1)
TSpline & operator=(const TSpline &)
assignment operator
TObject & operator=(const TObject &rhs)
TObject assignment operator.
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
ClassImp(TSplinePoly) ClassImp(TSplinePoly3) ClassImp(TSplinePoly5) ClassImp(TSpline3) ClassImp(TSpline5) ClassImp(TSpline) TSpline
copy constructor
TSpline5 & operator=(const TSpline5 &)
assignment operator
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
virtual void SetLineColor(Color_t lcolor)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
TSplinePoly5 & operator=(TSplinePoly5 const &other)
assignment operator
Double_t Derivative(Double_t x) const
Derivative.
virtual Double_t GetBinCenter(Int_t bin) const
return bin center for 1D historam Better to use h1.GetXaxis().GetBinCenter(bin)
virtual Size_t GetMarkerSize() const
Double_t Derivative(Double_t x) const
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
R__EXTERN TSystem * gSystem
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
Int_t FindX(Double_t x) const
Find X.
void SetCond(const char *opt)
Check the boundary conditions.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Color_t GetFillColor() const
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Bool_t TestBit(UInt_t f) const
virtual void SetPointCoeff(Int_t i, Double_t b, Double_t c, Double_t d)
set point coefficient number i
virtual const char * GetName() const
Returns name of object.
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual Double_t Eval(Double_t x) const =0
void BuildCoeff()
subroutine cubspl ( tau, c, n, ibcbeg, ibcend ) from * a practical guide to splines * by c...
virtual Color_t GetLineColor() const
TSpline3 & operator=(const TSpline3 &)
assignment operator
virtual void SetMarkerSize(Size_t msize=1)
void SetBoundaries(Double_t b1, Double_t e1, Double_t b2, Double_t e2, const char *cb1, const char *ce1, const char *cb2, const char *ce2)
Set the boundary conditions at double/triple knots.
virtual void GetKnot(Int_t i, Double_t &x, Double_t &y) const =0
virtual ~TSpline()
destructor
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
set point number i.
virtual void SaveAs(const char *filename, Option_t *option="") const
write this spline as a C++ function that can be executed without ROOT the name of the function is the...
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Double_t Eval(Double_t x) const
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
double func(double *x, double *p)
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
virtual void SetPointCoeff(Int_t i, Double_t b, Double_t c, Double_t d, Double_t e, Double_t f)
set point coefficient number i
virtual void SetLineStyle(Style_t lstyle)
Binding & operator=(OUT(*fun)(void))
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
void GetCoeff(Int_t i, Double_t &x, Double_t &y, Double_t &b, Double_t &c, Double_t &d, Double_t &e, Double_t &f)
void GetCoeff(Int_t i, Double_t &x, Double_t &y, Double_t &b, Double_t &c, Double_t &d)
virtual Color_t GetMarkerColor() const
void BuildCoeff()
algorithm 600, collected algorithms from acm.
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual void Paint(Option_t *option="")
Paint this function with its current attributes.
virtual void SaveAs(const char *filename, Option_t *option="") const
write this spline as a C++ function that can be executed without ROOT the name of the function is the...
void CopyPoly(TSplinePoly5 const &other)
utility called by the copy constructors and = operator
virtual Style_t GetMarkerStyle() const
virtual Width_t GetLineWidth() const
unsigned int r2[N_CITIES]
Double_t Derivative(Double_t x) const
Derivative.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0