made *x and *y args const

This commit is contained in:
Ahmet Inan 2021-09-11 16:30:01 +02:00
commit c83add357c
4 changed files with 6 additions and 6 deletions

View file

@ -14,7 +14,7 @@ class SimpleLinearRegression
TYPE xint_, yint_, slope_; TYPE xint_, yint_, slope_;
public: public:
SimpleLinearRegression() : xint_(0), yint_(0), slope_(0) {} SimpleLinearRegression() : xint_(0), yint_(0), slope_(0) {}
SimpleLinearRegression(TYPE *x, TYPE *y, int LEN) SimpleLinearRegression(const TYPE *x, const TYPE *y, int LEN)
{ {
TYPE avgX(0), avgY(0); TYPE avgX(0), avgY(0);
for (int i = 0; i < LEN; ++i) { for (int i = 0; i < LEN; ++i) {
@ -32,7 +32,7 @@ public:
slope_ = covXY / varX; slope_ = covXY / varX;
yint_ = avgY - slope_ * avgX; yint_ = avgY - slope_ * avgX;
} }
SimpleLinearRegression(TYPE *y, int l, TYPE x0 = 0, TYPE dx = 1) SimpleLinearRegression(const TYPE *y, int l, TYPE x0 = 0, TYPE dx = 1)
{ {
TYPE midL((l-1) / TYPE(2)); TYPE midL((l-1) / TYPE(2));
TYPE avgX(x0 + dx*midL); TYPE avgX(x0 + dx*midL);

View file

@ -17,7 +17,7 @@ class RepeatedMedianEstimator
TYPE xint_, yint_, slope_; TYPE xint_, yint_, slope_;
public: public:
RepeatedMedianEstimator() : xint_(0), yint_(0), slope_(0) {} RepeatedMedianEstimator() : xint_(0), yint_(0), slope_(0) {}
void compute(TYPE *x, TYPE *y, int LEN) void compute(const TYPE *x, const TYPE *y, int LEN)
{ {
if (LEN > SIZE) if (LEN > SIZE)
LEN = SIZE; LEN = SIZE;
@ -68,7 +68,7 @@ class RepeatedMedianEstimator2
TYPE xint_, yint_, slope_; TYPE xint_, yint_, slope_;
public: public:
RepeatedMedianEstimator2() : xint_(0), yint_(0), slope_(0) {} RepeatedMedianEstimator2() : xint_(0), yint_(0), slope_(0) {}
void compute(TYPE *x, TYPE *y, int LEN) void compute(const TYPE *x, const TYPE *y, int LEN)
{ {
if (LEN > SIZE) if (LEN > SIZE)
LEN = SIZE; LEN = SIZE;

View file

@ -15,7 +15,7 @@ class UniformNaturalCubicSpline
ITYPE x0, dx; ITYPE x0, dx;
public: public:
UniformNaturalCubicSpline() = default; UniformNaturalCubicSpline() = default;
UniformNaturalCubicSpline(OTYPE *Y, ITYPE x0 = 0, ITYPE dx = 1, int STRIDE = 1) : x0(x0), dx(dx) UniformNaturalCubicSpline(const OTYPE *Y, ITYPE x0 = 0, ITYPE dx = 1, int STRIDE = 1) : x0(x0), dx(dx)
{ {
ITYPE U[KNOTS-1]; ITYPE U[KNOTS-1];
U[0] = ITYPE(0); U[0] = ITYPE(0);

View file

@ -18,7 +18,7 @@ class TheilSenEstimator
TYPE xint_, yint_, slope_; TYPE xint_, yint_, slope_;
public: public:
TheilSenEstimator() : xint_(0), yint_(0), slope_(0) {} TheilSenEstimator() : xint_(0), yint_(0), slope_(0) {}
void compute(TYPE *x, TYPE *y, int LEN) void compute(const TYPE *x, const TYPE *y, int LEN)
{ {
int count = 0; int count = 0;
for (int i = 0; count < size_ && i < LEN; ++i) for (int i = 0; count < size_ && i < LEN; ++i)