Example usage for com.google.common.collect ArrayTable get

List of usage examples for com.google.common.collect ArrayTable get

Introduction

In this page you can find the example usage for com.google.common.collect ArrayTable get.

Prototype

@Override
    public V get(@Nullable Object rowKey, @Nullable Object columnKey) 

Source Link

Usage

From source file:eu.itesla_project.sampling.util.Utils.java

public static double[][] histoDataAsDoubleMatrix(ArrayTable<Integer, String, Float> hdTable) {

    int rowsSize = hdTable.rowKeySet().size();
    int colsSize = hdTable.columnKeySet().size();
    double[][] matFinal = new double[rowsSize][colsSize];
    for (int i = 0; i < rowsSize; i++) {
        for (int j = 0; j < colsSize; j++) {
            Float v = hdTable.get(i, j);
            matFinal[i][j] = ((v != null) && (v.isNaN() == false)) ? v : 0.0f;
        }//w  ww .  j av a  2  s  .  c  o m
    }
    return matFinal;
}

From source file:eu.itesla_project.sampling.util.Utils.java

public static double[][] histoDataAsDoubleMatrixNew(ArrayTable<Integer, String, Float> hdTable) {
    int rowsSize = hdTable.rowKeySet().size();
    int colsSize = hdTable.columnKeySet().size();
    double[][] matFinal = new double[rowsSize][colsSize];
    int i = 0;// w w  w  .  j a v  a2 s . co  m
    for (Integer rowKey : hdTable.rowKeyList()) {
        int j = 0;
        for (String colkey : hdTable.columnKeyList()) {
            Float v = hdTable.get(rowKey, colkey);
            matFinal[i][j] = ((v != null) && (v.isNaN() == false)) ? v : 0.0f;
            j = j + 1;
        }
        i = i + 1;
    }
    return matFinal;
}

From source file:eu.itesla_project.mcla.forecast_errors.FEAMatFileWriter.java

private MLDouble histoDataAsMLDouble(String name, ArrayTable<Integer, String, Float> histoData) {
    int rowsSize = histoData.rowKeySet().size();
    int colsSize = histoData.columnKeySet().size();
    MLDouble mlDouble = new MLDouble(name, new int[] { rowsSize, colsSize });
    int i = 0;/*from w  ww. ja v a  2 s  .c o  m*/
    for (Integer rowKey : histoData.rowKeyList()) {
        int j = 0;
        for (String colkey : histoData.columnKeyList()) {
            Float v = histoData.get(rowKey, colkey);
            mlDouble.set(new Double(v), i, j);
            j++;
        }
        i++;
    }
    return mlDouble;
}

From source file:lu.list.itis.dkd.aig.match.ClusterGenerator.java

/**
 * Helper method used to populate the distance matrix.
 *
 * @param matches//from  www.  j  ava 2 s . c  om
 *        The matches used to populate the symmetric distance matrix.
 * @return The populated matrix.
 * @throws SimilarityComputationException
 * @throws InitializationException
 *         Thrown when the initialization of the bridge failed. This is most likely due to
 *         either the connection to the knowledge base failing or the engine not properly
 *         initializing.
 */
public ArrayTable<Match, Match, Float> computeDistances(final List<Match> matches) {
    final ArrayTable<Match, Match, Float> distanceMatrix = ArrayTable.create(matches, matches);
    for (final Match match : matches) {
        for (final Match that : matches) {
            if (distanceMatrix.get(match, that) != null) {
                continue;
            }
            if (match == that) {
                distanceMatrix.put(match, that, 1f);
                distanceMatrix.put(that, match, 1f);
                continue;
            }
            final float similarity = SimilarityProvider.getInstance().compare(match.getAnswerVariable(),
                    that.getAnswerVariable());
            distanceMatrix.put(match, that, similarity);
            distanceMatrix.put(that, match, similarity);
        }
    }
    return distanceMatrix;
}