Package cern.colt.bitvector

Examples of cern.colt.bitvector.BitVector


public void ensureCapacity(int minCapacity) {
  int oldCapacity = capacity;
  if (minCapacity > oldCapacity) {
      int newCapacity = (oldCapacity * 3)/2 + 1;
    if (newCapacity < minCapacitynewCapacity = minCapacity;
    BitVector vector = toBitVector();
    vector.setSize(newCapacity*bitsPerElement);
    this.bits = vector.elements();
    this.capacity = newCapacity;
  }
}
View Full Code Here


/**
* Returns the receiver seen as bitvector.
* WARNING: The bitvector and the receiver share the backing bits. Modifying one of them will affect the other.
*/
public BitVector toBitVector() {
  return new BitVector(this.bits, this.capacity*bitsPerElement);
}
 
View Full Code Here

* storage of the receiver.
*/
public void trimToSize() {
  int oldCapacity = capacity;
  if (size < oldCapacity) {
    BitVector vector = toBitVector();
    vector.setSize(size);
    this.bits = vector.elements();
    this.capacity = size;
  }
}
View Full Code Here

public void ensureCapacity(int minCapacity) {
  int oldCapacity = capacity;
  if (minCapacity > oldCapacity) {
      int newCapacity = (oldCapacity * 3)/2 + 1;
    if (newCapacity < minCapacitynewCapacity = minCapacity;
    BitVector vector = toBitVector();
    vector.setSize(newCapacity*bitsPerElement);
    this.bits = vector.elements();
    this.capacity = newCapacity;
  }
}
View Full Code Here

/**
* Returns the receiver seen as bitvector.
* WARNING: The bitvector and the receiver share the backing bits. Modifying one of them will affect the other.
*/
public BitVector toBitVector() {
  return new BitVector(this.bits, this.capacity*bitsPerElement);
}
 
View Full Code Here

* storage of the receiver.
*/
public void trimToSize() {
  int oldCapacity = capacity;
  if (size < oldCapacity) {
    BitVector vector = toBitVector();
    vector.setSize(size);
    this.bits = vector.elements();
    this.capacity = size;
  }
}
View Full Code Here

  }
 
  @Test
  public final void testIntersects()
  {
    BitVector A=new BitVector(100),B=new BitVector(100);
    Assert.assertFalse(Linear.intersects(A, B));
    A.set(10);
    Assert.assertFalse(Linear.intersects(A, B));
    B.set(10);
    Assert.assertTrue(Linear.intersects(A, B));
    A.clear(10);
    A.set(71);A.set(72);B.set(72);
    Assert.assertTrue(Linear.intersects(A, B));
    A.clear(72);
    Assert.assertFalse(Linear.intersects(A, B));
  }
View Full Code Here

    Map<Label,Integer> inputToInt = new TreeMap<Label,Integer>();
                for(Label str:getAlphabet()) inputToInt.put(str, num++);
    for(Entry<CmpVertex,Map<Label,TARGET_A_TYPE>> entry:graph.transitionMatrix.entrySet())
      if (filter.stateToConsider(entry.getKey()))
      {// ignoring irrelevant-states, for efficiency
        BitVector
          acceptVector = new BitVector(getAlphabet().size()),
          rejectVector = new BitVector(getAlphabet().size());
        for(Entry<Label,TARGET_A_TYPE> transition:entry.getValue().entrySet())
          for(CmpVertex vert:graph.getTargets(transition.getValue()))
          {
           
            if (!vert.isAccept())
              rejectVector.set(inputToInt.get(transition.getKey()));
            else
              acceptVector.set(inputToInt.get(transition.getKey()));
          }
        inputsAccepted.put(entry.getKey(), acceptVector);
        inputsRejected.put(entry.getKey(), rejectVector);
View Full Code Here

      @Override
      public void handleEntry(Entry<CmpVertex, Map<Label, List<CmpVertex>>> entryA, @SuppressWarnings("unused") int threadNo)
      {// we are never called with entryA which has been filtered out.
        Collection<Entry<Label,List<CmpVertex>>> rowA_collection = matrixInverse.transitionMatrix.get(entryA.getKey()).entrySet();// the "inverse" row
        BitVector inputsAcceptedFromA = inputsAccepted.get(entryA.getKey()), inputsRejectedFromA = inputsRejected.get(entryA.getKey());
       
        // Now iterate through states, pre-filtered during construction of matrixInverse but in the same order
        // because they are ordered by their IDs and we are using a TreeMap to store 'em.
        Iterator<Entry<CmpVertex,Map<Label,List<CmpVertex>>>> stateB_It = matrixInverse.transitionMatrix.entrySet().iterator();
        while(stateB_It.hasNext())
        {
          Entry<CmpVertex,Map<Label,List<CmpVertex>>> stateB = stateB_It.next();// stateB should not have been filtered out by construction of matrixInverse
          int currentStatePair = vertexToIntNR(stateB.getKey(),entryA.getKey());
          assert prevStatePairNumber < 0 || currentStatePair == prevStatePairNumber+1;prevStatePairNumber=currentStatePair;
         
          // Note that we are iterating state pairs consecutively in an increasing order and
          // different threads handle non-intersecting ranges of them, hence most of the time,
          // there should be no "cache thrashing".
          BitVector B_accepted=inputsAccepted.get(stateB.getKey()),B_rejected=inputsRejected.get(stateB.getKey());
          if (!AbstractLearnerGraph.checkCompatible(stateB.getKey(), entryA.getKey(), pairCompatibility) ||// relevant in two cases:
              // (A) if we do not filter any states initially; this is the case where there are states
              // without outgoing transitions which may be incompatible due to different labelling.
              // (B) some pairs of states are recorded as incompatible
              intersects(inputsAcceptedFromA,B_rejected) || intersects(inputsRejectedFromA,B_accepted))
View Full Code Here

    Map<Label,Integer> inputToInt = new TreeMap<Label,Integer>();
                for(Label str:getAlphabet()) inputToInt.put(str, num++);
    for(Entry<CmpVertex,Map<Label,TARGET_A_TYPE>> entry:graph.transitionMatrix.entrySet())
      if (filter.stateToConsider(entry.getKey()))
      {// ignoring irrelevant-states, for efficiency
        BitVector
          acceptVector = new BitVector(getAlphabet().size()),
          rejectVector = new BitVector(getAlphabet().size());
        for(Entry<Label,TARGET_A_TYPE> transition:entry.getValue().entrySet())
          for(CmpVertex vert:graph.getTargets(transition.getValue()))
          {
           
            if (!vert.isAccept())
              rejectVector.set(inputToInt.get(transition.getKey()));
            else
              acceptVector.set(inputToInt.get(transition.getKey()));
          }
        inputsAccepted.put(entry.getKey(), acceptVector);
        inputsRejected.put(entry.getKey(), rejectVector);
View Full Code Here

TOP

Related Classes of cern.colt.bitvector.BitVector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.