-
Notifications
You must be signed in to change notification settings - Fork 0
/
approx.h
45 lines (31 loc) · 868 Bytes
/
approx.h
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
35
36
37
38
39
40
41
42
43
44
45
#ifndef APPROX_H
#define APPROX_H
#include "util.h"
#include <vector>
class Approx {
public:
virtual ~Approx() {};
virtual void set_param(std::pair<int, int>) {}
virtual void set_param(double) {}
virtual void clear() = 0;
virtual double estimate(ull) = 0;
virtual void feed(point) = 0;
virtual size_t memory_usage() = 0;
double burstiness(ull t, ull tau) {
auto c = estimate(t);
if (t < tau) {
return c;
}
else {
auto b = estimate(t - tau);
if (t < 2 * tau) {
return c - 2 * b;
}
else {
auto a = estimate(t - 2 * tau);
return c - 2 * b + a;
}
}
}
};
#endif