Package gnu.trove.map

Examples of gnu.trove.map.TIntFloatMap


    @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;
View Full Code Here


        return SortOrder.Asc;
    }

    @Override
    public float score(String srcVKey, int srcId, float[] source, String tgtVKey, int tgtId, float[] target) {
        TIntFloatMap sourceInfoCache = caches.get(srcVKey);
        TIntFloatMap targetInfoCache = caches.get(tgtVKey);

        TIntFloatMap sourceSumCache = caches.get("length:" + srcVKey);
        TIntFloatMap targetSumCache = caches.get("length:" + tgtVKey);
        float srcSum = sourceSumCache.get(srcId);
        float tgtSum = targetSumCache.get(tgtId);

        float scoring = 0f;
        int len = source.length;
        for (int i = 0; i < len; i++) {
            float p = source[i] / srcSum;
View Full Code Here

    }

    @Override
    public float score(String srcVKey, int srcId, int[] source, int srclen, String tgtVKey, int tgtId, int[] target,
            int tgtlen) {
        TIntFloatMap sourceInfoCache = caches.get(srcVKey);
        TIntFloatMap targetInfoCache = caches.get(tgtVKey);

        TIntFloatMap sourceSumCache = caches.get("length:" + srcVKey);
        TIntFloatMap targetSumCache = caches.get("length:" + tgtVKey);
        float srcSum = sourceSumCache.get(srcId);
        float tgtSum = targetSumCache.get(tgtId);

        float scoring = 0f;
        int idx1 = 0, idx2 = 0;
        while (idx1 < srclen && idx2 < tgtlen) {
            if (source[idx1] < 0 || target[idx2] < 0) {
View Full Code Here

        return SortOrder.Desc;
    }

    @Override
    public float score(String srcVKey, int srcId, float[] source, String tgtVKey, int tgtId, float[] target) {
        TIntFloatMap sourceCache = caches.get(srcVKey);
        TIntFloatMap targetCache = caches.get(tgtVKey);

        float scoring = 0;
        int len = source.length;
        for (int i = 0; i < len; i++) {
            scoring += source[i] * target[i];
        }

        scoring = scoring * scoring / sourceCache.get(srcId) / targetCache.get(tgtId);

        return scoring;
    }
View Full Code Here

    }

    @Override
    public float score(String srcVKey, int srcId, int[] source, int srclen, String tgtVKey, int tgtId, int[] target,
            int tgtlen) {
        TIntFloatMap sourceCache = caches.get(srcVKey);
        TIntFloatMap targetCache = caches.get(tgtVKey);

        float scoring = 0f;
        int idx1 = 0, idx2 = 0;
        if (idx1 < srclen && idx2 < tgtlen) {
            while (true) {
                if (source[idx1] < target[idx2]) {
                    idx1 += 2;
                    if (idx1 >= srclen)
                        break;
                } else if (source[idx1] > target[idx2]) {
                    idx2 += 2;
                    if (idx2 >= tgtlen)
                        break;
                } else {
                    scoring += source[idx1 + 1] * target[idx2 + 1];
                    idx1 += 2;
                    idx2 += 2;
                    if (idx1 >= srclen || idx2 >= tgtlen)
                        break;
                }
            }
        }

        scoring = scoring * scoring / sourceCache.get(srcId) / targetCache.get(tgtId);

        return scoring;
    }
View Full Code Here

        validateParams(vecid, pairs);
        if (!indexer.containsKey(vecid)) {
            _add(vecid, pairs);
        } else {
            TIntList indexes = new TIntArrayList();
            TIntFloatMap results = new TIntFloatHashMap();

            float max = Float.NEGATIVE_INFINITY;
            int cursor = indexer.get(vecid);
            int length = lengths.get(vecid);
            while (length > 0) {
                int pos = (int) data.get(cursor++);
                float val = data.get(cursor++);
                results.put(pos, val);
                if (val > max) {
                    max = val;
                }
                indexes.add(pos);
                length -= 2;
            }

            cursor = 0;
            while (cursor < pairs.length) {
                int pos = pairs[cursor++];
                float val = (float) pairs[cursor++];
                if (results.containsKey(pos)) {
                    val = results.get(pos) + val;
                    results.put(pos, val);
                    if (val > max) {
                        max = val;
                    }
                } else {
                    results.put(pos, val);
                    indexes.add(pos);
                }
            }
            indexes.sort();

            int start = data.size();
            indexer.put(vecid, start);
            lengths.put(vecid, indexes.size() * 2);
            TIntIterator iter = indexes.iterator();
            if (max < accumuFactor * sparseFactor) {
                while (iter.hasNext()) {
                    int key = iter.next();
                    float value = results.get(key);
                    data.add(key);
                    data.add(value);
                }
            } else {
                while (iter.hasNext()) {
                    int key = iter.next();
                    float value = results.get(key) * accumuFactor / max;
                    data.add(key);
                    data.add(value);
                }
            }

View Full Code Here

TOP

Related Classes of gnu.trove.map.TIntFloatMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.