org.apache.spark.mllib.linalg.distributed

## Class IndexedRowMatrix

• Object
• org.apache.spark.mllib.linalg.distributed.IndexedRowMatrix
• ### Constructor Detail

• #### IndexedRowMatrix

public IndexedRowMatrix(RDD<IndexedRow> rows,
long nRows,
int nCols)
• #### IndexedRowMatrix

public IndexedRowMatrix(RDD<IndexedRow> rows)
Alternative constructor leaving matrix dimensions to be determined automatically.
• ### Method Detail

• #### toRowMatrix

public RowMatrix toRowMatrix()
Drops row indices and converts this matrix to a RowMatrix.
• #### 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 U
rCond - 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

public IndexedRowMatrix multiply(Matrix B)
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
• #### computeGramianMatrix

public Matrix computeGramianMatrix()
Computes the Gramian matrix A^T A.
• #### toBreeze

public breeze.linalg.DenseMatrix<Object> toBreeze()
Description copied from interface: DistributedMatrix
Collects data and assembles a local dense breeze matrix (for test only).
Specified by:
toBreeze in interface DistributedMatrix