-
Notifications
You must be signed in to change notification settings - Fork 0
/
learn_linear_to_c_1.c
34 lines (31 loc) · 988 Bytes
/
learn_linear_to_c_1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include <cstdarg>
namespace Eloquent {
namespace ML {
namespace Port {
class LinearRegression {
public:
/**
* Predict class for features vector
*/
float predict(float *x) {
return dot(x, 3.000000000000) + 1.0000000000000018;
}
protected:
/**
* Compute dot product
*/
float dot(float *x, ...) {
va_list w;
va_start(w, 1);
float dot = 0.0;
for (uint16_t i = 0; i < 1; i++) {
const float wi = va_arg(w, double);
dot += x[i] * wi;
}
return dot;
}
};
}
}
}