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_;
public:
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);
for (int i = 0; i < LEN; ++i) {
@ -32,7 +32,7 @@ public:
slope_ = covXY / varX;
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 avgX(x0 + dx*midL);

View file

@ -17,7 +17,7 @@ class RepeatedMedianEstimator
TYPE xint_, yint_, slope_;
public:
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)
LEN = SIZE;
@ -68,7 +68,7 @@ class RepeatedMedianEstimator2
TYPE xint_, yint_, slope_;
public:
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)
LEN = SIZE;

View file

@ -15,7 +15,7 @@ class UniformNaturalCubicSpline
ITYPE x0, dx;
public:
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];
U[0] = ITYPE(0);

View file

@ -18,7 +18,7 @@ class TheilSenEstimator
TYPE xint_, yint_, slope_;
public:
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;
for (int i = 0; count < size_ && i < LEN; ++i)