本文整理汇总了Java中gnu.trove.map.TIntFloatMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java TIntFloatMap.get方法的具体用法?Java TIntFloatMap.get怎么用?Java TIntFloatMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntFloatMap
的用法示例。
在下文中一共展示了TIntFloatMap.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cosineSimilarity
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
public static double cosineSimilarity(TIntFloatMap X, TIntFloatMap Y) {
double xDotX = 0.0;
double yDotY = 0.0;
double xDotY = 0.0;
for (int id : X.keys()) {
double x = X.get(id);
xDotX += x * x;
if (Y.containsKey(id)) {
xDotY += x * Y.get(id);
}
}
for (double y : Y.values()) {
yDotY += y * y;
}
return xDotX * yDotY != 0 ? xDotY / Math.sqrt(xDotX * yDotY): 0.0;
}
示例2: compare
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
public double compare(
TIntFloatMap v1,
TIntFloatMap v2,
boolean sorted)
{
//it does not matter if the vectors are sorted or not
double DKL = 0.0;
TIntFloatIterator iter = v1.iterator();
while (iter.hasNext())
{
iter.advance();
int key = iter.key();
if (!v2.containsKey(key))
{
continue;
}
double P = iter.value();
double Q = v2.get(key);
DKL += Math.log(P/Q) * P;
}
return DKL;
}
示例3: equals
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntFloatMap ) ) {
return false;
}
TIntFloatMap that = ( TIntFloatMap ) other;
if ( that.size() != this.size() ) {
return false;
}
float[] values = _values;
byte[] states = _states;
float this_no_entry_value = getNoEntryValue();
float that_no_entry_value = that.getNoEntryValue();
for ( int i = values.length; i-- > 0; ) {
if ( states[i] == FULL ) {
int key = _set[i];
float that_value = that.get( key );
float 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;
}
示例4: equals
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntFloatMap ) ) {
return false;
}
TIntFloatMap that = ( TIntFloatMap ) other;
if ( that.size() != this.size() ) {
return false;
}
TFloatOffheapArray values = _values;
TByteOffheapArray states = _states;
float this_no_entry_value = getNoEntryValue();
float that_no_entry_value = that.getNoEntryValue();
for ( int i = capacity(); i-- > 0; ) {
if ( states.get( i ) == FULL ) {
int key = _set.get( i );
float that_value = that.get( key );
float this_value = values.get( i );
if ( ( this_value != that_value ) &&
( this_value != this_no_entry_value ) &&
( that_value != that_no_entry_value ) ) {
return false;
}
}
}
return true;
}
示例5: makeOutlinkVector
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
private TIntFloatMap makeOutlinkVector(TIntSet links) {
TIntFloatMap vector = new TIntFloatHashMap();
for (int wpId : links.toArray()) {
vector.put(wpId, (float) Math.log(1.0 * linkCache.getTotalPages() / linkCache
.getInlinks(wpId).size()));
}
if(wlmExtended) {
TIntFloatMap vector2 = new TIntFloatHashMap();
//考虑二级链接
for (int id1 : links.toArray()) {
for (int id2 : linkCache.getOutlinks(id1).toArray()) {
double tfidf = Math.log(1.0 * linkCache.getTotalPages()
/ linkCache.getInlinks(id2).size());
float w = (float) tfidf * vector.get(id1);
float old = 0;
if (vector2.containsKey(id2)) {
old = vector2.get(id2);
}
vector2.put(id2, old + w);
}
}
vector.putAll(vector2);
}
return vector;
}