#include <linlsq.h>
Definition at line 28 of file linlsq.h.
◆ LLSQ()
◆ add() [1/3]
void LLSQ::add |
( |
const LLSQ & |
other | ) |
|
Definition at line 66 of file linlsq.cpp.
66 {
67 total_weight += other.total_weight;
68 sigx += other.sigx;
69 sigy += other.sigy;
70 sigxx += other.sigxx;
71 sigxy += other.sigxy;
72 sigyy += other.sigyy;
73}
◆ add() [2/3]
void LLSQ::add |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Definition at line 48 of file linlsq.cpp.
48 {
49 total_weight++;
50 sigx += x;
51 sigy += y;
52 sigxx += x * x;
53 sigxy += x * y;
54 sigyy += y * y;
55}
◆ add() [3/3]
void LLSQ::add |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
weight |
|
) |
| |
Definition at line 57 of file linlsq.cpp.
57 {
58 total_weight += weight;
59 sigx += x * weight;
60 sigy += y * weight;
61 sigxx += x * x * weight;
62 sigxy += x * y * weight;
63 sigyy += y * y * weight;
64}
◆ c()
double LLSQ::c |
( |
double |
m | ) |
const |
Definition at line 116 of file linlsq.cpp.
116 {
117 if (total_weight > 0.0)
118 return (sigy -
m * sigx) / total_weight;
119 else
120 return 0;
121}
◆ clear()
Definition at line 32 of file linlsq.cpp.
32 {
33 total_weight = 0.0;
34 sigx = 0.0;
35 sigy = 0.0;
36 sigxx = 0.0;
37 sigxy = 0.0;
38 sigyy = 0.0;
39}
◆ count()
int32_t LLSQ::count |
( |
| ) |
const |
|
inline |
Definition at line 43 of file linlsq.h.
43 {
44 return static_cast<int>(total_weight + 0.5);
45 }
◆ covariance()
double LLSQ::covariance |
( |
| ) |
const |
|
inline |
Definition at line 75 of file linlsq.h.
75 {
76 if (total_weight > 0.0)
77 return (sigxy - sigx * sigy / total_weight) / total_weight;
78 else
79 return 0.0;
80 }
◆ m()
Definition at line 100 of file linlsq.cpp.
100 {
103 if (x_var != 0.0)
104 return covar / x_var;
105 else
106 return 0.0;
107}
double x_variance() const
double covariance() const
◆ mean_point()
FCOORD LLSQ::mean_point |
( |
| ) |
const |
Definition at line 166 of file linlsq.cpp.
166 {
167 if (total_weight > 0.0) {
168 return FCOORD(sigx / total_weight, sigy / total_weight);
169 } else {
170 return FCOORD(0.0f, 0.0f);
171 }
172}
◆ pearson()
double LLSQ::pearson |
( |
| ) |
const |
Definition at line 153 of file linlsq.cpp.
153 {
154 double r = 0.0;
155
157 if (covar != 0.0) {
159 if (var_product > 0.0)
160 r = covar / std::sqrt(var_product);
161 }
162 return r;
163}
double y_variance() const
◆ remove()
void LLSQ::remove |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Definition at line 82 of file linlsq.cpp.
82 {
83 if (total_weight <= 0.0)
85 total_weight--;
86 sigx -= x;
87 sigy -= y;
88 sigxx -= x * x;
89 sigxy -= x * y;
90 sigyy -= y * y;
91}
constexpr ERRCODE EMPTY_LLSQ("Can't delete from an empty LLSQ")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
◆ rms()
double LLSQ::rms |
( |
double |
m, |
|
|
double |
c |
|
) |
| const |
Definition at line 130 of file linlsq.cpp.
130 {
131 double error;
132
133 if (total_weight > 0) {
134 error = sigyy +
m * (
m * sigxx + 2 * (
c * sigx - sigxy)) +
c *
135 (total_weight *
c - 2 * sigy);
136 if (error >= 0)
137 error = std::sqrt(error / total_weight);
138 else
139 error = 0;
140 } else {
141 error = 0;
142 }
143 return error;
144}
◆ rms_orth()
double LLSQ::rms_orth |
( |
const FCOORD & |
dir | ) |
const |
Definition at line 195 of file linlsq.cpp.
195 {
201}
bool normalise()
Convert to unit vec.
◆ vector_fit()
FCOORD LLSQ::vector_fit |
( |
| ) |
const |
Definition at line 251 of file linlsq.cpp.
251 {
255 double theta = 0.5 * atan2(2.0 * covar, x_var - y_var);
256 FCOORD result(cos(theta), sin(theta));
257 return result;
258}
◆ x_variance()
double LLSQ::x_variance |
( |
| ) |
const |
|
inline |
Definition at line 81 of file linlsq.h.
81 {
82 if (total_weight > 0.0)
83 return (sigxx - sigx * sigx / total_weight) / total_weight;
84 else
85 return 0.0;
86 }
◆ y_variance()
double LLSQ::y_variance |
( |
| ) |
const |
|
inline |
Definition at line 87 of file linlsq.h.
87 {
88 if (total_weight > 0.0)
89 return (sigyy - sigy * sigy / total_weight) / total_weight;
90 else
91 return 0.0;
92 }
The documentation for this class was generated from the following files: