Package edu.rit.io

Class DoubleMatrixFile.Writer

java.lang.Object
edu.rit.io.DoubleMatrixFile.Writer
Enclosing class:
DoubleMatrixFile

public class DoubleMatrixFile.Writer extends Object
Class DoubleMatrixFile.Writer provides an object with which to write a DoubleMatrixFile to an output stream.

When a writer is created, the number of rows and number of columns are written to the output stream. Each time the write(), writeRowSlice(), writeColSlice(), or writePatch() method is called, one segment of matrix elements is written to the output stream. When finished, call the close() method.

Note: Class DoubleMatrixFile.Writer is not multiple thread safe.

Version:
06-Jan-2008
Author:
Alan Kaminsky
  • Method Details

    • write

      public void write() throws IOException
      Write all rows and columns of the matrix to the output stream.
      Throws:
      IOException - Thrown if an I/O error occurred.
    • writeRowSlice

      public void writeRowSlice(Range theRowRange) throws IOException
      Write the given row slice of the matrix to the output stream. Elements in the given range of rows and in all columns are written.

      Note: theRowRange's stride must be 1.

      Parameters:
      theRowRange - Range of matrix rows.
      Throws:
      NullPointerException - (unchecked exception) Thrown if theRowRange is null.
      IllegalArgumentException - (unchecked exception) Thrown if theRowRange's stride is greater than 1.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in theRowRange is outside the range 0 .. R-1.
      IOException - Thrown if an I/O error occurred.
    • writeColSlice

      public void writeColSlice(Range theColRange) throws IOException
      Write the given column slice of the matrix to the output stream. Elements in all rows and in the given range of columns are written.

      Note: theColRange's stride must be 1.

      Parameters:
      theColRange - Range of matrix columns.
      Throws:
      NullPointerException - (unchecked exception) Thrown if theColRange is null.
      IllegalArgumentException - (unchecked exception) Thrown if theColRange's stride is greater than 1.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in theColRange is outside the range 0 .. C-1.
      IOException - Thrown if an I/O error occurred.
    • writePatch

      public void writePatch(Range theRowRange, Range theColRange) throws IOException
      Write the given patch of the matrix to the output stream. Elements in the given range of rows and in the given range of columns are written.

      Note: theRowRange's stride must be 1. theColRange's stride must be 1.

      Parameters:
      theRowRange - Range of matrix rows.
      theColRange - Range of matrix columns.
      Throws:
      NullPointerException - (unchecked exception) Thrown if theRowRange is null. Thrown if theColRange is null.
      IllegalArgumentException - (unchecked exception) Thrown if theRowRange's stride is greater than 1. Thrown if theColRange's stride is greater than 1.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in theRowRange is outside the range 0 .. R-1. Thrown if any index in theColRange is outside the range 0 .. C-1.
      IOException - Thrown if an I/O error occurred.
    • close

      public void close() throws IOException
      Close the output stream.
      Throws:
      IOException - Thrown if an I/O error occurred.