Class CoordinateMatrix

Object
org.apache.spark.mllib.linalg.distributed.CoordinateMatrix
All Implemented Interfaces:
Serializable, DistributedMatrix, scala.Serializable

public class CoordinateMatrix extends Object implements DistributedMatrix
Represents a matrix in coordinate format.

param: entries matrix entries param: nRows number of rows. A non-positive value means unknown, and then the number of rows will be determined by the max row index plus one. param: nCols number of columns. A non-positive value means unknown, and then the number of columns will be determined by the max column index plus one.

See Also:
  • Constructor Details

    • CoordinateMatrix

      public CoordinateMatrix(RDD<MatrixEntry> entries, long nRows, long nCols)
    • CoordinateMatrix

      public CoordinateMatrix(RDD<MatrixEntry> entries)
      Alternative constructor leaving matrix dimensions to be determined automatically.
  • Method Details

    • entries

      public RDD<MatrixEntry> entries()
    • numCols

      public long numCols()
      Gets or computes the number of columns.
      Specified by:
      numCols in interface DistributedMatrix
    • numRows

      public long numRows()
      Gets or computes the number of rows.
      Specified by:
      numRows in interface DistributedMatrix
    • toBlockMatrix

      public BlockMatrix toBlockMatrix()
      Converts to BlockMatrix. Creates blocks of SparseMatrix with size 1024 x 1024.
      Returns:
      (undocumented)
    • toBlockMatrix

      public BlockMatrix toBlockMatrix(int rowsPerBlock, int colsPerBlock)
      Converts to BlockMatrix. Creates blocks of SparseMatrix.
      Parameters:
      rowsPerBlock - The number of rows of each block. The blocks at the bottom edge may have a smaller value. Must be an integer value greater than 0.
      colsPerBlock - The number of columns of each block. The blocks at the right edge may have a smaller value. Must be an integer value greater than 0.
      Returns:
      a BlockMatrix
    • toIndexedRowMatrix

      public IndexedRowMatrix toIndexedRowMatrix()
      Converts to IndexedRowMatrix. The number of columns must be within the integer range.
    • toRowMatrix

      public RowMatrix toRowMatrix()
      Converts to RowMatrix, dropping row indices after grouping by row index. The number of columns must be within the integer range.
      Returns:
      (undocumented)
    • transpose

      public CoordinateMatrix transpose()
      Transposes this CoordinateMatrix.