diff --git a/mixer/src/main/java/mixer/MixNetwork.java b/mixer/src/main/java/mixer/MixNetwork.java index da096d0..833ef73 100644 --- a/mixer/src/main/java/mixer/MixNetwork.java +++ b/mixer/src/main/java/mixer/MixNetwork.java @@ -18,7 +18,7 @@ public class MixNetwork { int[] permutation = randomPermutation.permutation; int n = permutation.length; assert ((n & n-1) == 0); //n == 2^k - int layers = (int)(2*Math.log(n)/Math.log(2)); + int layers = (int)(2*Math.log(n)/Math.log(2)) - 1; int[] pi, piL, piR; Queue permutationsQueue = new ArrayBlockingQueue(n); @@ -40,8 +40,8 @@ public class MixNetwork { piR = new int[iDiv2]; for (int k = 0; k < iDiv2; k++) // k == switch index in permutation j { - index1 = k + j; - index2 = k + j + iDiv2; + index1 = k + (j << 1); + index2 = index1 + iDiv2; switches[layers - layer - 1][k + j] = new Switch(index1,index2,layers - layer - 1,graph.getSwitchValue(k, true)); switches[layer][k + j] = new Switch(index1,index2,layer,graph.getSwitchValue(k, false)); diff --git a/mixer/src/test/java/mixer/MixNetworkTest.java b/mixer/src/test/java/mixer/MixNetworkTest.java index b783a2a..4652460 100644 --- a/mixer/src/test/java/mixer/MixNetworkTest.java +++ b/mixer/src/test/java/mixer/MixNetworkTest.java @@ -15,7 +15,7 @@ public class MixNetworkTest { public void testMixNetwork() throws Exception{ Random random = new Random(); - int logn = random.nextInt()%10 + 5; + int logn = 10; int n = 1 << logn; int layers = 2*logn - 1;