mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-02-23 00:45:22 +01:00
Deletetd tests
This commit is contained in:
parent
dec8585ab4
commit
93138238db
@ -15,63 +15,4 @@ public class FasterFinnSortTest extends AbstractSortTest {
|
|||||||
sortAlg = SortEnum.FASTER_FINN_SORT;
|
sortAlg = SortEnum.FASTER_FINN_SORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMergeOrder() {
|
|
||||||
Integer[] input = {24,25,26,27,28,21,22,23,18,19,20,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,1,2};
|
|
||||||
FasterFinnSort.sort(input, 0, input.length, NaturalOrder.INSTANCE,null, 0, 0);
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void powerTest() {
|
|
||||||
Run run1 = new Run(0, 10, 0);
|
|
||||||
Run run2 = new Run(10, 20, 0);
|
|
||||||
|
|
||||||
for (int i = 20; i < 10100; i++) {
|
|
||||||
System.out.println(i);
|
|
||||||
//assertEquals(integerPower(run1, run2, i), power(run1, run2, i));
|
|
||||||
assertEquals(power(run1, run2, i),
|
|
||||||
power2(run1, run2, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private static int integerPower(Run run1, Run run2, int n) {
|
|
||||||
|
|
||||||
int n_1 = run1.len;
|
|
||||||
int n_2 = run2.len;
|
|
||||||
|
|
||||||
int a = 2 * run1.start + n_1 - 1;
|
|
||||||
int b = a + n_1 + n_2;
|
|
||||||
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
while (a * pow(2, result) == b * pow(2, result)) {
|
|
||||||
result++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private static int power(Run run1, Run run2, int n) {
|
|
||||||
/*
|
|
||||||
if (run1.start == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
int n_1 = run1.end - run1.start;
|
|
||||||
int n_2 = run2.end - run2.start;
|
|
||||||
double a = ((double) run1.start + 0.5d * n_1) / n;
|
|
||||||
double b = ((double) run2.start + 0.5d * n_2) / n;
|
|
||||||
int l = 1;
|
|
||||||
while ((int) (a * pow(2, l)) == (int) (b * pow(2 ,l))) {
|
|
||||||
l++;
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int power2(Run run1, Run run2, int n) {
|
|
||||||
long l = (long) run1.start + (long) run2.start; // 2*middleA
|
|
||||||
long r = (long) run2.start + (long) run2.end + 1; // 2*middleB
|
|
||||||
int a = (int) ((l << 30) / n); // middleA / 2n
|
|
||||||
int b = (int) ((r << 30) / n); // middleB / 2n
|
|
||||||
return Integer.numberOfLeadingZeros(a ^ b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user