/src/tesseract/src/ccstruct/quadlsq.h
Line | Count | Source (jump to first uncovered line) |
1 | | /********************************************************************** |
2 | | * File: quadlsq.h (Formerly qlsq.h) |
3 | | * Description: Code for least squares approximation of quadratics. |
4 | | * Author: Ray Smith |
5 | | * |
6 | | * (C) Copyright 1993, Hewlett-Packard Ltd. |
7 | | ** Licensed under the Apache License, Version 2.0 (the "License"); |
8 | | ** you may not use this file except in compliance with the License. |
9 | | ** You may obtain a copy of the License at |
10 | | ** http://www.apache.org/licenses/LICENSE-2.0 |
11 | | ** Unless required by applicable law or agreed to in writing, software |
12 | | ** distributed under the License is distributed on an "AS IS" BASIS, |
13 | | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | ** See the License for the specific language governing permissions and |
15 | | ** limitations under the License. |
16 | | * |
17 | | **********************************************************************/ |
18 | | |
19 | | #ifndef QUADLSQ_H |
20 | | #define QUADLSQ_H |
21 | | |
22 | | #include "points.h" |
23 | | |
24 | | namespace tesseract { |
25 | | |
26 | | class QLSQ { |
27 | | public: |
28 | 318k | QLSQ() { // constructor |
29 | 318k | clear(); // set to zeros |
30 | 318k | } |
31 | | void clear(); // initialize |
32 | | |
33 | | void add( // add element |
34 | | double x, // coords to add |
35 | | double y); |
36 | | void remove( // delete element |
37 | | double x, // coords to delete |
38 | | double y); |
39 | 0 | int32_t count() { // no of elements |
40 | 0 | return n; |
41 | 0 | } |
42 | | |
43 | | void fit( // fit the given |
44 | | int degree); // return actual |
45 | 287k | double get_a() const { // get x squard |
46 | 287k | return a; |
47 | 287k | } |
48 | 311k | double get_b() const { // get x squard |
49 | 311k | return b; |
50 | 311k | } |
51 | 311k | double get_c() const { // get x squard |
52 | 311k | return c; |
53 | 311k | } |
54 | | |
55 | | private: |
56 | | int32_t n; // no of elements |
57 | | double a, b, c; // result |
58 | | double sigx; // sum of x |
59 | | double sigy; // sum of y |
60 | | double sigxx; // sum x squared |
61 | | double sigxy; // sum of xy |
62 | | double sigyy; // sum y squared |
63 | | long double sigxxx; // sum x cubed |
64 | | long double sigxxy; // sum xsquared y |
65 | | long double sigxxxx; // sum x fourth |
66 | | }; |
67 | | |
68 | | } // namespace tesseract |
69 | | |
70 | | #endif |