Java Code Examples for com.carrotsearch.hppc.IntObjectOpenHashMap#lget()

The following examples show how to use com.carrotsearch.hppc.IntObjectOpenHashMap#lget() . 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: AbstractVectorBasedCalculation.java    From Palmetto with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public double[] calculateConfirmationValues(SubsetVectors subsetVectors) {
    int pos = 0;
    for (int i = 0; i < subsetVectors.segments.length; ++i) {
        pos += subsetVectors.conditions[i].length;
    }
    double values[] = new double[pos];

    IntObjectOpenHashMap<double[]> vectorCache = new IntObjectOpenHashMap<double[]>();
    for (int i = 0; i < subsetVectors.vectors.length; ++i) {
        vectorCache.put(1 << i, subsetVectors.vectors[i]);
    }
    double segmentVector[],
            conditionVector[];
    pos = 0;
    for (int i = 0; i < subsetVectors.segments.length; ++i) {
        if (vectorCache.containsKey(subsetVectors.segments[i])) {
            segmentVector = vectorCache.lget();
        } else {
            segmentVector = createVector(subsetVectors.segments[i], subsetVectors.vectors);
            vectorCache.put(subsetVectors.segments[i], segmentVector);
        }
        for (int j = 0; j < subsetVectors.conditions[i].length; ++j) {
            if (vectorCache.containsKey(subsetVectors.conditions[i][j])) {
                conditionVector = vectorCache.lget();
            } else {
                conditionVector = createVector(subsetVectors.conditions[i][j], subsetVectors.vectors);
                vectorCache.put(subsetVectors.conditions[i][j], conditionVector);
            }
            values[pos] = calculateSimilarity(segmentVector, conditionVector);
            ++pos;
        }
    }
    return values;
}
 
Example 2
Source File: CentroidConfirmationMeasure.java    From Palmetto with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public double[] calculateConfirmationValues(SubsetVectors subsetVectors) {
    double values[] = new double[subsetVectors.segments.length];

    double centroid[] = new double[subsetVectors.vectors[0].length];
    IntObjectOpenHashMap<double[]> vectorCache = new IntObjectOpenHashMap<double[]>();
    for (int i = 0; i < subsetVectors.vectors.length; ++i) {
        vectorCache.put(1 << i, subsetVectors.vectors[i]);
        for (int j = 0; j < centroid.length; j++) {
            centroid[j] += subsetVectors.vectors[i][j];
        }
    }
    // for (int j = 0; j < centroid.length; j++) {
    // centroid[j] /= subsetVectors.vectors.length;
    // }
    double segmentVector[];
    for (int i = 0; i < subsetVectors.segments.length; ++i) {
        if (vectorCache.containsKey(subsetVectors.segments[i])) {
            segmentVector = vectorCache.lget();
        } else {
            segmentVector = createVector(subsetVectors.segments[i], subsetVectors.vectors);
            vectorCache.put(subsetVectors.segments[i], segmentVector);
        }
        values[i] = calculateSimilarity(segmentVector, centroid);
    }
    return values;
}