Class SparseRaggedDoubleMatrix<R,C>

java.lang.Object
ubic.basecode.dataStructure.matrix.AbstractMatrix<R,C,Double>
ubic.basecode.dataStructure.matrix.DoubleMatrix<R,C>
ubic.basecode.dataStructure.matrix.SparseRaggedDoubleMatrix<R,C>
All Implemented Interfaces:
Serializable, Matrix2D<R,C,Double>, PrimitiveMatrix<R,C,Double>

public class SparseRaggedDoubleMatrix<R,C> extends DoubleMatrix<R,C>
A sparse matrix class where the rows are ragged and compressed.
Author:
pavlidis
See Also:
  • Constructor Details

    • SparseRaggedDoubleMatrix

      public SparseRaggedDoubleMatrix()
  • Method Details

    • addRow

      public void addRow(R name, DoubleMatrix1D matrix1D)
      Parameters:
      matrix1D -
    • addRow

      public void addRow(R name, IntArrayList indexes, DoubleArrayList values)
      Parameters:
      name -
      indexes -
      values -
    • asArray

      public double[][] asArray()
      Specified by:
      asArray in class DoubleMatrix<R,C>
      Returns:
      double[][]
    • columns

      public int columns()
      Returns the size of the widest row.
      Returns:
      int
      See Also:
      • invalid reference
        basecode.dataStructure.matrix.Matrix2D#columns()
    • copy

      public DoubleMatrix<R,C> copy()
      Description copied from class: DoubleMatrix
      Create a deep copy of this
      Specified by:
      copy in class DoubleMatrix<R,C>
      Returns:
      a deep copy of this
    • get

      public double get(int i, int j)
      Specified by:
      get in class DoubleMatrix<R,C>
      Parameters:
      i -
      j -
      row -
      column -
      Returns:
    • getColObj

      public Double[] getColObj(int col)
      Parameters:
      col -
      Returns:
    • getColRange

      public DoubleMatrix<R,C> getColRange(int startCol, int endCol)
      Specified by:
      getColRange in class DoubleMatrix<R,C>
      Parameters:
      startCol - inclusive, numbered from zero
      endCol - inclusive, numbered from zero
      Returns:
      new matrix with just the requested range of columns from this
    • getColumn

      public double[] getColumn(int col)
      Specified by:
      getColumn in class DoubleMatrix<R,C>
    • getObject

      public Double getObject(int row, int col)
      Parameters:
      row -
      col -
      Returns:
    • getRow

      public double[] getRow(int i)
      Specified by:
      getRow in class DoubleMatrix<R,C>
    • getRowArrayList

      public DoubleArrayList getRowArrayList(int row)
      This gives just the list of values in the row - make sure this is what you want. It does not include the zero values.
      Specified by:
      getRowArrayList in class DoubleMatrix<R,C>
      Parameters:
      row -
      Returns:
    • getRowObj

      public Double[] getRowObj(int i)
      Parameters:
      i -
      Returns:
    • getRowRange

      public DoubleMatrix<R,C> getRowRange(int startRow, int endRow)
      Specified by:
      getRowRange in class DoubleMatrix<R,C>
      Parameters:
      startRow - inclusive, numbered from zero
      endRow - inclusive
      Returns:
    • isMissing

      public boolean isMissing(int i, int j)
      (non-Javadoc) Note that in a sparse matrix, zero values are considered "missing"!
      Parameters:
      i - row
      j - column
      Returns:
      true if the value is missing, false otherwise.
      See Also:
      • invalid reference
        basecode.dataStructure.matrix.Matrix2D#isMissing(int, int)
    • rows

      public int rows()
      Description copied from interface: Matrix2D
      Get the number of rows the matrix has
      Returns:
      int
    • set

      public void set(int i, int j, Double d)
      Parameters:
      i -
      j -
      d -
    • size

      public int size()
      Specified by:
      size in class AbstractMatrix<R,C,Double>
    • subsetColumns

      public DoubleMatrix<R,C> subsetColumns(List<C> c)
      Description copied from class: DoubleMatrix
      Create a copy of this matrix with only the selected columns, in the selected order.
      Specified by:
      subsetColumns in class DoubleMatrix<R,C>
      Parameters:
      c -
      Returns:
    • subsetRows

      public DoubleMatrix<R,C> subsetRows(List<R> rowNames)
      Description copied from class: DoubleMatrix
      Create a copy of this matrix with only the selected rows, in the selected order.
      Specified by:
      subsetRows in class DoubleMatrix<R,C>
      Parameters:
      rowNames -
      Returns:
    • transpose

      public DoubleMatrix<C,R> transpose()
      Specified by:
      transpose in class DoubleMatrix<R,C>
    • viewColumn

      public DoubleMatrix1D viewColumn(int column)
      Specified by:
      viewColumn in class DoubleMatrix<R,C>
    • viewRow

      public DoubleMatrix1D viewRow(int i)
      Specified by:
      viewRow in class DoubleMatrix<R,C>
      Parameters:
      i -
      Returns: