24 if (hasValues && !doErrors)
27 double F0, F1, F2, F3, F4, F0y, F1y, F2y;
28 F0 = F1 = F2 = F3 = F4 = F0y = F1y = F2y = 0.;
30 typedef vector<Point>::const_iterator
IT;
31 for (IT ip = points.begin(); ip != points.end(); ip++) {
53 Column cY = {F0y, F1y, F2y};
55 double det0 = det(cA, cB, cC);
58 theResult.parA = det(cY, cB, cC) / det0;
59 theResult.parB = det(cA, cY, cC) / det0;
60 theResult.parC = det(cA, cB, cY) / det0;
62 Column cCY = {F0y - theResult.parC * F2, F1y - theResult.parC * F3, F2y - theResult.parC * F4};
63 double det0C = det(cA, cB);
64 theResult.parA = det(cCY, cB) / det0C;
65 theResult.parB = det(cA, cCY) / det0C;
69 double vAA, vBB, vCC, vAB, vAC, vBC;
70 vAA = vBB = vCC = vAB = vAC = vBC = 0.;
76 if (!hasWeights &&
dof() > 0) {
78 double scale_w = 1. /
chi2() /
dof();
79 for (IT ip = points.begin(); ip != points.end(); ip++)
84 for (IT ip = points.begin(); ip != points.end(); ip++) {
88 double dXBC = det(cX, cB, cC);
89 double dAXC = det(cA, cX, cC);
90 double dABX = det(cA, cB, cX);
95 vAB += w * dXBC * dAXC;
96 vAC += w * dXBC * dABX;
97 vBC += w * dAXC * dABX;
100 theResult.varAA = vAA /
sqr(det0);
101 theResult.varBB = vBB /
sqr(det0);
102 theResult.varCC = vCC /
sqr(det0);
103 theResult.varAB = vAB /
sqr(det0);
104 theResult.varAC = vAC /
sqr(det0);
105 theResult.varBC = vBC /
sqr(det0);
113 for (vector<Point>::const_iterator ip = points.begin(); ip != points.end(); ip++) {
114 mychi2 += ip->w *
sqr(ip->y - fun(ip->x));
119 double ParabolaFit::fun(
double x)
const {
return theResult.parA + theResult.parB * x + theResult.parC * x * x; }
125 int nDof = points.size() - nPar;
126 return (nDof > 0) ? nDof : 0;
const Result & result(bool doErrors) const
double det(const Column &c1, const Column &c2, const Column &c3) const
void addPoint(double x, double y)
std::vector< LinkConnSpec >::const_iterator IT
double fun(double x) const
Power< A, B >::type pow(const A &a, const B &b)