forked from abhimanyudubey/P
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoresetStack.cpp
76 lines (52 loc) · 1.16 KB
/
CoresetStack.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "CoresetStack.hpp"
#define CORESETSTACK_DEBUG 1
CoresetStack::CoresetStack(int m)
{
svd_method = m;
}
int CoresetStack::getSVDmethod()
{
return svd_method;
}
Coreset CoresetStack::top()
{
if(!core_stack.empty())
return core_stack.top();
else
return Coreset(-1);
}
void CoresetStack::push(Coreset cor)
{
Coreset c1 = cor;
Coreset c2 = top();
#ifdef CORESETSTACK_DEBUG
std::cout << "c2: " << c2.getLevel() << std::endl;
std::cout << "c1: " << c1.getLevel() << std::endl;
#endif
while(c2.getLevel() == c1.getLevel())
{
core_stack.pop();
c1.mergeCoreset(c2, svd_method);
#ifdef CORESETSTACK_DEBUG
std::cout << "coresets merged" << std::endl;
#endif
c2 = top();
#ifdef CORESETSTACK_DEBUG
std::cout << "l2: " << c2.getLevel() << std::endl;
std::cout << "l1: " << c1.getLevel() << std::endl;
#endif
}
#ifdef CORESETSTACK_DEBUG
std::cout << "coresets pushed" << std::endl;
#endif
core_stack.push(c1);
}
void CoresetStack::pop()
{
if(!core_stack.empty())
core_stack.pop();
}
int CoresetStack::size()
{
return core_stack.size();
}