Skip to content

Commit cbc9a5d

Browse files
authored
Bug: duplicate counting (#10)
* Setup: Debug * Bug fixed: only Rs equals to identical p counts
1 parent cbf0662 commit cbc9a5d

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"files.associations": {
3-
"utils.h": "c"
3+
"utils.h": "c",
4+
"random": "c"
45
}
56
}

src/intersect.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ int MERGE_COUNT_INVERSION(Paths pt, int l, int m, int r){
151151
}
152152

153153
//Sum up
154-
inv = inv + (count - (m + 1)) + Iden;
154+
inv += (count - (m + 1));
155+
156+
if(pt.r[k].p == isSame.p)
157+
inv += Iden;
158+
155159
}
156160

157161

src/main.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@
1616

1717
int main()
1818
{
19-
/*
20-
int n = 10;
21-
int p[] = {-5, 15, 15, -8, -11, -5, -13, -14, 15, 10};
22-
int q[] = {-7, -12, -4, -13, 5, 1, 14, -16, -16, -14};
23-
int r[] = {2, -13, 1, 9, 9, 1, 1, 12, -15, 6};
2419

20+
2521
//Initiate
26-
Paths pt = init_path(n,p,q,r);
27-
28-
29-
30-
MERGE_SORT_FIRSTofThree(pt.p, pt.l, pt.r, 0, pt.len-1);
22+
/*
23+
TriProb tp = ParseData("test/dataGen/2.txt");
24+
int ans = get_intersects(tp.n, tp.ps, tp.qs, tp.rs);
25+
printf("%d\n",ans);
3126
*/
3227

33-
28+
// Interface
3429
generator.init();
3530
int t = generator.getT();
3631

@@ -44,7 +39,7 @@ int main()
4439
printf("\n");
4540
}
4641
}
47-
42+
4843

4944
return 0;
5045
}

0 commit comments

Comments
 (0)