• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TIntFloatMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gnu.trove.map.TIntFloatMap的典型用法代码示例。如果您正苦于以下问题:Java TIntFloatMap类的具体用法?Java TIntFloatMap怎么用?Java TIntFloatMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TIntFloatMap类属于gnu.trove.map包,在下文中一共展示了TIntFloatMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: TIntFloatHashMap

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
/**
 * Creates a new <code>TIntFloatHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntFloatMap</tt> that will be duplicated.
 */
public TIntFloatHashMap( TIntFloatMap map ) {
    super( map.size() );
    if ( map instanceof TIntFloatHashMap ) {
        TIntFloatHashMap hashmap = ( TIntFloatHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( float ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:26,代码来源:TIntFloatHashMap.java


示例2: 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;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:18,代码来源:SimUtils.java


示例3: normalizeVector

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
/**
 * Normalize a vector to unit length.
 * @param X
 * @return
 */
public static TIntFloatMap normalizeVector(TIntFloatMap X) {
    TIntFloatHashMap Y = new TIntFloatHashMap();
    double sumSquares = 0.0;
    for (double x : X.values()) {
        sumSquares += x * x;
    }
    if (sumSquares != 0.0) {
        double norm = Math.sqrt(sumSquares);
        for (int id : X.keys()) {
            Y.put(id, (float) (X.get(id) / norm));
        }
        return Y;
    }
    return X;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:21,代码来源:SimUtils.java


示例4: compare

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
public double compare(
		TIntFloatMap v1,
		TIntFloatMap v2,
		boolean sorted) 
{
           int overlaps = 0;
	
           TIntIterator iter = v1.keySet().iterator();
           while (iter.hasNext())
           {
               int key = iter.next();
               if (v2.containsKey(key))
                   overlaps++;
           }
           
           return overlaps / (double)(v1.size() + v2.size() - overlaps);
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:18,代码来源:Jaccard.java


示例5: 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;

}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:27,代码来源:KLDivergence.java


示例6: getSortedIndices

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
public static int[] getSortedIndices(TIntFloatMap vector)
{
    // NOTE: it's probably possible to do this using purely primitive
    // operations without having to resort to pushing things into an
    // Index[].  However, this code is much cleaner to have and since we
    // sort at most once per vector and the result is memoized, we don't
    // lose too much from the Object-based sorting.
    Index[] keyValPairs = new Index[vector.size()];
    TIntFloatIterator iter = vector.iterator();
    int i = 0;
    while (iter.hasNext())
    {
            iter.advance();
            keyValPairs[i++] = new Index(iter.key(), iter.value());
    }

    Arrays.sort(keyValPairs);
    int[] sortedIndices = new int[keyValPairs.length];
    for (i = 0; i < keyValPairs.length; ++i)
        sortedIndices[i] = keyValPairs[i].key;
    
    return sortedIndices;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:24,代码来源:SemSigUtils.java


示例7: normalizeVector

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
/**
 * Normalizes the probability values in a vector so that to sum to 1.0
 * @param vector
 * @return
 */
public static TIntFloatMap normalizeVector(TIntFloatMap vector)
{
	float total = 0;

               TFloatIterator iter = vector.valueCollection().iterator();
               while (iter.hasNext())
                      total += iter.next();
               
               TIntFloatMap normalized = new TIntFloatHashMap(vector.size());
	
               TIntFloatIterator iter2 = vector.iterator();
               while (iter2.hasNext())
               {
                       iter2.advance();
                       normalized.put(iter2.key(), iter2.value() / total);
               }		
	return normalized;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:24,代码来源:SemSigUtils.java


示例8: testGetSortedIndices

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
@Test
public void testGetSortedIndices() 
{
           TIntFloatMap m = new TIntFloatHashMap();
           m.put(0, 1f);
           m.put(1, 10f);
           m.put(2, 5f);
           m.put(3, 2f);

           int[] sorted = SemSigUtils.getSortedIndices(m);
           assertEquals(4, sorted.length);
           assertEquals(1, sorted[0]);
           assertEquals(2, sorted[1]);
           assertEquals(3, sorted[2]);
           assertEquals(0, sorted[3]);
       }
 
开发者ID:pilehvar,项目名称:ADW,代码行数:17,代码来源:SemSigUtilsTest.java


示例9: putAll

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
/** {@inheritDoc} */
public void putAll( TIntFloatMap map ) {
    ensureCapacity( map.size() );
    TIntFloatIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:10,代码来源:TIntFloatHashMap.java


示例10: 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;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:29,代码来源:TIntFloatHashMap.java


示例11: readExternal

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // MAP
    _map = ( TIntFloatMap ) in.readObject();
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:10,代码来源:TIntFloatMapDecorator.java


示例12: putAll

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void putAll( TIntFloatMap map ) {
    ensureCapacity( map.size() );
    TIntFloatIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:11,代码来源:TIntFloatHashMap.java


示例13: 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;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:29,代码来源:TIntFloatOffheapHashMap.java


示例14: readExternal

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
@Override
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // MAP
    _map = ( TIntFloatMap ) in.readObject();
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:11,代码来源:TIntFloatMapDecorator.java


示例15: cosineOutlink

import gnu.trove.map.TIntFloatMap; //导入依赖的package包/类
public double cosineOutlink(int pageId1, int pageId2) {
    TIntSet outlinks1 = linkCache.getOutlinks(pageId1);
    TIntSet outlinks2 = linkCache.getOutlinks(pageId2);

    TIntFloatMap v1 = makeOutlinkVector(outlinks1);
    TIntFloatMap v2 = makeOutlinkVector(outlinks2);
    if (v1.isEmpty() || v2.isEmpty()) {
        return 0.0;
    }

    return SimUtils.cosineSimilarity(v1, v2);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:13,代码来源:LinkRelatedness.java



注:本文中的gnu.trove.map.TIntFloatMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PlayMode类代码示例发布时间:2022-05-21
下一篇:
Java BuildLauncher类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap