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

Class MatrixOfVecs

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


    public class MatrixOfVecs
    extends GenericMatrix
    This class provides a base mechanism to create a Matrix 'view' from a list of Vec objects. The vector objects will be used to back the rows of the matrix, so changes to one are shown in the other. If the matirx is altered using changeSize(int, int), this may no longer be true.
    Row oriented operations are implemented to defer to the base vector objects used.
    See Also:
    Serialized Form
    • Constructor Detail

      • MatrixOfVecs

        public MatrixOfVecs(Vec... rows)
        Creates a new Matrix of Vecs from the given array of Vec objects. All Vec objects contained should be of the same length.
        Parameters:
        rows - the rows of vecs to make this matrix.
      • MatrixOfVecs

        public MatrixOfVecs(java.util.List<Vec> rows)
        Creates a new Matrix of Vecs from the given list of Vec objects. All Vec objects contained should be of the same length.
        Parameters:
        rows - the rows of vecs to make this matrix.
      • MatrixOfVecs

        public MatrixOfVecs(int rows,
                            int cols,
                            boolean sparse)
        Creates a new Matrix of Vecs of the desired size.
        Parameters:
        rows - the number of rows in the matrix
        cols - the number of columns in the matrix
        sparse - if true SparseVector objects will be used for the rows. Else DenseVector will be used.
    • Method Detail

      • changeSize

        public void changeSize(int newRows,
                               int newCols)
        Description copied from class: Matrix
        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.
        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.
      • 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
      • increment

        public void increment(int i,
                              int j,
                              double value)
        Description copied from class: Matrix
        Alters the current matrix at index (i,j) to be equal to Ai,j = Ai,j + value
        Overrides:
        increment in class Matrix
        Parameters:
        i - the row, starting from 0
        j - the column, starting from 0
        value - the value to add to the matrix coordinate
      • 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
      • 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
      • updateRow

        public void updateRow(int i,
                              double c,
                              Vec b)
        Description copied from class: Matrix
        Alters row i of this matrix, such that A[i,:] = A[i,:] + c*b
        Overrides:
        updateRow in class Matrix
        Parameters:
        i - the index of the row to update
        c - the scalar constant to multiply the vector by
        b - the vector to add to the specified row
      • multiply

        public void multiply(Vec b,
                             double z,
                             Vec c)
        Description copied from class: Matrix
        If this matrix is Am x n, and b has a length of n, and c has a length of m, then this will mutate c to store c = c + A*b*z
        Overrides:
        multiply in class GenericMatrix
        Parameters:
        b - the vector to be treated as a colum vector
        z - the constant to multiply the A*b value by.
        c - where to place the result by addition
      • mutableMultiply

        public void mutableMultiply(double c)
        Description copied from class: Matrix
        Alters the current matrix to be equal to A*c
        Overrides:
        mutableMultiply in class GenericMatrix
        Parameters:
        c - the scalar constant to multiply by
      • mutableAdd

        public void mutableAdd(double c)
        Description copied from class: Matrix
        Alters the current matrix to store the value A+c
        Overrides:
        mutableAdd in class GenericMatrix
        Parameters:
        c - the scalar constant to add to this
      • zeroOut

        public void zeroOut()
        Description copied from class: Matrix
        Alters the current matrix so that all values are equal to zero.
        Overrides:
        zeroOut in class GenericMatrix
      • 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

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.