Package org.apache.mahout.math

Examples of org.apache.mahout.math.MatrixWritable.readFields()


  private static void addToSavedCopy(File file, Matrix matrix) throws IOException {
    MatrixWritable mw = new MatrixWritable();
    if (file.exists()) {
      DataInputStream in = new DataInputStream(new FileInputStream(file));
      try {
        mw.readFields(in);
      } finally {
        in.close();
      }
      mw.get().assign(matrix, Functions.PLUS);
    } else {
View Full Code Here


    // step 1, compute R as in R'R = Y'Y where Y = A \Omega
    for (File file : partsOfA) {
      MatrixWritable m = new MatrixWritable();
      DataInputStream in = new DataInputStream(new FileInputStream(file));
      try {
        m.readFields(in);
      } finally {
        in.close();
      }

      Matrix aI = m.get();
View Full Code Here

    int ncols = 0;
    for (File file : partsOfA) {
      MatrixWritable m = new MatrixWritable();
      final DataInputStream in = new DataInputStream(new FileInputStream(file));
      try {
        m.readFields(in);
      } finally {
        in.close();
      }
      Matrix aI = m.get();
      ncols = Math.max(ncols, aI.columnSize());
View Full Code Here

    MatrixWritable bTmp = new MatrixWritable();
    for (int j = 0; j < ncols; j += columnsPerSlice) {
      if (bFile(tmpDir, j).exists()) {
        final DataInputStream in = new DataInputStream(new FileInputStream(bFile(tmpDir, j)));
        try {
          bTmp.readFields(in);
        } finally {
          in.close();
        }

        b2.assign(bTmp.get().times(bTmp.get().transpose()), Functions.PLUS);
View Full Code Here

      final File bPath = bFile(tmpDir, j);
      if (bPath.exists()) {
        MatrixWritable m = new MatrixWritable();
        final DataInputStream in = new DataInputStream(new FileInputStream(bPath));
        try {
          m.readFields(in);
        } finally {
          in.close();
        }
        m.set(l2.solveRight(m.get().transpose()).times(svd.getV()));
        final DataOutputStream out = new DataOutputStream(new FileOutputStream(new File(tmpDir, String.format("V-%s", bPath.getName().replaceAll(".*-", "")))));
View Full Code Here

        if (!fs.exists(inverseCovarianceFile.get())) {
          throw new FileNotFoundException(inverseCovarianceFile.get().toString());
        }
        DataInputStream in = fs.open(inverseCovarianceFile.get());
        try {
          inverseCovarianceMatrix.readFields(in);
        } finally {
          Closeables.closeQuietly(in);
        }
        this.inverseCovarianceMatrix = inverseCovarianceMatrix.get();
        Preconditions.checkArgument(this.inverseCovarianceMatrix != null, "inverseCovarianceMatrix not initialized");
View Full Code Here

    MatrixWritable m = new MatrixWritable();

    int row = 0;
    for (File file : files) {
      DataInputStream in = new DataInputStream(new FileInputStream(file));
      m.readFields(in);
      in.close();
      if (nrows == -1) {
        // now we can set an upper bound on how large our result will be
        nrows = m.get().rowSize() * files.size();
        ncols = m.get().columnSize();
View Full Code Here

    ByteArrayInputStream bis = new ByteArrayInputStream(buf);
    try {
      ObjectInputStream ois = new ObjectInputStream(bis);
      if (isMatrix) {
        MatrixWritable w = new MatrixWritable();
        w.readFields(ois);
        ret = (T) w.get();
      } else {
        VectorWritable w = new VectorWritable();
        w.readFields(ois);
        ret = (T) w.get();
View Full Code Here

        MatrixWritable w = new MatrixWritable();
        w.readFields(ois);
        ret = (T) w.get();
      } else {
        VectorWritable w = new VectorWritable();
        w.readFields(ois);
        ret = (T) w.get();
      }
    } catch (java.io.IOException e) {
      System.out.println("Caught exception: " + e);
    }
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.