Package java.io

Examples of java.io.DataInputStream.readFloat()


   * @return the version value of saved file
   * @throws Exception if it fails to read value
   */
  protected float readVersionFile(File file) throws Exception {
    DataInputStream dis = new DataInputStream(new FileInputStream(file));
    float version = dis.readFloat();
    dis.close();
    return version;
  }

  /**
 
View Full Code Here


            } else {
                src = bytes;
            }
            DataInputStream stream =
                  new DataInputStream(new ByteArrayInputStream(src, offset, 4));
            return stream.readFloat();
        } catch (Exception ex) {
            throw new DescriptorException(ex);
        }
    }
View Full Code Here

                int nzInCurCol = dis.readInt();        
                dos.writeInt(nzInCurCol);
                // Transform all non zero values for the new matrix.
                for (int index = 0; index < nzInCurCol; ++index) {
                    int row = dis.readInt();
                    double value = dis.readFloat();
                    dos.writeInt(row);
                    dos.writeFloat(
                            (float) transform.transform(row, col, value));
                }
            }
View Full Code Here

        for (; entriesSeen < entries; ++col) {
            int nonZero = dis.readInt();

            for (int i = 0; i < nonZero; ++i, ++entriesSeen) {
                int row = dis.readInt();
                float val = dis.readFloat();
                if (transpose)
                    pw.println((1 + col) + " " + (1 + row) + " " + val);
                else
                    pw.println((1 + row) + " " + (1 + col) + " " + val);
            }
View Full Code Here

            : Matrices.create(rows, cols, matrixType);
       
        if (transposeOnRead) {
            for (int row = 0; row < rows; ++row) {
                for (int col = 0; col < cols; ++col) {
                    m.set(col, row, dis.readFloat());
                }
            }
        }
        else {
            for (int row = 0; row < rows; ++row) {
View Full Code Here

            }
        }
        else {
            for (int row = 0; row < rows; ++row) {
                for (int col = 0; col < cols; ++col) {
                    m.set(row, col, dis.readFloat());
                }
            }
        }
        dis.close();
        return m;
View Full Code Here

                int nzInCol = dis.readInt();
                int[] indices = new int[nzInCol];
                double[] vals = new double[nzInCol];
                for (int i = 0; i < nzInCol; ++i, ++entriesSeen) {
                    indices[i] = dis.readInt();
                    vals[i] = dis.readFloat();
                }
                SparseDoubleVector rowVec =
                    new CompactSparseVector(indices, vals, rows);
                rowArr[curRow] = rowVec;
                ++curRow;               
View Full Code Here

            int entriesSeen = 0;
            int col = 0;
            for (; entriesSeen < nz; ++col) {
                int nzInCol = dis.readInt();
                for (int i = 0; i < nzInCol; ++i, ++entriesSeen) {
                    m.set(dis.readInt(), col, dis.readFloat());
                }
            }
        }
        dis.close();
View Full Code Here

            dos.writeInt(cols);

            // Traverse each row and column value, transforming each entry.
            for (int row = 0; row < rows; ++row) {
                for (int col = 0; col < cols; ++col) {
                    double val = dis.readFloat();
                    dos.writeFloat((float) transform.transform(row, col, val));
                }
            }

            dos.close();
View Full Code Here

    @Override
    public Float bytesToFloat(byte[] b) {
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b));
        try {
            return new Float(dis.readFloat());
        } catch (IOException e) {
            LogUtils.warn(this, "Unable to convert bytearray to float, " +
                    "caught IOException <" + e.getMessage() + ">",
                    PigWarning.FIELD_DISCARDED_TYPE_CONVERSION_FAILED,
                    mLog);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.