Class DefaultMatrixStorage

  • All Implemented Interfaces:
    MatrixAccess, Table

    public class DefaultMatrixStorage
    extends Object
    implements MatrixAccess
    There are multiple ways to implement the storage data structure depending on the matrix type for optimization purpose. This class provides a default way to access the storage structure. A particular matrix implementation may override these methods for performance, if implementation details of storage are known.
    • Constructor Detail

      • DefaultMatrixStorage

        public DefaultMatrixStorage​(MatrixAccess storage)
        Construct a DefaultMatrixStorage to wrap a storage for access.
        Parameters:
        storage - the matrix data storage/representation
    • Method Detail

      • nRows

        public int nRows()
        Description copied from interface: Table
        Gets the number of rows. Rows count from 1.
        Specified by:
        nRows in interface Table
        Returns:
        the number of rows
      • nCols

        public int nCols()
        Description copied from interface: Table
        Gets the number of columns. Columns count from 1.
        Specified by:
        nCols in interface Table
        Returns:
        the number of columns
      • set

        public void set​(int row,
                        int col,
                        double value)
                 throws MatrixAccessException
        Description copied from interface: MatrixAccess
        Set the matrix entry at [i,j] to a value. This is the only method that may change a matrix.
        Specified by:
        set in interface MatrixAccess
        Parameters:
        row - the row index
        col - the column index
        value - the value to set A[i,j] to
        Throws:
        MatrixAccessException - if i or j is out of range
      • setRow

        public void setRow​(int i,
                           double... values)
        Set the values for a row in the matrix, i.e., [i, *].
        Parameters:
        i - the row index, counting from 1
        values - the values to change the row entries to
        Throws:
        MatrixAccessException - if the number of values does not match the column size
      • setRow

        public void setRow​(int i,
                           Vector v)
        Set the values for a row in the matrix, i.e., [i, *].
        Parameters:
        i - the row index, counting from 1
        v - the vector to change the row entries to
        Throws:
        MatrixAccessException - if the number of values does not match the column size
      • setColumn

        public void setColumn​(int j,
                              double... values)
        Set the values for a column in the matrix, i.e., [*, j].
        Parameters:
        j - the column index, counting from 1
        values - the values to change the column entries to
        Throws:
        MatrixAccessException - if the number of values does not match the row size
      • setColumn

        public void setColumn​(int j,
                              Vector v)
        Set the values for a column in the matrix, i.e., [*, j].
        Parameters:
        j - the column index, counting from 1
        v - the vector to change the column entries to
        Throws:
        MatrixAccessException - if the number of values does not match the row size
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object