Documentation of 'jsat.linear.SubMatrix' Java class
SubMatrix
jsat.linear

Class SubMatrix

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class SubMatrix
    extends GenericMatrix
    This class allows for the selection of an area of a matrix to operate on independently. Mutable matrix operations perform on this sub matrix, will be visible in the base matrix given. This allows for easy implementation of blocking algorithms, but care must be taken to not create and use two sub matrices that overlap and are altered simultaneously.
    See Also:
    Serialized Form
    • Constructor Detail

      • SubMatrix

        public SubMatrix(Matrix baseMatrix,
                         int firstRow,
                         int firstColumn,
                         int toRow,
                         int toCol)
        Creates a new matrix that is a sub view of the given base matrix.
        Parameters:
        baseMatrix - the base matrix to get a view of
        firstRow - the first row to consider as part of the sub matrix, starting from 0 inclusive
        firstColumn - the first column to consider as part of the sub matrix, starting from 0 inclusive
        toRow - the last row from the base matrix to consider, exclusive
        toCol - the last column from the base matrix to consider, exclusive
    • Method Detail

      • getBaseMatrix

        public Matrix getBaseMatrix()
        Returns the matrix that is the base for this sub matrix.
        Returns:
        the matrix that is the base for this sub matrix.
      • getFirstRow

        public int getFirstRow()
        Returns the row offset used from the base matrix
        Returns:
        the row offset used from the base matrix
      • getFirstColumn

        public int getFirstColumn()
        Returns the column offset used from the base matrix
        Returns:
        the column offset used from the base matrix
      • get

        public double get(int i,
                          int j)
        Description copied from class: Matrix
        Returns the value stored at at the matrix position Ai,j
        Specified by:
        get in class Matrix
        Parameters:
        i - the row, starting from 0
        j - the column, starting from 0
        Returns:
        the value at Ai,j
      • set

        public void set(int i,
                        int j,
                        double value)
        Description copied from class: Matrix
        Sets the value stored at at the matrix position Ai,j
        Specified by:
        set in class Matrix
        Parameters:
        i - the row, starting from 0
        j - the column, starting from 0
        value - the value to place at Ai,j
      • getRowView

        public Vec getRowView(int r)
        Description copied from class: Matrix
        Obtains a vector that is backed by this, at very little memory cost. Mutations to this vector will alter the values stored in the matrix, and vice versa.
        Overrides:
        getRowView in class Matrix
        Parameters:
        r - the row to obtain a view of
        Returns:
        a vector backed by the specified row of the matrix
      • getColumnView

        public Vec getColumnView(int j)
        Description copied from class: Matrix
        Obtains a vector that is backed by this, at very little memory cost. Mutations to this vector will alter the values stored in the matrix, and vice versa.
        Overrides:
        getColumnView in class Matrix
        Parameters:
        j - the column to obtain a view of
        Returns:
        a vector backed by the specified row of the matrix
      • rows

        public int rows()
        Description copied from class: Matrix
        Returns the number of rows stored in this matrix
        Specified by:
        rows in class Matrix
        Returns:
        the number of rows stored in this matrix
      • cols

        public int cols()
        Description copied from class: Matrix
        Returns the number of columns stored in this matrix
        Specified by:
        cols in class Matrix
        Returns:
        the number of columns stored in this matrix
      • isSparce

        public boolean isSparce()
        Description copied from class: Matrix
        Returns true if the matrix is sparse, false otherwise
        Specified by:
        isSparce in class Matrix
        Returns:
        true if the matrix is sparse, false otherwise
      • changeSize

        public void changeSize(int newRows,
                               int newCols)
        This method alters the size of a matrix, either adding or subtracting rows from the internal structure of the matrix. Every resize call may cause a new allocation internally, and should not be called for excessive changing of a matrix. All added rows/ columns will have values of zero. If a row / column is removed, it is always the bottom/right most row / column removed. Values of the removed rows / columns will be lost.

        When a SubMatrix attempts to change size, it may alter the values of the underlying matrix in an unusual way. If the base matrix is large enough to hold the changed size, then the values in the underlying matrix that this SubMatrix is expanding to encompass will be set to zero. If the underlying matrix is not large enough, change size will be called upon it as well.
        When decreasing the number of rows / columns, the SubMatrix will always reduce its view - but never shrink the underling matrix that the view is of.
        To expand the size of a SubMatrix without zeroing out the new values, create a new SubMatrix object.
        Specified by:
        changeSize in class Matrix
        Parameters:
        newRows - the new number of rows, must be positive
        newCols - the new number of columns, must be positive.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.