/** {@inheritDoc} */ public void putAll( Map<? extends Integer, ? extends Double> map ) { ensureCapacity( map.size() ); // could optimize this for cases when map instanceof THashMap for ( Map.Entry<? extends Integer, ? extends Double> entry : map.entrySet() ) { this.put( entry.getKey().intValue(), entry.getValue().doubleValue() ); } }
/** {@inheritDoc} */ public int[] toArray() { return TIntDoubleHashMap.this.keys(); }
/** {@inheritDoc} */ public int[] keys() { int[] keys = new int[size()]; int[] k = _set; byte[] states = _states; for ( int i = k.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { keys[j++] = k[i]; } } return keys; }
/** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { int key = in.readInt(); double val = in.readDouble(); put(key, val); } } } // TIntDoubleHashMap
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TIntDoubleMap ) ) { return false; } TIntDoubleMap that = ( TIntDoubleMap ) other; if ( that.size() != this.size() ) { return false; } double[] values = _values; byte[] states = _states; double this_no_entry_value = getNoEntryValue(); double that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { int key = _set[i]; double that_value = that.get( key ); double this_value = values[i]; if ( ( this_value != that_value ) && ( this_value != this_no_entry_value ) && ( that_value != that_no_entry_value ) ) { return false; } } } return true; }
TIntDoubleHashMap scoreMap = new TIntDoubleHashMap(); for (int id : allIds.toArray()) { scoreMap.put(id, mostSimilarCoefficients.get(0)); c1, result.getScore(), c2, rank, Math.log(rank)); scoreMap.adjustValue(result.getId(), value); + c2 * Math.log(mostSimilarInterpolator.getInterpolatedRank(i/2)); for (int id : unknownIds.toArray()) { scoreMap.adjustValue(id, value); for (int id : scoreMap.keys()){ resultList.add(new SRResult(id,scoreMap.get(id)));
final TIntDoubleMap distances = new TIntDoubleHashMap();
@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()); }
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; } }
/** {@inheritDoc} */ public double[] toArray( double[] dest ) { return TIntDoubleHashMap.this.values( dest ); }
@Override public void update(int nb_probes) { double activity, oldmA, U; for (int k : Av.keys()) { activity = Av.get(k); oldmA = mAv.get(k); U = activity - oldmA; mAv.adjustValue(k, U / nb_probes); } }
/** {@inheritDoc} */ public void clear() { TIntDoubleHashMap.this.clear(); }
/** * {@inheritDoc} */ public double get(int index) { return vector.get(index); }
/** {@inheritDoc} */ public boolean containsAll( int[] array ) { for ( int element : array ) { if ( ! TIntDoubleHashMap.this.contains( element ) ) { return false; } } return true; }
/** * Creates a new <code>TIntDoubleHashMap</code> instance containing * all of the entries in the map passed in. * * @param keys a <tt>int</tt> array containing the keys for the matching values. * @param values a <tt>double</tt> array containing the values. */ public TIntDoubleHashMap( int[] keys, double[] values ) { super( Math.max( keys.length, values.length ) ); int size = Math.min( keys.length, values.length ); for ( int i = 0; i < size; i++ ) { this.put( keys[i], values[i] ); } }