final TIntDoubleMap distances = new TIntDoubleHashMap();
final TIntDoubleMap distances = new TIntDoubleHashMap(); for (StreetEdge e : candidateEdges) { distances.put(e.getId(), distance(vertex, e, xscale)); ); final TIntDoubleMap stopDistances = new TIntDoubleHashMap();
/** * Creates a new {@code SparseWeightedEdgeSet} where all edges in this set * must connect to {@code rootVertex}. */ public SparseWeightedEdgeSet(int rootVertex) { this.rootVertex = rootVertex; edges = new TIntDoubleHashMap(); }
public MapVal(int os) { this.os = os; this.Av = new TIntDoubleHashMap(32, 0.5f, 0, 0); this.mAv = new TIntDoubleHashMap(32, 0.5f, 0, 0); }
/** * Creates a new vector of the specified length * * @param length the length of this vector */ public SparseHashDoubleVector(int length) { maxLength = length; vector = new TIntDoubleHashMap(); nonZeroIndices = null; }
/** * Creates a new vector of the specified length * * @param length the length of this vector */ public SparseHashDoubleVector(int length) { maxLength = length; vector = new TIntDoubleHashMap(); }
/** * Constructor. * * @param size Expected size * @param def Default value */ public MapIntegerDBIDDoubleStore(int size, double def) { super(); map = new TIntDoubleHashMap(size, 0.5f, Integer.MIN_VALUE, def); }
/** * Constructor * @param length the length for this array * @param defaultValue the default value for array */ SparseArrayOfDoubles(int length, Double defaultValue) { super(Double.class, ArrayStyle.SPARSE, false); this.length = length; this.defaultValue = defaultValue != null ? defaultValue : Double.NaN; this.values = new TIntDoubleHashMap((int)Math.max(length * 0.5, 10d), 0.8f, -1, this.defaultValue); }
/** * Construct the array with the given length and capacity for non-zero elements * @param length the length * @param capacity the capacity */ public SparseHashedDoubleArray(int length, int capacity) { if (length < 0) throw new IllegalArgumentException("length must be >= 0"); if (capacity <= 0) throw new IllegalArgumentException("capacity must be > 0"); this.length = length; this.data = new TIntDoubleHashMap(capacity); }
/** * Construct the array with the given length and expected density * @param length the length * @param density the density */ public SparseHashedDoubleArray(int length, float density) { if (length < 0) throw new IllegalArgumentException("length must be >= 0"); if (density <= 0 || density > 1) throw new IllegalArgumentException("density must be > 0 and < 1"); this.length = length; int capacity = (int) (density * length); this.data = new TIntDoubleHashMap(capacity); }
@Override public SparseDoubleArray copy() { SparseHashedDoubleArray copy = new SparseHashedDoubleArray(length); copy.data = new TIntDoubleHashMap(data); return copy; }
@Override() public final Array<Double> copy() { try { final SparseArrayOfDoubles copy = (SparseArrayOfDoubles)super.clone(); copy.values = new TIntDoubleHashMap(values); copy.defaultValue = this.defaultValue; return copy; } catch (Exception ex) { throw new ArrayException("Failed to copy Array: " + this, ex); } }
/** * Creates a new vector using the non-zero values of the specified array. * The created vector contains no references to the provided array, so * changes to either will not be reflected in the other. * * @param values the intial values for this vector to have */ public SparseHashDoubleVector(double[] values) { maxLength = values.length; vector = new TIntDoubleHashMap(); nonZeroIndices = null; magnitude = -1; for (int i = 0; i < values.length; ++i) { if (values[i] != 0) { vector.put(i, values[i]); } } }
public float squaredL2NormUnsafe() { TIntDoubleHashMap vec = new TIntDoubleHashMap(size<<1); for (int i = 0; i < size; ++i) vec.adjustOrPutValue(x[i], va[i], va[i]); float sum = 0; for (double v : vec.values()) sum += v*v; return sum; }
public float squaredL2NormUnsafe() { TIntDoubleHashMap vec = new TIntDoubleHashMap(size<<1); for (int i = 0; i < size; ++i) vec.adjustOrPutValue(x[i], va[i], va[i]); float sum = 0; for (double v : vec.values()) sum += v*v; return sum; }
@Override public SparseDoubleArray reverse() { //TODO: this could be more efficient and avoid the copy TIntDoubleHashMap tmp = new TIntDoubleHashMap(data.size()); for (Entry e : entries()) tmp.put(length - e.index, e.value); this.data = tmp; return this; } }
protected TIntObjectMap<TIntDoubleMap> device2map(PersistenceDevice device) throws Exception { TIntObjectMap<TIntDoubleMap> ret = new TIntObjectHashMap<TIntDoubleMap>(); Pair<Integer, Serializable> pair = null; while ((pair = device.read()) != null) { TIntDoubleMap map = new TIntDoubleHashMap(); @SuppressWarnings("unchecked") LinkedHashMap<Integer, Double> linkedhashmap = (LinkedHashMap<Integer,Double>)pair.getSecond(); for (Entry<Integer,Double> entry : linkedhashmap.entrySet()) map.put(entry.getKey(), entry.getValue()); ret.put(pair.getFirst(),map); } return ret; } }
public PrecisionRecallAccumulator getPrecisionRecall(int n, double threshold) { PrecisionRecallAccumulator pr = new PrecisionRecallAccumulator(n, threshold); TIntDoubleMap actual = new TIntDoubleHashMap(); for (KnownSim ks : known.getMostSimilar()) { pr.observe(ks.similarity); actual.put(ks.wpId2, ks.similarity); } for (Observation o : observations) { if (o.rank > n) { break; } pr.observeRetrieved(actual.get(o.id)); } return pr; }
@Override public V restore(V featureVector) { TIntDoubleHashMap vals = new TIntDoubleHashMap(); for(int it = featureVector.iter(); featureVector.iterValid(it); it = featureVector.iterAdvance(it)) { final int dim = featureVector.iterDim(it); vals.put(dim, featureVector.iterDoubleValue(it) / idf.get(dim)); } return ((SparseNumberVector.Factory<V>) factory).newNumberVector(vals, featureVector.getDimensionality()); }
@Override protected V filterSingleObject(V featureVector) { TIntDoubleHashMap vals = new TIntDoubleHashMap(); for(int it = featureVector.iter(); featureVector.iterValid(it); it = featureVector.iterAdvance(it)) { final int dim = featureVector.iterDim(it); vals.put(dim, featureVector.iterDoubleValue(it) * idf.get(dim)); } return ((SparseNumberVector.Factory<V>) factory).newNumberVector(vals, featureVector.getDimensionality()); }