Examples of TFloatArrayList


Examples of gnu.trove.list.array.TFloatArrayList

     * specified capacity.
     *
     * @param capacity the initial depth of the stack
     */
    public TFloatArrayStack( int capacity ) {
        _list = new TFloatArrayList( capacity );
    }
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

     *
     * @param capacity the initial depth of the stack
     * @param no_entry_value value that represents null
     */
    public TFloatArrayStack( int capacity, float no_entry_value ) {
        _list = new TFloatArrayList( capacity, no_entry_value );
    }
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

     * @param stack the instance to copy
     */
    public TFloatArrayStack( TFloatStack stack ) {
        if ( stack instanceof TFloatArrayStack ) {
            TFloatArrayStack array_stack = ( TFloatArrayStack ) stack;
            this._list = new TFloatArrayList( array_stack._list );
        } else {
            throw new UnsupportedOperationException( "Only support TFloatArrayStack" );
        }
    }
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

    });
  }
 
  private TIntArrayList nearestN(Point p, int n, float furthestDistance) {
    TIntArrayList ids = new TIntArrayList();
    TFloatArrayList distances = new TFloatArrayList();
   
    TIntObjectIterator<Rectangle> iter = m_map.iterator();
    while (iter.hasNext()) {
      iter.advance();
      int currentId = iter.key();
      Rectangle currentRectangle = iter.value();
      float distance = currentRectangle.distance(p);
     
      if (distance <= furthestDistance) {
        int insertionIndex = 0;
        while (ids.size() > insertionIndex && distances.get(insertionIndex) <= distance) {
          insertionIndex++;
        }
       
        ids.insert(insertionIndex, currentId);
        distances.insert(insertionIndex, distance);
       
        // remove the entries with the greatest distance, if necessary.
        if (ids.size() > n) {
          // check that removing all entries with equal greatest distance
          // would leave at least N entries.
          int maxDistanceCount = 1;
          int currentIndex = distances.size() - 1;
          float maxDistance = distances.get(currentIndex);
          while (currentIndex - 1 >= 0 && distances.get(currentIndex - 1) == maxDistance) {
            currentIndex--;
            maxDistanceCount++;
          }
          if (ids.size() - maxDistanceCount >= n) {
            ids.remove(currentIndex, maxDistanceCount);
            distances.remove(currentIndex, maxDistanceCount);
          }
        }
      }
    }
   
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

    priorities.reset();
  }

  public SortedList() {
    ids = new TIntArrayList(DEFAULT_PREFERRED_MAXIMUM_SIZE);
    priorities = new TFloatArrayList(DEFAULT_PREFERRED_MAXIMUM_SIZE);
  }
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

  }

  public PriorityQueue(boolean sortOrder, int initialCapacity) {
    this.sortOrder = sortOrder;
    values = new TIntArrayList(initialCapacity);
    priorities = new TFloatArrayList(initialCapacity);
  }
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

    @Override
    public void clean() {
        TFloatList olddata = data;
        TIntIntMap oldindexer = indexer;
        data = new TFloatArrayList(olddata.size());
        indexer = new TIntIntHashMap(oldindexer.size());

        int pos = 0;
        TIntIntIterator iter = oldindexer.iterator();
        while (iter.hasNext()) {
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

    @Override
    public void clean() {
        TFloatList olddata = data;
        TIntIntMap oldindexer = indexer;
        data = new TFloatArrayList(olddata.size());
        indexer = new TIntIntHashMap(oldindexer.size());

        int pos = 0;
        TIntIntIterator iter = oldindexer.iterator();
        while (iter.hasNext()) {
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

    int[] idx = index.keys();
    Arrays.sort(idx);
    int length = weights.length;
    IFeatureAlphabet newfeat = new StringFeatureAlphabet();
    cl.getAlphabetFactory().setDefaultFeatureAlphabet(newfeat);
    TFloatArrayList ww = new TFloatArrayList();
    float[] vars = new float[idx.length];
    float[] entropy = new float[idx.length];
    for (int i = 0; i < idx.length; i++) {
      int base = idx[i]; //一个特征段起始位置
      int end; //一个特征段结束位置
      if (i < idx.length - 1)
        end = idx[i + 1]; //对应下一个特征段起始位置
      else
        end  = length; //或者整个结束位置
      int interv = end - base;   //一个特征段长度
      float[] sw = new float[interv];
      for (int j = 0; j < interv; j++) {
        sw[j] = weights[base+j];
      }
      //计算方差
//      System.out.println(MyStrings.toString(sw, " "));
      vars[i] = MyArrays.viarance(sw);
      MyArrays.normalize(sw);
      MyArrays.normalize2Prop(sw);
      entropy[i] = MyArrays.entropy(sw);
      int[] maxe = new int[sw.length];
      for(int iii=0;iii<maxe.length;iii++){
        maxe[iii]=1;
      }
      float maxen = MyArrays.entropy(maxe);
      if (i==0||vars[i]>varsthresh&&entropy[i]<maxen*0.999) {
        String str = index.get(base);
        int id = newfeat.lookupIndex(str, interv);
        for (int j = 0; j < interv; j++) {
          ww.insert(id + j, weights[base + j]);
        }
      }else{
//                System.out.print("."); 
      }
    }
    System.out.println("方差均值:"+MyArrays.average(vars));
    System.out.println("方差非零个数:"+MyArrays.countNoneZero(vars));
    System.out.println("方差直方图:"+MyStrings.toString(MyArrays.histogram(vars, 10)));
//    MyArrays.normalize2Prop(entropy);
    System.out.println("熵均值:"+MyArrays.average(entropy));
    System.out.println("熵非零个数:"+MyArrays.countNoneZero(entropy));
    System.out.println("熵直方图:"+MyStrings.toString(MyArrays.histogram(entropy, 10)));
   
    newfeat.setStopIncrement(freeze);
    cl.setWeights(ww.toArray());

    float[] www = cl.getWeights();
    c = MyArrays.countNoneZero(www);

    System.out.println("\n优化后")
    System.out.println("字典索引个数"+cl.getAlphabetFactory().DefaultFeatureAlphabet().keysize());
    System.out.println("字典大小"+cl.getAlphabetFactory().DefaultFeatureAlphabet().size());
    System.out.println("权重长度"+www.length);
    System.out.println("非零权重"+c)

    index.clear();
    ww.clear();
  }
View Full Code Here

Examples of gnu.trove.list.array.TFloatArrayList

    int[] idx = index.keys();
    Arrays.sort(idx);
    int length = weights.length;
    HashFeatureAlphabet newfeat = new HashFeatureAlphabet();
    cl.getAlphabetFactory().setDefaultFeatureAlphabet(newfeat);
    TFloatArrayList ww = new TFloatArrayList();
    for (int i = 0; i < idx.length; i++) {
      int base = idx[i]; //一个特征段起始位置
      int end; //一个特征段结束位置
      if (i < idx.length - 1)
        end = idx[i + 1]; //对应下一个特征段起始位置
      else
        end  = length; //或者整个结束位置

      int interv = end - base;   //一个特征段长度
      float[] sw = new float[interv];
      for (int j = 0; j < interv; j++) {
        sw[j] = weights[base+j];
      }
      float var = MyArrays.viarance(sw);
      if (var>varsthresh) {
        int str = index.get(base);
        int id = newfeat.lookupIndex(str, interv);
        for (int j = 0; j < interv; j++) {
          ww.insert(id + j, weights[base + j]);
        }
      }else{
        //        System.out.print("."); 
      }

    }
    newfeat.setStopIncrement(freeze);
    cl.setWeights(ww.toArray());
    index.clear();
    ww.clear();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.