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:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class MatrixVectorReader extends java.io.BufferedReaderReads matrices and vectors
-
-
Constructor Summary
Constructors Constructor Description MatrixVectorReader(java.io.Reader in)Constructor for MatrixVectorReaderMatrixVectorReader(java.io.Reader in, int sz)Constructor for MatrixVectorReader
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(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 dataMatrixSizereadArraySize()Reads in the size of an array matrix.java.lang.String[]readComments()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 vectorMatrixSizereadCoordinateSize()Reads in the size of a coordinate matrix.MatrixInforeadMatrixInfo()Reads the matrix info for the Matrix Market exchange format.MatrixSizereadMatrixSize(MatrixInfo info)Reads in the size of a matrix.voidreadPattern(int[] index)Reads a pattern vectorvoidreadPattern(int[] row, int[] column)Reads a pattern matrixVectorSizereadVectorArraySize()Reads in the size of a dense vector.VectorSizereadVectorCoordinateSize()Reads in the size of a coordinate vector.VectorInforeadVectorInfo()Reads the vector info for the Matrix Market exchange format.VectorSizereadVectorSize(VectorInfo info)Reads in the size of a vector.
-
-
-
Constructor Detail
-
MatrixVectorReader
public MatrixVectorReader(java.io.Reader in)
Constructor for MatrixVectorReader- Parameters:
in- A Reader
-
MatrixVectorReader
public MatrixVectorReader(java.io.Reader in, int sz)Constructor for MatrixVectorReader- Parameters:
in- A Readersz- Input buffer size
-
-
Method Detail
-
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
public MatrixInfo readMatrixInfo() throws java.io.IOException
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:
java.io.IOException
-
readVectorInfo
public VectorInfo readVectorInfo() throws java.io.IOException
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:
java.io.IOException
-
hasInfo
public boolean hasInfo() throws java.io.IOExceptionChecks if a Matrix Market header is present ("%%MatrixMarket")- Returns:
- True if a header was found, else false
- Throws:
java.io.IOException
-
readComments
public java.lang.String[] readComments() throws java.io.IOExceptionReads 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:
java.io.IOException
-
readMatrixSize
public MatrixSize readMatrixSize(MatrixInfo info) throws java.io.IOException
Reads in the size of a matrix. Skips initial comments- Throws:
java.io.IOException
-
readArraySize
public MatrixSize readArraySize() throws java.io.IOException
Reads in the size of an array matrix. Skips initial comments- Throws:
java.io.IOException
-
readCoordinateSize
public MatrixSize readCoordinateSize() throws java.io.IOException
Reads in the size of a coordinate matrix. Skips initial comments- Throws:
java.io.IOException
-
readVectorSize
public VectorSize readVectorSize(VectorInfo info) throws java.io.IOException
Reads in the size of a vector. Skips initial comments- Throws:
java.io.IOException
-
readVectorArraySize
public VectorSize readVectorArraySize() throws java.io.IOException
Reads in the size of a dense vector. Skips initial comments- Throws:
java.io.IOException
-
readVectorCoordinateSize
public VectorSize readVectorCoordinateSize() throws java.io.IOException
Reads in the size of a coordinate vector. Skips initial comments- Throws:
java.io.IOException
-
readArray
public void readArray(double[] data) throws java.io.IOExceptionReads the array data- Throws:
java.io.IOException
-
readArray
public void readArray(float[] data) throws java.io.IOExceptionReads the array data- Throws:
java.io.IOException
-
readArray
public void readArray(int[] data) throws java.io.IOExceptionReads the array data- Throws:
java.io.IOException
-
readArray
public void readArray(long[] data) throws java.io.IOExceptionReads the array data- Throws:
java.io.IOException
-
readArray
public void readArray(double[] dataR, double[] dataI) throws java.io.IOExceptionReads the array data. The first array will contain real entries, while the second contain imaginary entries- Throws:
java.io.IOException
-
readArray
public void readArray(float[] dataR, float[] dataI) throws java.io.IOExceptionReads the array data. The first array will contain real entries, while the second contain imaginary entries- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] index, double[] data) throws java.io.IOExceptionReads a coordinate vector- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] index, float[] data) throws java.io.IOExceptionReads a coordinate vector- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] index, int[] data) throws java.io.IOExceptionReads a coordinate vector- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] index, long[] data) throws java.io.IOExceptionReads a coordinate vector- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] index, float[] dataR, float[] dataI) throws java.io.IOExceptionReads a coordinate vector. First data array contains real entries, and the second contains imaginary entries- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] index, double[] dataR, double[] dataI) throws java.io.IOExceptionReads a coordinate vector. First data array contains real entries, and the second contains imaginary entries- Throws:
java.io.IOException
-
readPattern
public void readPattern(int[] index) throws java.io.IOExceptionReads a pattern vector- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, double[] data) throws java.io.IOExceptionReads a coordinate matrix- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, float[] data) throws java.io.IOExceptionReads a coordinate matrix- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, int[] data) throws java.io.IOExceptionReads a coordinate matrix- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, long[] data) throws java.io.IOExceptionReads a coordinate matrix- Throws:
java.io.IOException
-
readPattern
public void readPattern(int[] row, int[] column) throws java.io.IOExceptionReads a pattern matrix- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, double[] dataR, double[] dataI) throws java.io.IOExceptionReads a coordinate matrix. First data array contains real entries, and the second contains imaginary entries- Throws:
java.io.IOException
-
readCoordinate
public void readCoordinate(int[] row, int[] column, float[] dataR, float[] dataI) throws java.io.IOExceptionReads a coordinate matrix. First data array contains real entries, and the second contains imaginary entries- Throws:
java.io.IOException
-
-