public static void sampleSubtract(FixedBitSet vector,FixedBitSet subvector){
  long numchanges=vector.length() / 2 - xorCount(vector,subvector);
  java.util.Random random=new java.util.Random();
  random.setSeed((long)23);
  FixedBitSet commonGround=(FixedBitSet)vector.clone();
  commonGround.xor(subvector);
  int cnt=0;
  if (numchanges > 0)   for (int x=0; cnt < numchanges; x++) {
    if (x >= vector.length())     x=0;
    double change=random.nextDouble();
    if (!commonGround.get(x) && change > 0.5) {
      vector.flip(x);
      cnt++;
    }
  }
 else   if (numchanges < 0) {
    for (int x=0; cnt > numchanges; x++) {
      if (x >= vector.length())       x=0;
      double change=random.nextDouble();
      if (commonGround.get(x) && change > 0.5) {
        vector.flip(x);
        cnt--;
      }
    }
  }
}

public static void sampleSubtract ( FixedBitSet vector , FixedBitSet subvector ) { long numchanges = vector . length ( ) / 2 - xorCount ( vector , subvector ) ; java . util . Random random = new java . util . Random ( ) ; random . setSeed ( ( long ) 23 ) ; FixedBitSet commonGround = ( FixedBitSet ) vector . clone ( ) ; commonGround . xor ( subvector ) ; int cnt = 0 ; if ( numchanges > 0 ) for ( int x = 0 ; cnt < numchanges ; x ++ ) { if ( x >= vector . length ( ) ) x = 0 ; double change = random . nextDouble ( ) ; if ( ! commonGround . get ( x ) && change > 0.5 ) { vector . flip ( x ) ; cnt ++ ; } } else if ( numchanges < 0 ) { for ( int x = 0 ; cnt > numchanges ; x ++ ) { if ( x >= vector . length ( ) ) x = 0 ; double change = random . nextDouble ( ) ; if ( commonGround . get ( x ) && change > 0.5 ) { vector . flip ( x ) ; cnt -- ; } } } }
this method provides the equivalent of orthogonalization for binary vectors . rather than making vector k orthogonal to vector j , we alter vector j so it has a hamming distance of n / 2 to vector k . this is the analog of orthogonality in real / complex space .
