@@ -256,11 +256,12 @@ def randomized_svd(
256256 transpose = "auto" ,
257257 flip_sign = True ,
258258 random_state = "warn" ,
259+ svd_lapack_driver = "gesdd" ,
259260):
260261 """Computes a truncated randomized SVD.
261262
262- This method solves the fixed-rank approximation problem described in the
263- Halko et al paper (problem (1.5), p5).
263+ This method solves the fixed-rank approximation problem described in [1]_
264+ (problem (1.5), p5).
264265
265266 Parameters
266267 ----------
@@ -278,8 +279,8 @@ def randomized_svd(
278279 approximation of singular vectors and singular values. Users might wish
279280 to increase this parameter up to `2*k - n_components` where k is the
280281 effective rank, for large matrices, noisy problems, matrices with
281- slowly decaying spectrums, or to increase precision accuracy. See Halko
282- et al (pages 5, 23 and 26).
282+ slowly decaying spectrums, or to increase precision accuracy. See [1]_
283+ (pages 5, 23 and 26).
283284
284285 n_iter : int or 'auto', default='auto'
285286 Number of power iterations. It can be used to deal with very noisy
@@ -291,7 +292,7 @@ def randomized_svd(
291292 more costly power iterations steps. When `n_components` is equal
292293 or greater to the effective matrix rank and the spectrum does not
293294 present a slow decay, `n_iter=0` or `1` should even work fine in theory
294- (see Halko et al paper, page 9).
295+ (see [1]_ page 9).
295296
296297 .. versionchanged:: 0.18
297298
@@ -332,6 +333,14 @@ def randomized_svd(
332333 the value of `random_state` explicitly to suppress the deprecation
333334 warning.
334335
336+ svd_lapack_driver : {"gesdd", "gesvd"}, default="gesdd"
337+ Whether to use the more efficient divide-and-conquer approach
338+ (`"gesdd"`) or more general rectangular approach (`"gesvd"`) to compute
339+ the SVD of the matrix B, which is the projection of M into a low
340+ dimensional subspace, as described in [1]_.
341+
342+ .. versionadded:: 1.2
343+
335344 Notes
336345 -----
337346 This algorithm finds a (usually very good) approximate truncated
@@ -346,17 +355,16 @@ def randomized_svd(
346355
347356 References
348357 ----------
349- * :arxiv:`"Finding structure with randomness:
358+ .. [1] :arxiv:`"Finding structure with randomness:
350359 Stochastic algorithms for constructing approximate matrix decompositions"
351360 <0909.4061>`
352361 Halko, et al. (2009)
353362
354- * A randomized algorithm for the decomposition of matrices
363+ .. [2] A randomized algorithm for the decomposition of matrices
355364 Per-Gunnar Martinsson, Vladimir Rokhlin and Mark Tygert
356365
357- * An implementation of a randomized algorithm for principal component
358- analysis
359- A. Szlam et al. 2014
366+ .. [3] An implementation of a randomized algorithm for principal component
367+ analysis A. Szlam et al. 2014
360368 """
361369 if isinstance (M , (sparse .lil_matrix , sparse .dok_matrix )):
362370 warnings .warn (
@@ -405,7 +413,7 @@ def randomized_svd(
405413 B = safe_sparse_dot (Q .T , M )
406414
407415 # compute the SVD on the thin matrix: (k + p) wide
408- Uhat , s , Vt = linalg .svd (B , full_matrices = False )
416+ Uhat , s , Vt = linalg .svd (B , full_matrices = False , lapack_driver = svd_lapack_driver )
409417
410418 del B
411419 U = np .dot (Q , Uhat )
0 commit comments