Class MatrixVectorReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

    public class MatrixVectorReader
    extends java.io.BufferedReader
    Reads matrices and vectors
    • Field Summary

      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      MatrixVectorReader​(java.io.Reader in)
      Constructor for MatrixVectorReader
      MatrixVectorReader​(java.io.Reader in, int sz)
      Constructor for MatrixVectorReader
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void 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 data
      void readArray​(double[] dataR, double[] dataI)
      Reads the array data.
      void readArray​(float[] data)
      Reads the array data
      void readArray​(float[] dataR, float[] dataI)
      Reads the array data.
      void readArray​(int[] data)
      Reads the array data
      void readArray​(long[] data)
      Reads the array data
      MatrixSize readArraySize()
      Reads in the size of an array matrix.
      java.lang.String[] readComments()
      Reads all the comments (lines starting with '%').
      void readCoordinate​(int[] index, double[] data)
      Reads a coordinate vector
      void readCoordinate​(int[] index, double[] dataR, double[] dataI)
      Reads a coordinate vector.
      void readCoordinate​(int[] index, float[] data)
      Reads a coordinate vector
      void readCoordinate​(int[] index, float[] dataR, float[] dataI)
      Reads a coordinate vector.
      void readCoordinate​(int[] index, int[] data)
      Reads a coordinate vector
      void readCoordinate​(int[] row, int[] column, double[] data)
      Reads a coordinate matrix
      void readCoordinate​(int[] row, int[] column, double[] dataR, double[] dataI)
      Reads a coordinate matrix.
      void readCoordinate​(int[] row, int[] column, float[] data)
      Reads a coordinate matrix
      void readCoordinate​(int[] row, int[] column, float[] dataR, float[] dataI)
      Reads a coordinate matrix.
      void readCoordinate​(int[] row, int[] column, int[] data)
      Reads a coordinate matrix
      void readCoordinate​(int[] row, int[] column, long[] data)
      Reads a coordinate matrix
      void readCoordinate​(int[] index, long[] data)
      Reads a coordinate vector
      MatrixSize readCoordinateSize()
      Reads in the size of a coordinate matrix.
      MatrixInfo readMatrixInfo()
      Reads the matrix info for the Matrix Market exchange format.
      MatrixSize readMatrixSize​(MatrixInfo info)
      Reads in the size of a matrix.
      void readPattern​(int[] index)
      Reads a pattern vector
      void readPattern​(int[] row, int[] column)
      Reads a pattern matrix
      VectorSize readVectorArraySize()
      Reads in the size of a dense vector.
      VectorSize readVectorCoordinateSize()
      Reads in the size of a coordinate vector.
      VectorInfo readVectorInfo()
      Reads the vector info for the Matrix Market exchange format.
      VectorSize 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 Reader
        sz - 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 index
        indices - 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.IOException
        Checks 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.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:
        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.IOException
        Reads the array data
        Throws:
        java.io.IOException
      • readArray

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

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

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

        public void readArray​(double[] dataR,
                              double[] dataI)
                       throws java.io.IOException
        Reads 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.IOException
        Reads 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.IOException
        Reads a coordinate vector
        Throws:
        java.io.IOException
      • readCoordinate

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

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

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

        public void readCoordinate​(int[] index,
                                   float[] dataR,
                                   float[] dataI)
                            throws java.io.IOException
        Reads 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.IOException
        Reads 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.IOException
        Reads a pattern vector
        Throws:
        java.io.IOException
      • readCoordinate

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

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

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

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

        public void readPattern​(int[] row,
                                int[] column)
                         throws java.io.IOException
        Reads a pattern matrix
        Throws:
        java.io.IOException
      • readCoordinate

        public void readCoordinate​(int[] row,
                                   int[] column,
                                   double[] dataR,
                                   double[] dataI)
                            throws java.io.IOException
        Reads 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.IOException
        Reads a coordinate matrix. First data array contains real entries, and the second contains imaginary entries
        Throws:
        java.io.IOException