-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCBvMatrix.cpp
More file actions
72 lines (60 loc) · 1.63 KB
/
CBvMatrix.cpp
File metadata and controls
72 lines (60 loc) · 1.63 KB
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
65
66
67
68
69
70
71
72
#include "CBvMatrix.h"
CBvMatrix::CBvMatrix(vector<TiXmlElement*>& m_sortedElements)
:CMatrix(m_sortedElements)
{
string bvString = BvString();
m_pBitVec = new bit_vector(bvString.length(), 0);
string::iterator it = bvString.begin();
for (int i = 0; it != bvString.end(); i++, it++)
if ((*it) == '1')
(*m_pBitVec)[i] = 1;
m_pSDVec = new sd_vector<>(*m_pBitVec);
}
CBvMatrix::~CBvMatrix()
{
if (m_pBitVec)
delete m_pBitVec;
delete m_pSDVec;
}
int CBvMatrix::ParentBV(int nID)
{
bit_vector::select_1_type sel1(m_pBitVec);
rank_support_v<0> rank_bitvector(m_pBitVec);
int selectID = sel1(nID);
int rank = rank_bitvector(selectID);
int iParent = rank % m_nElements;
return iParent;
}
int CBvMatrix::ParentSD(int nID)
{
sd_vector<>::select_1_type sel1(m_pSDVec);
//rank_support_v<0> rank_bitvector(m_pSDVec);
sd_vector<>::rank_0_type ranker(m_pSDVec);
int selectID = sel1(nID);
int rank = ranker(selectID);
int iParent = rank % m_nElements;
return iParent;
}
void CBvMatrix::ParentSDPrepare(sd_vector<>::select_1_type*& pSel1, sd_vector<>::rank_0_type*& pRanker)
{
pSel1 = new sd_vector<>::select_1_type(m_pSDVec);
pRanker = new sd_vector<>::rank_0_type (m_pSDVec);
return ;
}
void CBvMatrix::ParentSDDelete(sd_vector<>::select_1_type*& pSel1, sd_vector<>::rank_0_type*& pRanker)
{
delete pSel1;
delete pRanker;
return;
}
int CBvMatrix::ParentSDRun(sd_vector<>::select_1_type*& pSel1, sd_vector<>::rank_0_type*& pRanker, int nID)
{
int selectID = (*pSel1)(nID);
int rank = (*pRanker)(selectID);
int iParent = rank % m_nElements;
return iParent;
}
double CBvMatrix::GetSize()
{
return size_in_mega_bytes(*m_pSDVec);
}