Tesseract  3.02
tesseract-ocr/ccstruct/quadlsq.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        quadlsq.h  (Formerly qlsq.h)
00003  * Description: Code for least squares approximation of quadratics.
00004  * Author:              Ray Smith
00005  * Created:             Wed Oct  6 15:14:23 BST 1993
00006  *
00007  * (C) Copyright 1993, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef           QUADLSQ_H
00021 #define           QUADLSQ_H
00022 
00023 #include          "points.h"
00024 
00025 class QLSQ
00026 {
00027   public:
00028     QLSQ() {  //constructor
00029       clear();  //set to zeros
00030     }
00031     void clear();  //initialize
00032 
00033     void add(           //add element
00034              double x,  //coords to add
00035              double y);
00036     void remove(           //delete element
00037                 double x,  //coords to delete
00038                 double y);
00039     inT32 count() {  //no of elements
00040       return n;
00041     }
00042 
00043     void fit(              //fit the given
00044              int degree);  //return actual
00045     double get_a() {  //get x squard
00046       return a;
00047     }
00048     double get_b() {  //get x squard
00049       return b;
00050     }
00051     double get_c() {  //get x squard
00052       return c;
00053     }
00054 
00055   private:
00056     inT32 n;                     //no of elements
00057     double a, b, c;              //result
00058     double sigx;                 //sum of x
00059     double sigy;                 //sum of y
00060     double sigxx;                //sum x squared
00061     double sigxy;                //sum of xy
00062     double sigyy;                //sum y squared
00063     long double sigxxx;          //sum x cubed
00064     long double sigxxy;          //sum xsquared y
00065     long double sigxxxx;         //sum x fourth
00066 };
00067 #endif