Class MatrixVectorReader

java.lang.Object
java.io.Reader
java.io.BufferedReader
no.uib.cipr.matrix.io.MatrixVectorReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class MatrixVectorReader extends BufferedReader
Reads matrices and vectors
  • Constructor Details

    • MatrixVectorReader

      public MatrixVectorReader(Reader in)
      Constructor for MatrixVectorReader
      Parameters:
      in - A Reader
    • MatrixVectorReader

      public MatrixVectorReader(Reader in, int sz)
      Constructor for MatrixVectorReader
      Parameters:
      in - A Reader
      sz - 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 index
      indices - Indices to shift
    • readMatrixInfo

      public MatrixInfo readMatrixInfo() throws 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:
      IOException
    • readVectorInfo

      public VectorInfo readVectorInfo() throws 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:
      IOException
    • hasInfo

      public boolean hasInfo() throws IOException
      Checks if a Matrix Market header is present ("%%MatrixMarket")
      Returns:
      True if a header was found, else false
      Throws:
      IOException
    • readComments

      public String[] readComments() throws IOException
      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

      public MatrixSize readMatrixSize(MatrixInfo info) throws IOException
      Reads in the size of a matrix. Skips initial comments
      Throws:
      IOException
    • readArraySize

      public MatrixSize readArraySize() throws IOException
      Reads in the size of an array matrix. Skips initial comments
      Throws:
      IOException
    • readCoordinateSize

      public MatrixSize readCoordinateSize() throws IOException
      Reads in the size of a coordinate matrix. Skips initial comments
      Throws:
      IOException
    • readVectorSize

      public VectorSize readVectorSize(VectorInfo info) throws IOException
      Reads in the size of a vector. Skips initial comments
      Throws:
      IOException
    • readVectorArraySize

      public VectorSize readVectorArraySize() throws IOException
      Reads in the size of a dense vector. Skips initial comments
      Throws:
      IOException
    • readVectorCoordinateSize

      public VectorSize readVectorCoordinateSize() throws IOException
      Reads in the size of a coordinate vector. Skips initial comments
      Throws:
      IOException
    • readArray

      public void readArray(double[] data) throws IOException
      Reads the array data
      Throws:
      IOException
    • readArray

      public void readArray(float[] data) throws IOException
      Reads the array data
      Throws:
      IOException
    • readArray

      public void readArray(int[] data) throws IOException
      Reads the array data
      Throws:
      IOException
    • readArray

      public void readArray(long[] data) throws IOException
      Reads the array data
      Throws:
      IOException
    • readArray

      public void readArray(double[] dataR, double[] dataI) throws IOException
      Reads the array data. The first array will contain real entries, while the second contain imaginary entries
      Throws:
      IOException
    • readArray

      public void readArray(float[] dataR, float[] dataI) throws IOException
      Reads the array data. The first array will contain real entries, while the second contain imaginary entries
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] index, double[] data) throws IOException
      Reads a coordinate vector
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] index, float[] data) throws IOException
      Reads a coordinate vector
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] index, int[] data) throws IOException
      Reads a coordinate vector
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] index, long[] data) throws IOException
      Reads a coordinate vector
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] index, float[] dataR, float[] dataI) throws IOException
      Reads a coordinate vector. First data array contains real entries, and the second contains imaginary entries
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] index, double[] dataR, double[] dataI) throws IOException
      Reads a coordinate vector. First data array contains real entries, and the second contains imaginary entries
      Throws:
      IOException
    • readPattern

      public void readPattern(int[] index) throws IOException
      Reads a pattern vector
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] row, int[] column, double[] data) throws IOException
      Reads a coordinate matrix
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] row, int[] column, float[] data) throws IOException
      Reads a coordinate matrix
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] row, int[] column, int[] data) throws IOException
      Reads a coordinate matrix
      Throws:
      IOException
    • readCoordinate

      public void readCoordinate(int[] row, int[] column, long[] data) throws IOException
      Reads a coordinate matrix
      Throws:
      IOException
    • readPattern

      public void readPattern(int[] row, int[] column) throws IOException
      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