test_class.file: lib/common/src/test/java/dk/alexandra/fresco/lib/common/collections/permute/TestWaksmanUtils.java
test_class.identifier: TestWaksmanUtils
test_case.body: @Test(expected = UnsupportedOperationException.class)
    public void testSetControlBits(){
      WaksmanUtils util = new WaksmanUtils();
     
      int[] controlBits = new int[]{2,3,0,1};
      Matrix<BigInteger> permutationMatrix = util.setControlBits(controlBits);
      assertThat(permutationMatrix.getHeight(), is(2));
      assertThat(permutationMatrix.getWidth(), is(controlBits.length-1));
          
      util.setControlBits(new int[]{2,1,0});
    }
test_case.class_method_signature: TestWaksmanUtils.testSetControlBits()
test_case.full_signature: @Test(expected = UnsupportedOperationException.class) public void testSetControlBits()
test_case.identifier: testSetControlBits
test_case.invocations: setControlBits assertThat getHeight is assertThat getWidth is setControlBits
test_case.modifiers: @Test(expected = UnsupportedOperationException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSetControlBits()
focal_class.file: lib/common/src/main/java/dk/alexandra/fresco/lib/common/collections/permute/WaksmanUtils.java
focal_class.identifier: WaksmanUtils
focal_class.class_method_signature: WaksmanUtils.log2(int n)
focal_class.full_signature: private int log2(int n)
focal_class.identifier: log2
focal_class.modifiers: private
focal_class.parameters: (int n)
focal_class.return: int
focal_class.signature: int log2(int n)
focal_class.class_method_signature: WaksmanUtils.nextUnsetSwapperIdx(int[] swappers)
focal_class.full_signature: private int nextUnsetSwapperIdx(int[] swappers)
focal_class.identifier: nextUnsetSwapperIdx
focal_class.modifiers: private
focal_class.parameters: (int[] swappers)
focal_class.return: int
focal_class.signature: int nextUnsetSwapperIdx(int[] swappers)
focal_class.class_method_signature: WaksmanUtils.swapperIdxOf(int elIdx)
focal_class.full_signature: private int swapperIdxOf(int elIdx)
focal_class.identifier: swapperIdxOf
focal_class.modifiers: private
focal_class.parameters: (int elIdx)
focal_class.return: int
focal_class.signature: int swapperIdxOf(int elIdx)
focal_class.class_method_signature: WaksmanUtils.topElIndexOf(int swIdx)
focal_class.full_signature: private int topElIndexOf(int swIdx)
focal_class.identifier: topElIndexOf
focal_class.modifiers: private
focal_class.parameters: (int swIdx)
focal_class.return: int
focal_class.signature: int topElIndexOf(int swIdx)
focal_class.class_method_signature: WaksmanUtils.even(int n)
focal_class.full_signature: private boolean even(int n)
focal_class.identifier: even
focal_class.modifiers: private
focal_class.parameters: (int n)
focal_class.return: boolean
focal_class.signature: boolean even(int n)
focal_class.class_method_signature: WaksmanUtils.isTopEl(int elIdx)
focal_class.full_signature: private boolean isTopEl(int elIdx)
focal_class.identifier: isTopEl
focal_class.modifiers: private
focal_class.parameters: (int elIdx)
focal_class.return: boolean
focal_class.signature: boolean isTopEl(int elIdx)
focal_class.class_method_signature: WaksmanUtils.neighElIdxOf(int elIdx)
focal_class.full_signature: private int neighElIdxOf(int elIdx)
focal_class.identifier: neighElIdxOf
focal_class.modifiers: private
focal_class.parameters: (int elIdx)
focal_class.return: int
focal_class.signature: int neighElIdxOf(int elIdx)
focal_class.class_method_signature: WaksmanUtils.hasNextUnsetSwapper(int[] rowO)
focal_class.full_signature: private boolean hasNextUnsetSwapper(int[] rowO)
focal_class.identifier: hasNextUnsetSwapper
focal_class.modifiers: private
focal_class.parameters: (int[] rowO)
focal_class.return: boolean
focal_class.signature: boolean hasNextUnsetSwapper(int[] rowO)
focal_class.class_method_signature: WaksmanUtils.routeFromOutputToInput(int rowOElIdx, int[] invPerm, int[] topPerm, int[] rowI)
focal_class.full_signature: private int routeFromOutputToInput(int rowOElIdx, int[] invPerm, int[] topPerm, int[] rowI)
focal_class.identifier: routeFromOutputToInput
focal_class.modifiers: private
focal_class.parameters: (int rowOElIdx, int[] invPerm, int[] topPerm, int[] rowI)
focal_class.return: int
focal_class.signature: int routeFromOutputToInput(int rowOElIdx, int[] invPerm, int[] topPerm, int[] rowI)
focal_class.class_method_signature: WaksmanUtils.routeFromInputToOutput(int rowIElIdx, int[] perm, int[] bottomPerm, int[] rowO)
focal_class.full_signature: private int routeFromInputToOutput(int rowIElIdx, int[] perm, int[] bottomPerm, int[] rowO)
focal_class.identifier: routeFromInputToOutput
focal_class.modifiers: private
focal_class.parameters: (int rowIElIdx, int[] perm, int[] bottomPerm, int[] rowO)
focal_class.return: int
focal_class.signature: int routeFromInputToOutput(int rowIElIdx, int[] perm, int[] bottomPerm, int[] rowO)
focal_class.class_method_signature: WaksmanUtils.route(int fromElIdx, int[] perm, int[] subPerm, int[] swappers,
        boolean outputToInput)
focal_class.full_signature: private int route(int fromElIdx, int[] perm, int[] subPerm, int[] swappers,
        boolean outputToInput)
focal_class.identifier: route
focal_class.modifiers: private
focal_class.parameters: (int fromElIdx, int[] perm, int[] subPerm, int[] swappers,
        boolean outputToInput)
focal_class.return: int
focal_class.signature: int route(int fromElIdx, int[] perm, int[] subPerm, int[] swappers,
        boolean outputToInput)
focal_class.class_method_signature: WaksmanUtils.setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_class.full_signature: private void setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_class.identifier: setControlBits
focal_class.modifiers: private
focal_class.parameters: (int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_class.return: void
focal_class.signature: void setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_class.class_method_signature: WaksmanUtils.getNumRowsRequired(int n)
focal_class.full_signature: public int getNumRowsRequired(int n)
focal_class.identifier: getNumRowsRequired
focal_class.modifiers: public
focal_class.parameters: (int n)
focal_class.return: int
focal_class.signature: int getNumRowsRequired(int n)
focal_class.class_method_signature: WaksmanUtils.getNumColsRequired(int n)
focal_class.full_signature: public int getNumColsRequired(int n)
focal_class.identifier: getNumColsRequired
focal_class.modifiers: public
focal_class.parameters: (int n)
focal_class.return: int
focal_class.signature: int getNumColsRequired(int n)
focal_class.class_method_signature: WaksmanUtils.isPow2(int n)
focal_class.full_signature: public boolean isPow2(int n)
focal_class.identifier: isPow2
focal_class.modifiers: public
focal_class.parameters: (int n)
focal_class.return: boolean
focal_class.signature: boolean isPow2(int n)
focal_class.class_method_signature: WaksmanUtils.invert(int[] p)
focal_class.full_signature: public int[] invert(int[] p)
focal_class.identifier: invert
focal_class.modifiers: public
focal_class.parameters: (int[] p)
focal_class.return: int[]
focal_class.signature: int[] invert(int[] p)
focal_class.class_method_signature: WaksmanUtils.setControlBits(int[] perm)
focal_class.full_signature: public Matrix<BigInteger> setControlBits(int[] perm)
focal_class.identifier: setControlBits
focal_class.modifiers: public
focal_class.parameters: (int[] perm)
focal_class.return: Matrix<BigInteger>
focal_class.signature: Matrix<BigInteger> setControlBits(int[] perm)
focal_method.body: private void setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx) {
      int n = perm.length;
  
      if (n == 2) {
        // for our base case we only have one swapper gate
        // which we can set directly
        controlBits[rowIdx][colIdx] = perm[0];
        return;
      }
  
      int[] rowI = new int[n / 2];
      int[] rowO = new int[n / 2];
      for (int j = 0; j < rowO.length; j++) {
        rowI[j] = -1;
        rowO[j] = -1;
      }
  
      int[] topPerm = new int[n / 2];
      int[] bottomPerm = new int[n / 2];
  
      int[] permInv = invert(perm);
  
      // loop until we have set all swappers at this level of the network
      while (hasNextUnsetSwapper(rowO)) {
        // find next O swapper that doesn't have control bit set
        int rowOSwIdx = nextUnsetSwapperIdx(rowO);
        // route through bottom
        rowO[rowOSwIdx] = 0;
  
        int firstOElIdx = topElIndexOf(rowOSwIdx);
        int rowOElIdx = firstOElIdx;
  
        // route from output to input and back again
        int rowIElIdx = routeFromOutputToInput(rowOElIdx, permInv, topPerm, rowI);
        rowOElIdx = routeFromInputToOutput(rowIElIdx, perm, bottomPerm, rowO);
  
        // loop until we're back at the start
        while (!(rowOElIdx == firstOElIdx)) {
          rowIElIdx = routeFromOutputToInput(rowOElIdx, permInv, topPerm, rowI);
          rowOElIdx = routeFromInputToOutput(rowIElIdx, perm, bottomPerm, rowO);
        }
      }
  
      // we have set all input and output swappers at this level of the network so we update our
      // swapper matrix and continue setting the swappers for our two sub permutations
      int numCols = controlBits[0].length;
      for (int j = 0; j < rowI.length; j++) {
        controlBits[rowIdx + j][colIdx] = rowI[j];
        controlBits[rowIdx + j][numCols - 1 - colIdx] = rowO[j];
      }
      setControlBits(topPerm, controlBits, rowIdx, colIdx + 1);
      setControlBits(bottomPerm, controlBits, rowIdx + rowI.length / 2, colIdx + 1);
    }
focal_method.class_method_signature: WaksmanUtils.setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_method.full_signature: private void setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_method.identifier: setControlBits
focal_method.invocations: invert hasNextUnsetSwapper nextUnsetSwapperIdx topElIndexOf routeFromOutputToInput routeFromInputToOutput routeFromOutputToInput routeFromInputToOutput setControlBits setControlBits
focal_method.modifiers: private
focal_method.parameters: (int[] perm, int[][] controlBits, int rowIdx, int colIdx)
focal_method.return: void
focal_method.signature: void setControlBits(int[] perm, int[][] controlBits, int rowIdx, int colIdx)