Package gnu.trove.map.hash

Examples of gnu.trove.map.hash.TIntDoubleHashMap$TIntDoubleValueHashIterator


*/
public class TByteTripleDoubleHashMap {
  private TIntDoubleHashMap map;

  public TByteTripleDoubleHashMap() {
    map = new TIntDoubleHashMap(100);
  }
View Full Code Here


  public TByteTripleDoubleHashMap() {
    map = new TIntDoubleHashMap(100);
  }

  public TByteTripleDoubleHashMap(int capacity) {
    map = new TIntDoubleHashMap(capacity);
  }
View Full Code Here

   *
   * @param size Expected size
   */
  public MapIntegerDBIDDoubleStore(int size) {
    super();
    map = new TIntDoubleHashMap(size, 0.5f, Integer.MIN_VALUE, Double.NaN);
  }
View Full Code Here

    return result;
    }
   
    public static RyanFeatureVector getAddedVector(RyanFeatureVector fv1, RyanFeatureVector fv2, double rate) {
     
      TIntDoubleHashMap hm = new TIntDoubleHashMap();
      for (RyanFeatureVector curr = fv1; curr.next != null; curr = curr.next) {
        if (curr.index >= 0) {
          hm.put(curr.index, (hm.containsKey(curr.index) ? hm.get(curr.index) : 0) + curr.value);
        }
      }

      for (RyanFeatureVector curr = fv2; curr.next != null; curr = curr.next) {
        if (curr.index >= 0) {
          hm.put(curr.index, (hm.containsKey(curr.index) ? hm.get(curr.index) : 0) + rate * curr.value);
        }
      }

      RyanFeatureVector result = new RyanFeatureVector(-1, -1, null);
      TIntDoubleIterator hmIter = hm.iterator();
      while (hmIter.hasNext()) {
        hmIter.advance();
        result = new RyanFeatureVector(hmIter.key(), hmIter.value(), result);
      }
    return result;
View Full Code Here

    return result;
    }
 
    public static double dotProduct(RyanFeatureVector fv1, RyanFeatureVector fv2) {
  double result = 0.0;
  TIntDoubleHashMap hm1 = new TIntDoubleHashMap();
  TIntDoubleHashMap hm2 = new TIntDoubleHashMap();

  for(RyanFeatureVector curr = fv1; curr.next != null; curr = curr.next) {
      if(curr.index < 0)
    continue;
      hm1.put(curr.index,hm1.get(curr.index)+curr.value);
  }
  for(RyanFeatureVector curr = fv2; curr.next != null; curr = curr.next) {
      if(curr.index < 0)
    continue;
      hm2.put(curr.index,hm2.get(curr.index)+curr.value);
  }

  int[] keys = hm1.keys();

  for(int i = 0; i < keys.length; i++) {
      double v1 = hm1.get(keys[i]);
      double v2 = hm2.get(keys[i]);
      result += v1*v2;
  }
   
  return result;
   
View Full Code Here

  }
  return sum;
    }
 
    public static double twoNorm(RyanFeatureVector fv1) {
  TIntDoubleHashMap hm = new TIntDoubleHashMap();
  double sum = 0.0;
  for(RyanFeatureVector curr = fv1; curr.next != null; curr = curr.next) {
      if(curr.index < 0)
    continue;
      hm.put(curr.index,hm.get(curr.index)+curr.value);
  }
  int[] keys = hm.keys();

  for(int i = 0; i < keys.length; i++)
      sum += Math.pow(hm.get(keys[i]),2.0);
   
  return Math.sqrt(sum);
    }
View Full Code Here

TOP

Related Classes of gnu.trove.map.hash.TIntDoubleHashMap$TIntDoubleValueHashIterator

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.