Package edu.rit.io
Class DoubleMatrixFile.Writer
java.lang.Object
edu.rit.io.DoubleMatrixFile.Writer
- Enclosing class:
DoubleMatrixFile
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 Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the output stream.void
write()
Write all rows and columns of the matrix to the output stream.void
writeColSlice
(Range theColRange) Write the given column slice of the matrix to the output stream.void
writePatch
(Range theRowRange, Range theColRange) Write the given patch of the matrix to the output stream.void
writeRowSlice
(Range theRowRange) Write the given row slice of the matrix to the output stream.
-
Method Details
-
write
Write all rows and columns of the matrix to the output stream.- Throws:
IOException
- Thrown if an I/O error occurred.
-
writeRowSlice
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 iftheRowRange
is null.IllegalArgumentException
- (unchecked exception) Thrown iftheRowRange
's stride is greater than 1.IndexOutOfBoundsException
- (unchecked exception) Thrown if any index intheRowRange
is outside the range 0 .. R-1.IOException
- Thrown if an I/O error occurred.
-
writeColSlice
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 iftheColRange
is null.IllegalArgumentException
- (unchecked exception) Thrown iftheColRange
's stride is greater than 1.IndexOutOfBoundsException
- (unchecked exception) Thrown if any index intheColRange
is outside the range 0 .. C-1.IOException
- Thrown if an I/O error occurred.
-
writePatch
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 iftheRowRange
is null. Thrown iftheColRange
is null.IllegalArgumentException
- (unchecked exception) Thrown iftheRowRange
's stride is greater than 1. Thrown iftheColRange
's stride is greater than 1.IndexOutOfBoundsException
- (unchecked exception) Thrown if any index intheRowRange
is outside the range 0 .. R-1. Thrown if any index intheColRange
is outside the range 0 .. C-1.IOException
- Thrown if an I/O error occurred.
-
close
Close the output stream.- Throws:
IOException
- Thrown if an I/O error occurred.
-