当前位置: 首页>>代码示例>>Java>>正文


Java TIntDoubleMap类代码示例

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


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

示例1: TIntDoubleHashMap

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

示例2: getData

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
public static Data getData()
{
    if (data != null) return data;

    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

    Integer[] dimsObj = DimensionManager.getIDs();
    TIntDoubleMap map = new TIntDoubleHashMap(dimsObj.length);

    for (Integer dim : dimsObj)
    {
        map.put(dim, mean(server.worldTickTimes.get(dim)) * 1.0E-6D);
    }

    double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;

    int total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024);
    int max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024);
    int free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024);

    data = new Data(meanTickTime, map, free, total, max);
    return data;
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:24,代码来源:ServerHelper.java

示例3: calcSimilarity

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
/**
     * cosine similarity
     * @param v0
     * @param v1
     * @return
     */
    public double calcSimilarity(ConceptVector v0, ConceptVector v1) {
//        double sum = 0.0;
//        ConceptIterator it0 = v0.iterator();
//        while (it0.next()) {
//            double value1 = v1.get(it0.getId());
//            if (value1 > 0) {
//                sum +=  it0.getValue() * value1;
//            }
//        }
//
//        return sum / ( v0.getNorm2() *  v1.getNorm2());
        TIntDoubleMap X = new TIntDoubleHashMap();
        TIntDoubleMap Y = new TIntDoubleHashMap();
        ConceptIterator it = v0.iterator();
        while (it.next()) {
            X.put(it.getId(), it.getValue());
        }
        it = v1.iterator();
        while (it.next()) {
            Y.put(it.getId(), it.getValue());
        }
        return SimUtils.cosineSimilarity(X, Y);
    }
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:30,代码来源:ConceptVectorSimilarity.java

示例4: cosineSimilarity

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
public static double cosineSimilarity(TIntDoubleMap X, TIntDoubleMap 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

示例5: normalizeVector

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
/**
 * Normalize a vector to unit length.
 * @param X
 * @return
 */
public static TIntDoubleMap normalizeVector(TIntDoubleMap X) {
    TIntDoubleHashMap Y = new TIntDoubleHashMap();
    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, X.get(id) / norm);
        }
        return Y;
    }
    return X;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:21,代码来源:SimUtils.java

示例6: testInitialGetStrategyVarMap

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
@Test
public void testInitialGetStrategyVarMap() {
	Game kuhnGame = new Game();
	kuhnGame.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "kuhn.txt");

	// This test checks that strategy vars are initialized correctly
	CounterFactualRegretSolver solver = new CounterFactualRegretSolver(kuhnGame);
	TIntDoubleMap[] map = solver.getInformationSetActionProbabilitiesByActionId();
	
	for (int informationSetId = 0; informationSetId < kuhnGame.getNumInformationSets(1); informationSetId++) {
		int numActions = kuhnGame.getNumActionsAtInformationSet(1, informationSetId);
		for (int actionId = 0; actionId < numActions; actionId++) {
			assertEquals(1.0 / numActions, map[informationSetId].get(actionId), TestConfiguration.epsilon);
		}
	}
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:17,代码来源:TestCounterFactualRegretSolver.java

示例7: writeSimnilarity

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
protected void writeSimnilarity(int element1Id, double element1Score, TIntObjectIterator<ElementSimilarityScoring> it, boolean bR2L) throws SerializationException, IOException, NoScoreFoundException {
	TIntDoubleMap elementsScores = new TIntDoubleHashMap();
	while (it.hasNext()) {
		it.advance();
		int element2Id = it.key();
		if (elementFilter == null || elementFilter.isRelevantElementForCalculation(element2Id)) {
			double element2Score = elementFeatureScoreStorage.getElementScore(element2Id);
			ElementSimilarityScoring similarityScoring = it.value();
			double similarityScore = bR2L ?
						similarityScoring.getSimilarityScore(element2Score, element1Score) :
						similarityScoring.getSimilarityScore(element1Score, element2Score);
			if (similarityScore > 0)
				elementsScores.put(element2Id, similarityScore);
		}
	}
	
	LinkedHashMap<Integer, Double> sortedElementScores = SortUtil.sortMapByValue(elementsScores,true);
	
	if (vectorTruncater != null) 
		sortedElementScores = vectorTruncater.truncate(sortedElementScores);
		
	if (bR2L)
		outR2LDevice.write(element1Id, sortedElementScores);
	else
		outL2RDevice.write(element1Id, sortedElementScores);
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:27,代码来源:GeneralElementSimilarityCalculator.java

示例8: putAll

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

示例9: equals

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
/** {@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;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:29,代码来源:TIntDoubleHashMap.java

示例10: readExternal

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

    // VERSION
    in.readByte();

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

示例11: Data

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
public Data(double meanTickTime, TIntDoubleMap map, int free, int total, int max)
{
    this.meanTickTime = meanTickTime;
    this.tMap = map;
    this.free = free;
    this.total = total;
    this.max = max;
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:9,代码来源:Data.java

示例12: putAll

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

示例13: equals

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TIntDoubleMap ) ) {
        return false;
    }
    TIntDoubleMap that = ( TIntDoubleMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    TDoubleOffheapArray values = _values;
    TByteOffheapArray states = _states;
    double this_no_entry_value = getNoEntryValue();
    double that_no_entry_value = that.getNoEntryValue();
    for ( int i = capacity(); i-- > 0; ) {
        if ( states.get( i ) == FULL ) {
            int key = _set.get( i );
            double that_value = that.get( key );
            double 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,代码来源:TIntDoubleOffheapHashMap.java

示例14: readExternal

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

    // VERSION
    in.readByte();

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

示例15: encodeDbl

import gnu.trove.map.TIntDoubleMap; //导入依赖的package包/类
private static mt_dbl encodeDbl(TIntDoubleMap t_dbl, int timestampsSize) {
    LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_dbl));
    double[] values = new double[timestampsSize];
    int values_len = 0;
    for (int i = 0; i < values.length; ++i) {
        if (t_dbl.containsKey(i))
            values[values_len++] = t_dbl.get(i);
    }

    mt_dbl result = new mt_dbl();
    result.presence = createPresenceBitset(t_dbl.keySet(), timestampsSize);
    result.values = Arrays.copyOf(values, values_len);

    return result;
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:16,代码来源:MetricTable.java


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