00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef LMEDSQ_H
00021 #define LMEDSQ_H
00022
00023 #include "points.h"
00024 #include "varable.h"
00025 #include "scrollview.h"
00026 #include "notdll.h"
00027
00028 class LMS
00029 {
00030 public:
00031 LMS(
00032 inT32 size);
00033 ~LMS ();
00034 void clear();
00035 void add(
00036 FCOORD sample);
00037 void fit(
00038 float &m,
00039 float &c);
00040 void constrained_fit(
00041 float fixed_m,
00042 float &out_c);
00043 void fit_quadratic(
00044 float outlier_threshold,
00045 double &a,
00046 float &b,
00047 float &c);
00048 void plot(
00049 ScrollView* win,
00050 ScrollView::Color colour);
00051 float error() {
00052 return fitted ? line_error : -1;
00053 }
00054
00055 private:
00056
00057 void pick_line(
00058 float &m,
00059 float &c);
00060 void pick_quadratic(
00061 double &a,
00062 float &b,
00063 float &c);
00064 void compute_errors(
00065 float m,
00066 float c);
00067
00068 float compute_quadratic_errors(float outlier_threshold,
00069 double a,
00070 float m,
00071 float c);
00072
00073 BOOL8 fitted;
00074 inT32 samplesize;
00075 inT32 samplecount;
00076 FCOORD *samples;
00077 float *errors;
00078 double a;
00079 float m;
00080 float c;
00081 float line_error;
00082 };
00083 extern INT_VAR_H (lms_line_trials, 12, "Number of linew fits to do");
00084 #endif