#include <quadlsq.h>
Definition at line 29 of file quadlsq.h.
QLSQ::QLSQ | ( | ) | [inline] |
void QLSQ::add | ( | double | x, | |
double | y | |||
) |
Add an element to the accumulator.
Definition at line 52 of file quadlsq.cpp.
References n, sigx, sigxx, sigxxx, sigxxxx, sigxxy, sigxy, sigy, and sigyy.
Referenced by merge_oldbl_parts(), and QSPLINE::QSPLINE().
00055 { 00056 n++; //count elements 00057 sigx += x; //update accumulators 00058 sigy += y; 00059 sigxx += x * x; 00060 sigxy += x * y; 00061 sigyy += y * y; 00062 sigxxx += (long double) x *x * x; 00063 sigxxy += (long double) x *x * y; 00064 sigxxxx += (long double) x *x * x * x; 00065 }
void QLSQ::clear | ( | ) |
Function to initialize a QLSQ.
Definition at line 33 of file quadlsq.cpp.
References a, b, c, n, sigx, sigxx, sigxxx, sigxxxx, sigxxy, sigxy, sigy, and sigyy.
Referenced by merge_oldbl_parts(), QLSQ(), and QSPLINE::QSPLINE().
00033 { //initialize 00034 a = 0; 00035 b = 0; 00036 c = 0; 00037 n = 0; //no elements 00038 sigx = 0; //update accumulators 00039 sigy = 0; 00040 sigxx = 0; 00041 sigxy = 0; 00042 sigyy = 0; 00043 sigxxx = 0; 00044 sigxxy = 0; 00045 sigxxxx = 0; 00046 }
INT32 QLSQ::count | ( | ) | [inline] |
void QLSQ::fit | ( | int | degree | ) |
Fit the given degree of polynomial and store the result.
Definition at line 93 of file quadlsq.cpp.
References a, b, c, n, sigx, sigxx, sigxxx, sigxxxx, sigxxy, sigxy, and sigy.
Referenced by merge_oldbl_parts(), and QSPLINE::QSPLINE().
00095 { 00096 long double cubetemp; //intermediates 00097 long double squaretemp; 00098 long double top96, bottom96; /*accurate top & bottom */ 00099 00100 if (n >= 4 && degree >= 2) { 00101 cubetemp = sigxxx * n - (long double) sigxx *sigx; 00102 00103 top96 = 00104 cubetemp * ((long double) sigxy * n - (long double) sigx * sigy); 00105 00106 squaretemp = (long double) sigxx *n - (long double) sigx *sigx; 00107 00108 top96 += squaretemp * ((long double) sigxx * sigy - sigxxy * n); 00109 00110 bottom96 = cubetemp * cubetemp; 00111 00112 bottom96 -= squaretemp * (sigxxxx * n - (long double) sigxx * sigxx); 00113 00114 a = top96 / bottom96; 00115 00116 top96 = ((long double) sigxx * sigx - sigxxx * n) * a 00117 + (long double) sigxy *n - (long double) sigx *sigy; 00118 bottom96 = (long double) sigxx *n - (long double) sigx *sigx; 00119 b = top96 / bottom96; 00120 00121 c = (sigy - a * sigxx - b * sigx) / n; 00122 } 00123 else if (n == 0 || degree < 0) { 00124 a = b = c = 0; 00125 } 00126 else { 00127 a = 0; 00128 if (n > 1 && degree > 0) { 00129 b = (sigxy * n - sigx * sigy) / (sigxx * n - sigx * sigx); 00130 } 00131 else 00132 b = 0; 00133 c = (sigy - b * sigx) / n; 00134 } 00135 }
double QLSQ::get_a | ( | ) | [inline] |
Definition at line 49 of file quadlsq.h.
References a.
Referenced by QSPLINE::QSPLINE().
00049 { //get x squard 00050 return a; 00051 }
double QLSQ::get_b | ( | ) | [inline] |
Definition at line 52 of file quadlsq.h.
References b.
Referenced by merge_oldbl_parts(), and QSPLINE::QSPLINE().
00052 { //get x squard 00053 return b; 00054 }
double QLSQ::get_c | ( | ) | [inline] |
Definition at line 55 of file quadlsq.h.
References c.
Referenced by merge_oldbl_parts(), and QSPLINE::QSPLINE().
00055 { //get x squard 00056 return c; 00057 }
void QLSQ::remove | ( | double | x, | |
double | y | |||
) |
Delete an element from the acculuator.
Definition at line 71 of file quadlsq.cpp.
References ABORT, EMPTY_QLSQ, ERRCODE::error(), n, NULL, sigx, sigxx, sigxxx, sigxxxx, sigxxy, sigxy, sigy, and sigyy.
00074 { 00075 if (n <= 0) 00076 //illegal 00077 EMPTY_QLSQ.error ("QLSQ::remove", ABORT, NULL); 00078 n--; //count elements 00079 sigx -= x; //update accumulators 00080 sigy -= y; 00081 sigxx -= x * x; 00082 sigxy -= x * y; 00083 sigyy -= y * y; 00084 sigxxx -= (long double) x *x * x; 00085 sigxxy -= (long double) x *x * y; 00086 sigxxxx -= (long double) x *x * x * x; 00087 }
double QLSQ::a [private] |
double QLSQ::b [private] |
double QLSQ::c [private] |
double QLSQ::sigx [private] |
double QLSQ::sigxx [private] |
long double QLSQ::sigxxx [private] |
long double QLSQ::sigxxxx [private] |
long double QLSQ::sigxxy [private] |
double QLSQ::sigxy [private] |
double QLSQ::sigy [private] |
double QLSQ::sigyy [private] |