Interface Matrix

All Superinterfaces:
Serializable
All Known Implementing Classes:
DenseMatrix, SparseMatrix

public interface Matrix extends Serializable
Trait for a local matrix.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    apply(int i, int j)
    Gets the (i, j)-th element.
    breeze.linalg.Matrix<Object>
    Converts to a breeze matrix.
    scala.collection.Iterator<Vector>
    Returns an iterator of column vectors.
    Returns a matrix in dense column major, dense row major, sparse row major, or sparse column major format, whichever uses less storage.
    Returns a matrix in dense or sparse column major format, whichever uses less storage.
    Returns a matrix in dense or sparse row major format, whichever uses less storage.
    Get a deep copy of the matrix.
    void
    foreachActive(scala.Function3<Object,Object,Object,scala.runtime.BoxedUnit> f)
    Applies a function f to all the active elements of dense and sparse matrix.
    long
    Gets the size of the dense representation of this `Matrix`.
    long
    Gets the current size in bytes of this `Matrix`.
    long
    getSparseSizeInBytes(boolean colMajor)
    Gets the size of the minimal sparse representation of this `Matrix`.
    int
    index(int i, int j)
    Return the index for the (i, j)-th element in the backing array.
    boolean
    Indicates whether the values backing this matrix are arranged in column major order.
    boolean
    Indicates whether the values backing this matrix are arranged in row major order.
    boolean
    Flag that keeps track whether the matrix is transposed or not.
    map(scala.Function1<Object,Object> f)
    Map the values of this matrix using a function.
    Convenience method for Matrix-DenseMatrix multiplication.
    Convenience method for Matrix-DenseVector multiplication.
    Convenience method for Matrix-Vector multiplication.
    int
    Find the number of values stored explicitly.
    int
    Number of columns.
    int
    Find the number of non-zero active values.
    int
    Number of rows.
    scala.collection.Iterator<Vector>
    Returns an iterator of row vectors.
    double[]
    Converts to a dense array in column major.
    Converts this matrix to a dense matrix while maintaining the layout of the current matrix.
    Converts this matrix to a dense matrix in column major order.
    toDenseMatrix(boolean colMajor)
    Converts this matrix to a dense matrix.
    Converts this matrix to a dense matrix in row major order.
    Converts this matrix to a sparse matrix while maintaining the layout of the current matrix.
    Converts this matrix to a sparse matrix in column major order.
    toSparseMatrix(boolean colMajor)
    Converts this matrix to a sparse matrix.
    Converts this matrix to a sparse matrix in row major order.
    A human readable representation of the matrix
    toString(int maxLines, int maxLineWidth)
    A human readable representation of the matrix with maximum lines and width
    Transpose the Matrix.
    void
    update(int i, int j, double v)
    Update element at (i, j)
    update(scala.Function1<Object,Object> f)
    Update all the values of this matrix using the function f.
  • Method Details

    • apply

      double apply(int i, int j)
      Gets the (i, j)-th element.
    • asBreeze

      breeze.linalg.Matrix<Object> asBreeze()
      Converts to a breeze matrix.
    • colIter

      scala.collection.Iterator<Vector> colIter()
      Returns an iterator of column vectors. This operation could be expensive, depending on the underlying storage.
      Returns:
      (undocumented)
    • compressed

      Matrix compressed()
      Returns a matrix in dense column major, dense row major, sparse row major, or sparse column major format, whichever uses less storage. When dense representation is optimal, it maintains the current layout order.
      Returns:
      (undocumented)
    • compressedColMajor

      Matrix compressedColMajor()
      Returns a matrix in dense or sparse column major format, whichever uses less storage.
      Returns:
      (undocumented)
    • compressedRowMajor

      Matrix compressedRowMajor()
      Returns a matrix in dense or sparse row major format, whichever uses less storage.
      Returns:
      (undocumented)
    • copy

      Matrix copy()
      Get a deep copy of the matrix.
    • foreachActive

      void foreachActive(scala.Function3<Object,Object,Object,scala.runtime.BoxedUnit> f)
      Applies a function f to all the active elements of dense and sparse matrix. The ordering of the elements are not defined.

      Parameters:
      f - the function takes three parameters where the first two parameters are the row and column indices respectively with the type Int, and the final parameter is the corresponding value in the matrix with type Double.
    • getDenseSizeInBytes

      long getDenseSizeInBytes()
      Gets the size of the dense representation of this `Matrix`.
    • getSizeInBytes

      long getSizeInBytes()
      Gets the current size in bytes of this `Matrix`. Useful for testing
    • getSparseSizeInBytes

      long getSparseSizeInBytes(boolean colMajor)
      Gets the size of the minimal sparse representation of this `Matrix`.
    • index

      int index(int i, int j)
      Return the index for the (i, j)-th element in the backing array.
    • isColMajor

      boolean isColMajor()
      Indicates whether the values backing this matrix are arranged in column major order.
    • isRowMajor

      boolean isRowMajor()
      Indicates whether the values backing this matrix are arranged in row major order.
    • isTransposed

      boolean isTransposed()
      Flag that keeps track whether the matrix is transposed or not. False by default.
    • map

      Matrix map(scala.Function1<Object,Object> f)
      Map the values of this matrix using a function. Generates a new matrix. Performs the function on only the backing array. For example, an operation such as addition or subtraction will only be performed on the non-zero values in a SparseMatrix.
      Parameters:
      f - (undocumented)
      Returns:
      (undocumented)
    • multiply

      DenseMatrix multiply(DenseMatrix y)
      Convenience method for Matrix-DenseMatrix multiplication.
      Parameters:
      y - (undocumented)
      Returns:
      (undocumented)
    • multiply

      DenseVector multiply(DenseVector y)
      Convenience method for Matrix-DenseVector multiplication. For binary compatibility.
      Parameters:
      y - (undocumented)
      Returns:
      (undocumented)
    • multiply

      DenseVector multiply(Vector y)
      Convenience method for Matrix-Vector multiplication.
      Parameters:
      y - (undocumented)
      Returns:
      (undocumented)
    • numActives

      int numActives()
      Find the number of values stored explicitly. These values can be zero as well.
      Returns:
      (undocumented)
    • numCols

      int numCols()
      Number of columns.
    • numNonzeros

      int numNonzeros()
      Find the number of non-zero active values.
      Returns:
      (undocumented)
    • numRows

      int numRows()
      Number of rows.
    • rowIter

      scala.collection.Iterator<Vector> rowIter()
      Returns an iterator of row vectors. This operation could be expensive, depending on the underlying storage.
      Returns:
      (undocumented)
    • toArray

      double[] toArray()
      Converts to a dense array in column major.
    • toDense

      DenseMatrix toDense()
      Converts this matrix to a dense matrix while maintaining the layout of the current matrix.
      Returns:
      (undocumented)
    • toDenseColMajor

      DenseMatrix toDenseColMajor()
      Converts this matrix to a dense matrix in column major order.
      Returns:
      (undocumented)
    • toDenseMatrix

      DenseMatrix toDenseMatrix(boolean colMajor)
      Converts this matrix to a dense matrix.

      Parameters:
      colMajor - Whether the values of the resulting dense matrix should be in column major or row major order. If false, resulting matrix will be row major.
      Returns:
      (undocumented)
    • toDenseRowMajor

      DenseMatrix toDenseRowMajor()
      Converts this matrix to a dense matrix in row major order.
      Returns:
      (undocumented)
    • toSparse

      SparseMatrix toSparse()
      Converts this matrix to a sparse matrix while maintaining the layout of the current matrix.
      Returns:
      (undocumented)
    • toSparseColMajor

      SparseMatrix toSparseColMajor()
      Converts this matrix to a sparse matrix in column major order.
      Returns:
      (undocumented)
    • toSparseMatrix

      SparseMatrix toSparseMatrix(boolean colMajor)
      Converts this matrix to a sparse matrix.

      Parameters:
      colMajor - Whether the values of the resulting sparse matrix should be in column major or row major order. If false, resulting matrix will be row major.
      Returns:
      (undocumented)
    • toSparseRowMajor

      SparseMatrix toSparseRowMajor()
      Converts this matrix to a sparse matrix in row major order.
      Returns:
      (undocumented)
    • toString

      String toString()
      A human readable representation of the matrix
      Overrides:
      toString in class Object
    • toString

      String toString(int maxLines, int maxLineWidth)
      A human readable representation of the matrix with maximum lines and width
    • transpose

      Matrix transpose()
      Transpose the Matrix. Returns a new Matrix instance sharing the same underlying data.
      Returns:
      (undocumented)
    • update

      void update(int i, int j, double v)
      Update element at (i, j)
    • update

      Matrix update(scala.Function1<Object,Object> f)
      Update all the values of this matrix using the function f. Performed in-place on the backing array. For example, an operation such as addition or subtraction will only be performed on the non-zero values in a SparseMatrix.
      Parameters:
      f - (undocumented)
      Returns:
      (undocumented)