Java Code Examples for gnu.trove.map.hash.TIntFloatHashMap#containsKey()
The following examples show how to use
gnu.trove.map.hash.TIntFloatHashMap#containsKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KMeansWordCluster.java From fnlp with GNU Lesser General Public License v3.0 | 6 votes |
private float distanceEuclidean(int n, HashSparseVector sv, float baseDistance) { HashSparseVector center = classCenter.get(n); int count = classCount.get(n); float dist = baseDistance / (count * count); TIntFloatHashMap data = center.data; TIntFloatIterator it = sv.data.iterator(); while (it.hasNext()) { it.advance(); int key = it.key(); if (!data.containsKey(key)) { dist += it.value() * it.value(); } else { float temp = data.get(key) / count; dist -= temp * temp; dist += (it.value() - temp) * (it.value() - temp); } } return dist; }
Example 2
Source File: KMeansWordCluster.java From fnlp with GNU Lesser General Public License v3.0 | 6 votes |
private void updateBaseDist(int classid, HashSparseVector vector) { float base = baseDistList.get(classid); TIntFloatHashMap center = classCenter.get(classid).data; TIntFloatIterator it = vector.data.iterator(); while (it.hasNext()) { it.advance(); if (!center.containsKey(it.key())) { base += it.value() * it.value(); } else { float temp = center.get(it.key()); base -= temp * temp; base += (it.value() - temp) * (it.value() - temp); } } baseDistList.set(classid, base); }
Example 3
Source File: MyArrays.java From fnlp with GNU Lesser General Public License v3.0 | 3 votes |
/** * 对部分下标的元素赋零 * * @param data * 数组 * @param idx * 赋值下标 */ public static void setZero(TIntFloatHashMap data, int[] idx) { for(int i = 0; i < idx.length; i++) { if (data.containsKey(idx[i])) { data.remove(idx[i]); } } }
Example 4
Source File: MyHashSparseArrays.java From fnlp with GNU Lesser General Public License v3.0 | 3 votes |
/** * 对部分下标的元素赋零 * * @param data * 数组 * @param idx * 赋值下标 */ public static void setZero(TIntFloatHashMap data, int[] idx) { for(int i = 0; i < idx.length; i++) { if (data.containsKey(idx[i])) { data.remove(idx[i]); } } }