Github user rezazadeh commented on a diff in the pull request:
https://github.com/apache/spark/pull/88#discussion_r10772816
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/SVD.scala ---
@@ -38,20 +39,113 @@ class SVD {
this
}
- /**
+ /**
+ * Singular values smaller than this value
+ * relative to the largest singular value are considered zero
+ */
+ def setReciprocalConditionNumber(smallS: Double): SVD = {
+ this.rCond = smallS
+ this
+ }
+
+ /**
+ * Should U be computed?
+ */
+ def setComputeU(compU: Boolean): SVD = {
+ this.computeU = compU
+ this
+ }
+
+ /**
* Compute SVD using the current set parameters
*/
- def compute(matrix: SparseMatrix) : MatrixSVD = {
- SVD.sparseSVD(matrix, k)
+ def compute(matrix: TallSkinnyDenseMatrix) : TallSkinnyMatrixSVD = {
+ denseSVD(matrix)
}
-}
+ /**
+ * Compute SVD using the current set parameters
+ * Returns (U, S, V) such that A = USV^T
+ * U is a row-by-row dense matrix
+ * S is a simple double array of singular values
+ * V is a 2d array matrix
+ * See denseSVD for more documentation
+ */
+ def compute(matrix: RDD[Array[Double]]) :
+ (RDD[Array[Double]], Array[Double], Array[Array[Double]]) = {
+ denseSVD(matrix)
+ }
+
+ /**
+ * Compute SVD with default parameter for computeU = true.
+ * See full paramter definition of sparseSVD for more description.
+ *
+ * @param matrix sparse matrix to factorize
+ * @return Three sparse matrices: U, S, V such that A = USV^T
+ */
+ def compute(matrix: SparseMatrix): MatrixSVD = {
+ sparseSVD(matrix)
+ }
/**
- * Top-level methods for calling Singular Value Decomposition
- * NOTE: All matrices are in 0-indexed sparse format RDD[((int, int),
value)]
+ * Singular Value Decomposition for Tall and Skinny matrices.
+ * Given an m x n matrix A, this will compute matrices U, S, V such that
+ * A = U * S * V'
+ *
+ * There is no restriction on m, but we require n^2 doubles to fit in
memory.
+ * Further, n should be less than m.
+ *
+ * The decomposition is computed by first computing A'A = V S^2 V',
--- End diff --
Doesn't like it to me, this is fine.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---