2
2
* File: linlsq.cpp (Formerly llsq.c)
3
3
* Description: Linear Least squares fitting code.
4
4
* Author: Ray Smith
5
- * Created: Thu Sep 12 08:44:51 BST 1991
6
5
*
7
6
* (C) Copyright 1991, Hewlett-Packard Ltd.
8
7
** Licensed under the Apache License, Version 2.0 (the "License");
18
17
**********************************************************************/
19
18
20
19
#include < cstdio>
21
- #include < cmath>
20
+ #include < cmath> // for std::sqrt
22
21
#include " errcode.h"
23
22
#include " linlsq.h"
24
23
@@ -135,7 +134,7 @@ double LLSQ::rms(double m, double c) const { // get error
135
134
error = sigyy + m * (m * sigxx + 2 * (c * sigx - sigxy)) + c *
136
135
(total_weight * c - 2 * sigy);
137
136
if (error >= 0 )
138
- error = sqrt (error / total_weight); // sqrt of mean
137
+ error = std:: sqrt (error / total_weight); // sqrt of mean
139
138
else
140
139
error = 0 ;
141
140
} else {
@@ -158,7 +157,7 @@ double LLSQ::pearson() const { // get correlation
158
157
if (covar != 0.0 ) {
159
158
double var_product = x_variance () * y_variance ();
160
159
if (var_product > 0.0 )
161
- r = covar / sqrt (var_product);
160
+ r = covar / std:: sqrt (var_product);
162
161
}
163
162
return r;
164
163
}
@@ -196,9 +195,9 @@ FCOORD LLSQ::mean_point() const {
196
195
double LLSQ::rms_orth (const FCOORD &dir) const {
197
196
FCOORD v = !dir;
198
197
v.normalise ();
199
- return sqrt (v.x () * v.x () * x_variance () +
200
- 2 * v.x () * v.y () * covariance () +
201
- v.y () * v.y () * y_variance ());
198
+ return std:: sqrt (v.x () * v.x () * x_variance () +
199
+ 2 * v.x () * v.y () * covariance () +
200
+ v.y () * v.y () * y_variance ());
202
201
}
203
202
204
203
// Returns the direction of the fitted line as a unit vector, using the
0 commit comments