20 #ifndef TESSERACT_CCSTRUCT_LINLSQ_H_
21 #define TESSERACT_CCSTRUCT_LINLSQ_H_
36 void add(
double x,
double y);
38 void add(
double x,
double y,
double weight);
43 int32_t
count()
const {
44 return static_cast<int>(total_weight + 0.5);
48 double c(
double m)
const;
49 double rms(
double m,
double c)
const;
76 if (total_weight > 0.0)
77 return (sigxy - sigx * sigy / total_weight) / total_weight;
82 if (total_weight > 0.0)
83 return (sigxx - sigx * sigx / total_weight) / total_weight;
88 if (total_weight > 0.0)
89 return (sigyy - sigy * sigy / total_weight) / total_weight;
115 T halfrange = static_cast<T>(modulus / 2);
116 int num_elements = v->
size();
117 for (
int i = 0; i < num_elements; ++i) {
118 stats.
add((*v)[i], (*v)[i] + halfrange);
122 for (
int i = 0; i < num_elements; ++i) {
123 (*v)[i] += halfrange;
128 for (
int i = 0; i < num_elements; ++i) {
129 (*v)[i] -= halfrange;
132 return (*v)[median_index];
136 #endif // TESSERACT_CCSTRUCT_LINLSQ_H_