@@ -246,6 +246,9 @@ class RowMatrix(
246
246
* Then we compute U via easy matrix multiplication as U = A * (V * S-1).
247
247
* Note that this approach requires `O(nnz(A))` time.
248
248
*
249
+ * When the requested eigenvalues k = n, a non-sparse implementation will be used, which requires
250
+ * `n^2` doubles to fit in memory and `O(n^3)` time on the master node.
251
+ *
249
252
* At most k largest non-zero singular values and associated vectors are returned.
250
253
* If there are k such values, then the dimensions of the return will be:
251
254
*
@@ -269,8 +272,16 @@ class RowMatrix(
269
272
val n = numCols().toInt
270
273
require(k > 0 && k <= n, s " Request up to n singular values k= $k n= $n. " )
271
274
272
- val (sigmaSquares : BDV [Double ], u : BDM [Double ]) =
275
+ val (sigmaSquares : BDV [Double ], u : BDM [Double ]) = if (k < n) {
273
276
EigenValueDecomposition .symmetricEigs(multiplyGramianMatrix, n, k, tol)
277
+ } else {
278
+ logWarning(s " Request full SVD (k = n = $k), while ARPACK requires k strictly less than n. " +
279
+ s " Using non-sparse implementation. " )
280
+ val G = computeGramianMatrix()
281
+ val (uFull : BDM [Double ], sigmaSquaresFull : BDV [Double ], vFull : BDM [Double ]) =
282
+ brzSvd(G .toBreeze.asInstanceOf [BDM [Double ]])
283
+ (sigmaSquaresFull, uFull)
284
+ }
274
285
val sigmas : BDV [Double ] = brzSqrt(sigmaSquares)
275
286
276
287
// Determine effective rank.
@@ -508,4 +519,4 @@ object RowMatrix {
508
519
509
520
Matrices .dense(n, n, G .data)
510
521
}
511
- }
522
+ }
0 commit comments