Package no.uib.cipr.matrix.io
Class MatrixVectorReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
no.uib.cipr.matrix.io.MatrixVectorReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
Reads matrices and vectors
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for MatrixVectorReaderMatrixVectorReader
(Reader in, int sz) Constructor for MatrixVectorReader -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int num, int[] indices) Shifts the indices.boolean
hasInfo()
Checks if a Matrix Market header is present ("%%MatrixMarket")void
readArray
(double[] data) Reads the array datavoid
readArray
(double[] dataR, double[] dataI) Reads the array data.void
readArray
(float[] data) Reads the array datavoid
readArray
(float[] dataR, float[] dataI) Reads the array data.void
readArray
(int[] data) Reads the array datavoid
readArray
(long[] data) Reads the array dataReads in the size of an array matrix.String[]
Reads all the comments (lines starting with '%').void
readCoordinate
(int[] index, double[] data) Reads a coordinate vectorvoid
readCoordinate
(int[] index, double[] dataR, double[] dataI) Reads a coordinate vector.void
readCoordinate
(int[] index, float[] data) Reads a coordinate vectorvoid
readCoordinate
(int[] index, float[] dataR, float[] dataI) Reads a coordinate vector.void
readCoordinate
(int[] index, int[] data) Reads a coordinate vectorvoid
readCoordinate
(int[] row, int[] column, double[] data) Reads a coordinate matrixvoid
readCoordinate
(int[] row, int[] column, double[] dataR, double[] dataI) Reads a coordinate matrix.void
readCoordinate
(int[] row, int[] column, float[] data) Reads a coordinate matrixvoid
readCoordinate
(int[] row, int[] column, float[] dataR, float[] dataI) Reads a coordinate matrix.void
readCoordinate
(int[] row, int[] column, int[] data) Reads a coordinate matrixvoid
readCoordinate
(int[] row, int[] column, long[] data) Reads a coordinate matrixvoid
readCoordinate
(int[] index, long[] data) Reads a coordinate vectorReads in the size of a coordinate matrix.Reads the matrix info for the Matrix Market exchange format.readMatrixSize
(MatrixInfo info) Reads in the size of a matrix.void
readPattern
(int[] index) Reads a pattern vectorvoid
readPattern
(int[] row, int[] column) Reads a pattern matrixReads in the size of a dense vector.Reads in the size of a coordinate vector.Reads the vector info for the Matrix Market exchange format.readVectorSize
(VectorInfo info) Reads in the size of a vector.Methods inherited from class java.io.BufferedReader
close, lines, mark, markSupported, read, read, readLine, ready, reset, skip
Methods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Constructor Details
-
MatrixVectorReader
Constructor for MatrixVectorReader- Parameters:
in
- A Reader
-
MatrixVectorReader
Constructor for MatrixVectorReader- Parameters:
in
- A Readersz
- Input buffer size
-
-
Method Details
-
add
public void add(int num, int[] indices) Shifts the indices. Useful for converting between 0- and 1-based indicing.- Parameters:
num
- Added to every indexindices
- Indices to shift
-
readMatrixInfo
Reads the matrix info for the Matrix Market exchange format. The line must consist of exactly 5 space-separated entries, the first being "%%MatrixMarket"- Throws:
IOException
-
readVectorInfo
Reads the vector info for the Matrix Market exchange format. The line must consist of exactly 4 space-separated entries, the first being "%%MatrixMarket"- Throws:
IOException
-
hasInfo
Checks if a Matrix Market header is present ("%%MatrixMarket")- Returns:
- True if a header was found, else false
- Throws:
IOException
-
readComments
Reads all the comments (lines starting with '%'). Positions the reader at the first non-comment line. Can only be called after reading the matrix or vector info. The comments read does not include '%' or the newline- Throws:
IOException
-
readMatrixSize
Reads in the size of a matrix. Skips initial comments- Throws:
IOException
-
readArraySize
Reads in the size of an array matrix. Skips initial comments- Throws:
IOException
-
readCoordinateSize
Reads in the size of a coordinate matrix. Skips initial comments- Throws:
IOException
-
readVectorSize
Reads in the size of a vector. Skips initial comments- Throws:
IOException
-
readVectorArraySize
Reads in the size of a dense vector. Skips initial comments- Throws:
IOException
-
readVectorCoordinateSize
Reads in the size of a coordinate vector. Skips initial comments- Throws:
IOException
-
readArray
Reads the array data- Throws:
IOException
-
readArray
Reads the array data- Throws:
IOException
-
readArray
Reads the array data- Throws:
IOException
-
readArray
Reads the array data- Throws:
IOException
-
readArray
Reads the array data. The first array will contain real entries, while the second contain imaginary entries- Throws:
IOException
-
readArray
Reads the array data. The first array will contain real entries, while the second contain imaginary entries- Throws:
IOException
-
readCoordinate
Reads a coordinate vector- Throws:
IOException
-
readCoordinate
Reads a coordinate vector- Throws:
IOException
-
readCoordinate
Reads a coordinate vector- Throws:
IOException
-
readCoordinate
Reads a coordinate vector- Throws:
IOException
-
readCoordinate
Reads a coordinate vector. First data array contains real entries, and the second contains imaginary entries- Throws:
IOException
-
readCoordinate
Reads a coordinate vector. First data array contains real entries, and the second contains imaginary entries- Throws:
IOException
-
readPattern
Reads a pattern vector- Throws:
IOException
-
readCoordinate
Reads a coordinate matrix- Throws:
IOException
-
readCoordinate
Reads a coordinate matrix- Throws:
IOException
-
readCoordinate
Reads a coordinate matrix- Throws:
IOException
-
readCoordinate
Reads a coordinate matrix- Throws:
IOException
-
readPattern
Reads a pattern matrix- Throws:
IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, double[] dataR, double[] dataI) throws IOException Reads a coordinate matrix. First data array contains real entries, and the second contains imaginary entries- Throws:
IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, float[] dataR, float[] dataI) throws IOException Reads a coordinate matrix. First data array contains real entries, and the second contains imaginary entries- Throws:
IOException
-