Example usage for org.apache.commons.math.linear OpenMapRealVector setEntry

List of usage examples for org.apache.commons.math.linear OpenMapRealVector setEntry

Introduction

In this page you can find the example usage for org.apache.commons.math.linear OpenMapRealVector setEntry.

Prototype

public void setEntry(int index, double value) throws MatrixIndexException 

Source Link

Usage

From source file:datafu.pig.hash.lsh.util.DataTypeUtil.java

private RealVector convertBag(DataBag bag, int dim) throws PigException {
    OpenMapRealVector ret = new OpenMapRealVector(dim);
    for (Tuple t : bag) {
        if (t.size() != 2) {
            throw new PigException("Unable to convert tuple inside bag into a sparse vector."
                    + "  Expected tuples of size at least 2 of form (int, java.lang.Number)");
        }/*from   w ww .j a  v a2s . c  om*/
        Integer position = (Integer) t.get(0);
        double value = ((Number) t.get(1)).doubleValue();
        ret.setEntry(position, value);
    }
    return ret;
}