Class IndexedRowMatrix
- All Implemented Interfaces:
Serializable
,DistributedMatrix
DistributedMatrix
with
indexed rows.
param: rows indexed rows of this matrix 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 size of the first row.
- See Also:
-
Constructor Summary
ConstructorDescriptionIndexedRowMatrix
(RDD<IndexedRow> rows) Alternative constructor leaving matrix dimensions to be determined automatically.IndexedRowMatrix
(RDD<IndexedRow> rows, long nRows, int nCols) -
Method Summary
Modifier and TypeMethodDescriptionCompute all cosine similarities between columns of this matrix using the brute-force approach of computing normalized dot products.Computes the Gramian matrixA^T A
.computeSVD
(int k, boolean computeU, double rCond) Computes the singular value decomposition of this IndexedRowMatrix.Multiply this matrix by a local matrix on the right.long
numCols()
Gets or computes the number of columns.long
numRows()
Gets or computes the number of rows.rows()
Converts to BlockMatrix.toBlockMatrix
(int rowsPerBlock, int colsPerBlock) Converts to BlockMatrix.Converts this matrix to aCoordinateMatrix
.Drops row indices and converts this matrix to aRowMatrix
.
-
Constructor Details
-
IndexedRowMatrix
-
IndexedRowMatrix
Alternative constructor leaving matrix dimensions to be determined automatically.
-
-
Method Details
-
columnSimilarities
Compute all cosine similarities between columns of this matrix using the brute-force approach of computing normalized dot products.- Returns:
- An n x n sparse upper-triangular matrix of cosine similarities between columns of this matrix.
-
computeGramianMatrix
Computes the Gramian matrixA^T A
.- Returns:
- (undocumented)
- Note:
- This cannot be computed on matrices with more than 65535 columns.
-
computeSVD
public SingularValueDecomposition<IndexedRowMatrix,Matrix> computeSVD(int k, boolean computeU, double rCond) Computes the singular value decomposition of this IndexedRowMatrix. Denote this matrix by A (m x n), this will compute matrices U, S, V such that A = U * S * V'.The cost and implementation of this method is identical to that in
RowMatrix
With the addition of indices.At most k largest non-zero singular values and associated vectors are returned. If there are k such values, then the dimensions of the return will be:
U is an
IndexedRowMatrix
of size m x k that satisfies U'U = eye(k), s is a Vector of size k, holding the singular values in descending order, and V is a local Matrix of size n x k that satisfies V'V = eye(k).- Parameters:
k
- number of singular values to keep. We might return less than k if there are numerically zero singular values. See rCond.computeU
- whether to compute UrCond
- the reciprocal condition number. All singular values smaller than rCond * sigma(0) are treated as zero, where sigma(0) is the largest singular value.- Returns:
- SingularValueDecomposition(U, s, V)
-
multiply
Multiply this matrix by a local matrix on the right.- Parameters:
B
- a local matrix whose number of rows must match the number of columns of this matrix- Returns:
- an IndexedRowMatrix representing the product, which preserves partitioning
-
numCols
public long numCols()Description copied from interface:DistributedMatrix
Gets or computes the number of columns.- Specified by:
numCols
in interfaceDistributedMatrix
-
numRows
public long numRows()Description copied from interface:DistributedMatrix
Gets or computes the number of rows.- Specified by:
numRows
in interfaceDistributedMatrix
-
rows
-
toBlockMatrix
Converts to BlockMatrix. Creates blocks with size 1024 x 1024.- Returns:
- (undocumented)
-
toBlockMatrix
Converts to BlockMatrix. Blocks may be sparse or dense depending on the sparsity of the rows.- 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
-
toCoordinateMatrix
Converts this matrix to aCoordinateMatrix
.- Returns:
- (undocumented)
-
toRowMatrix
Drops row indices and converts this matrix to aRowMatrix
.- Returns:
- (undocumented)
-