Example usage for java.io DataInput readDouble

List of usage examples for java.io DataInput readDouble

Introduction

In this page you can find the example usage for java.io DataInput readDouble.

Prototype

double readDouble() throws IOException;

Source Link

Document

Reads eight input bytes and returns a double value.

Usage

From source file:edu.umn.cs.spatialHadoop.osm.OSMEdge.java

@Override
public void readFields(DataInput in) throws IOException {
    edgeId = in.readLong();/* w  w w.  j  a  v a2s  . c o  m*/
    nodeId1 = in.readLong();
    lat1 = in.readDouble();
    lon1 = in.readDouble();
    nodeId2 = in.readLong();
    lat2 = in.readDouble();
    lon2 = in.readDouble();
    wayId = in.readLong();
    tags = in.readUTF();
}

From source file:hip.ch3.seqfile.writable.StockPriceWritable.java

@Override
public void readFields(DataInput in) throws IOException {
    symbol = WritableUtils.readString(in);
    date = WritableUtils.readString(in);
    open = in.readDouble();
    high = in.readDouble();//from ww w .  j  a va2  s .c  om
    low = in.readDouble();
    close = in.readDouble();
    low = in.readDouble();
    close = in.readDouble();
    volume = in.readInt();
    adjClose = in.readDouble();

}

From source file:ml.shifu.shifu.core.correlation.CorrelationWritable.java

@Override
public void readFields(DataInput in) throws IOException {
    this.columnIndex = in.readInt();
    this.sum = in.readDouble();
    this.sumSquare = in.readDouble();
    this.count = in.readDouble();

    int length = in.readInt();
    this.xySum = new double[length];
    for (int i = 0; i < length; i++) {
        this.xySum[i] = in.readDouble();
    }//from www.  ja  va  2  s. co m

    length = in.readInt();
    this.xxSum = new double[length];
    for (int i = 0; i < length; i++) {
        this.xxSum[i] = in.readDouble();
    }

    length = in.readInt();
    this.yySum = new double[length];
    for (int i = 0; i < length; i++) {
        this.yySum[i] = in.readDouble();
    }

    length = in.readInt();
    this.adjustCount = new double[length];
    for (int i = 0; i < length; i++) {
        this.adjustCount[i] = in.readDouble();
    }

    length = in.readInt();
    this.adjustSumX = new double[length];
    for (int i = 0; i < length; i++) {
        this.adjustSumX[i] = in.readDouble();
    }

    length = in.readInt();
    this.adjustSumY = new double[length];
    for (int i = 0; i < length; i++) {
        this.adjustSumY[i] = in.readDouble();
    }
}

From source file:ml.shifu.shifu.core.dtrain.dataset.PersistBasicFloatNetwork.java

private double[] readDoubleArray(DataInput in) throws IOException {
    int size = in.readInt();
    double[] array = new double[size];
    for (int i = 0; i < size; i++) {
        array[i] = in.readDouble();
    }/*from   w w w. j av  a2  s.  c o m*/
    return array;
}

From source file:ml.shifu.shifu.core.dtrain.dataset.PersistBasicFloatNetwork.java

public BasicFloatNetwork readNetwork(final DataInput in) throws IOException {
    final BasicFloatNetwork result = new BasicFloatNetwork();
    final FlatNetwork flat = new FlatNetwork();

    // read properties
    Map<String, String> properties = new HashMap<String, String>();
    int size = in.readInt();
    for (int i = 0; i < size; i++) {
        properties.put(ml.shifu.shifu.core.dtrain.StringUtils.readString(in),
                ml.shifu.shifu.core.dtrain.StringUtils.readString(in));
    }//from www .ja v a 2  s . co  m
    result.getProperties().putAll(properties);

    // read fields
    flat.setBeginTraining(in.readInt());
    flat.setConnectionLimit(in.readDouble());

    flat.setContextTargetOffset(readIntArray(in));
    flat.setContextTargetSize(readIntArray(in));

    flat.setEndTraining(in.readInt());
    flat.setHasContext(in.readBoolean());
    flat.setInputCount(in.readInt());

    flat.setLayerCounts(readIntArray(in));
    flat.setLayerFeedCounts(readIntArray(in));
    flat.setLayerContextCount(readIntArray(in));
    flat.setLayerIndex(readIntArray(in));
    flat.setLayerOutput(readDoubleArray(in));
    flat.setOutputCount(in.readInt());
    flat.setLayerSums(new double[flat.getLayerOutput().length]);
    flat.setWeightIndex(readIntArray(in));
    flat.setWeights(readDoubleArray(in));
    flat.setBiasActivation(readDoubleArray(in));

    // read activations
    flat.setActivationFunctions(new ActivationFunction[flat.getLayerCounts().length]);
    int acSize = in.readInt();
    for (int i = 0; i < acSize; i++) {
        String name = ml.shifu.shifu.core.dtrain.StringUtils.readString(in);
        if (name.equals("ActivationReLU")) {
            name = ActivationReLU.class.getName();
        } else if (name.equals("ActivationLeakyReLU")) {
            name = ActivationLeakyReLU.class.getName();
        } else if (name.equals("ActivationSwish")) {
            name = ActivationSwish.class.getName();
        } else if (name.equals("ActivationPTANH")) {
            name = ActivationPTANH.class.getName();
        } else {
            name = "org.encog.engine.network.activation." + name;
        }
        ActivationFunction af = null;
        try {
            final Class<?> clazz = Class.forName(name);
            af = (ActivationFunction) clazz.newInstance();
        } catch (final ClassNotFoundException e) {
            throw new PersistError(e);
        } catch (final InstantiationException e) {
            throw new PersistError(e);
        } catch (final IllegalAccessException e) {
            throw new PersistError(e);
        }
        double[] params = readDoubleArray(in);
        for (int j = 0; j < params.length; j++) {
            af.setParam(j, params[j]);
        }
        flat.getActivationFunctions()[i] = af;
    }

    // read subset
    int subsetSize = in.readInt();
    Set<Integer> featureList = new HashSet<Integer>();
    for (int i = 0; i < subsetSize; i++) {
        featureList.add(in.readInt());
    }
    result.setFeatureSet(featureList);

    result.getStructure().setFlat(flat);
    return result;
}

From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixBlock.java

/**
 * //  w  ww .  j ava  2 s.  co m
 * @param in
 * @throws IOException
 * @throws DMLRuntimeException 
 */
private void readSparseToDense(DataInput in) throws IOException, DMLRuntimeException {
    allocateDenseBlock(false); //allocate block
    Arrays.fill(denseBlock, 0);

    for (int r = 0; r < rlen; r++) {
        int nr = in.readInt();
        for (int j = 0; j < nr; j++) {
            int c = in.readInt();
            double val = in.readDouble();
            denseBlock[r * clen + c] = val;
        }
    }
}

From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixBlock.java

/**
 * /*from w  w  w.  ja  va 2  s. c  o  m*/
 * @param in
 * @throws IOException
 */
private void readUltraSparseBlock(DataInput in) throws IOException {
    allocateSparseRowsBlock(false); //adjust to size
    resetSparse(); //reset all sparse rows

    if (clen > 1) //ULTRA-SPARSE BLOCK
    {
        //block: read ijv-triples
        for (long i = 0; i < nonZeros; i++) {
            int r = in.readInt();
            int c = in.readInt();
            double val = in.readDouble();
            if (sparseRows[r] == null)
                sparseRows[r] = new SparseRow(1, clen);
            sparseRows[r].append(c, val);
        }
    } else //ULTRA-SPARSE COL
    {
        //col: read iv-pairs (should never happen since always dense)
        for (long i = 0; i < nonZeros; i++) {
            int r = in.readInt();
            double val = in.readDouble();
            if (sparseRows[r] == null)
                sparseRows[r] = new SparseRow(1, 1);
            sparseRows[r].append(0, val);
        }
    }
}

From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixBlock.java

/**
 * //  ww  w .  j a v  a2s.  c  o  m
 * @param in
 * @throws IOException
 * @throws DMLRuntimeException 
 */
private void readUltraSparseToDense(DataInput in) throws IOException, DMLRuntimeException {
    allocateDenseBlock(false); //allocate block
    Arrays.fill(denseBlock, 0);

    if (clen > 1) //ULTRA-SPARSE BLOCK
    {
        //block: read ijv-triples
        for (long i = 0; i < nonZeros; i++) {
            int r = in.readInt();
            int c = in.readInt();
            double val = in.readDouble();
            denseBlock[r * clen + c] = val;
        }
    } else //ULTRA-SPARSE COL
    {
        //col: read iv-pairs
        for (long i = 0; i < nonZeros; i++) {
            int r = in.readInt();
            double val = in.readDouble();
            denseBlock[r] = val;
        }
    }
}

From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixBlock.java

/**
 * /*w  ww . j  av  a  2 s  .c o  m*/
 * @param in
 * @throws IOException
 * @throws DMLRuntimeException 
 */
private void readDenseBlock(DataInput in) throws IOException, DMLRuntimeException {
    allocateDenseBlock(true); //allocate block, clear nnz

    int limit = rlen * clen;

    if (in instanceof MatrixBlockDataInput) //fast deserialize
    {
        MatrixBlockDataInput mbin = (MatrixBlockDataInput) in;
        nonZeros = mbin.readDoubleArray(limit, denseBlock);
    } else if (in instanceof DataInputBuffer && MRJobConfiguration.USE_BINARYBLOCK_SERIALIZATION) {
        //workaround because sequencefile.reader.next(key, value) does not yet support serialization framework
        DataInputBuffer din = (DataInputBuffer) in;
        MatrixBlockDataInput mbin = new FastBufferedDataInputStream(din);
        nonZeros = mbin.readDoubleArray(limit, denseBlock);
        ((FastBufferedDataInputStream) mbin).close();
    } else //default deserialize
    {
        for (int i = 0; i < limit; i++) {
            denseBlock[i] = in.readDouble();
            if (denseBlock[i] != 0)
                nonZeros++;
        }
    }
}

From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixBlock.java

/**
 * //from   w  ww .ja  va2s .c  o m
 * @param in
 * @throws IOException
 */
private void readSparseBlock(DataInput in) throws IOException {
    allocateSparseRowsBlock(false);
    resetSparse(); //reset all sparse rows

    if (in instanceof MatrixBlockDataInput) //fast deserialize
    {
        MatrixBlockDataInput mbin = (MatrixBlockDataInput) in;
        nonZeros = mbin.readSparseRows(rlen, sparseRows);
    } else if (in instanceof DataInputBuffer && MRJobConfiguration.USE_BINARYBLOCK_SERIALIZATION) {
        //workaround because sequencefile.reader.next(key, value) does not yet support serialization framework
        DataInputBuffer din = (DataInputBuffer) in;
        MatrixBlockDataInput mbin = new FastBufferedDataInputStream(din);
        nonZeros = mbin.readSparseRows(rlen, sparseRows);
        ((FastBufferedDataInputStream) mbin).close();
    } else //default deserialize
    {
        for (int r = 0; r < rlen; r++) {
            int nr = in.readInt();
            if (nr == 0) {
                if (sparseRows[r] != null)
                    sparseRows[r].reset(estimatedNNzsPerRow, clen);
                continue;
            }
            if (sparseRows[r] == null)
                sparseRows[r] = new SparseRow(nr);
            else
                sparseRows[r].reset(nr, clen);
            for (int j = 0; j < nr; j++)
                sparseRows[r].append(in.readInt(), in.readDouble());
        }
    }
}