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 TypeMethodDescriptionvoidadd(int num, int[] indices) Shifts the indices.booleanhasInfo()Checks if a Matrix Market header is present ("%%MatrixMarket")voidreadArray(double[] data) Reads the array datavoidreadArray(double[] dataR, double[] dataI) Reads the array data.voidreadArray(float[] data) Reads the array datavoidreadArray(float[] dataR, float[] dataI) Reads the array data.voidreadArray(int[] data) Reads the array datavoidreadArray(long[] data) Reads the array dataReads in the size of an array matrix.String[]Reads all the comments (lines starting with '%').voidreadCoordinate(int[] index, double[] data) Reads a coordinate vectorvoidreadCoordinate(int[] index, double[] dataR, double[] dataI) Reads a coordinate vector.voidreadCoordinate(int[] index, float[] data) Reads a coordinate vectorvoidreadCoordinate(int[] index, float[] dataR, float[] dataI) Reads a coordinate vector.voidreadCoordinate(int[] index, int[] data) Reads a coordinate vectorvoidreadCoordinate(int[] row, int[] column, double[] data) Reads a coordinate matrixvoidreadCoordinate(int[] row, int[] column, double[] dataR, double[] dataI) Reads a coordinate matrix.voidreadCoordinate(int[] row, int[] column, float[] data) Reads a coordinate matrixvoidreadCoordinate(int[] row, int[] column, float[] dataR, float[] dataI) Reads a coordinate matrix.voidreadCoordinate(int[] row, int[] column, int[] data) Reads a coordinate matrixvoidreadCoordinate(int[] row, int[] column, long[] data) Reads a coordinate matrixvoidreadCoordinate(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.voidreadPattern(int[] index) Reads a pattern vectorvoidreadPattern(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, skipMethods 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
-