quimb.linalg.rand_linalg¶
Randomized iterative methods for decompositions.
Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Core R3SVD algorithm. |
|
|
|
|
|
Handle rank-adaptively calling |
|
|
|
Check if |
|
Estimate the rank of an linear operator. Uses a low quality random |
|
|
|
Fast, randomized, iterative SVD. Adaptive variant of method due |
Module Contents¶
- quimb.linalg.rand_linalg.rsvd_core(A, k, compute_uv=True, q=2, p=0, state=None, AH=None)[source]¶
Core R3SVD algorithm.
- Parameters:
A (linear operator, shape (m, n)) – Operator to decompose, assumed m >= n.
k (int) – Number of singular values to find.
compute_uv (bool, optional) – Return the left and right singular vectors.
q (int, optional) – Number of power iterations.
p (int, optional) – Over sampling factor.
state ({None, array_like, (), (G0,), (U0, s0, VH0, G0)}, optional) –
Iterate based on these previous results:
None: basic mode.
array_like: use this as the initial subspace.
’begin-svd’: begin block iterations, return U, s, VH, G
(G0,) : begin block iterations with this subspace
(U0, s0, VH0, G0): continue block iterations, return G
- quimb.linalg.rand_linalg.rsvd_iterate(A, eps, compute_uv=True, q=2, p=0, G0=None, k_max=None, k_start=2, k_incr=1.4, AH=None, use_qb=20)[source]¶
Handle rank-adaptively calling
rsvd_core.
- quimb.linalg.rand_linalg.estimate_rank(A, eps, k_max=None, use_sli=True, k_start=2, k_incr=1.4, q=0, p=0, get_vectors=False, G0=None, AH=None, use_qb=20)[source]¶
Estimate the rank of an linear operator. Uses a low quality random SVD with a resolution of ~ 10.
- Parameters:
A (linear operator) – The operator to find rank of.
eps (float) – Find rank to this relative (compared to largest singular value) precision.
k_max (int, optional) – The maximum rank to find.
use_sli (bool, optional) – Whether to use
scipy.linalg.interpolative.estimate_rank()if possible (double precision and nok_maxset).k_start (int, optional) – Begin the adaptive SVD with a block of this size.
k_incr (float, optional) – Adaptive rank increment factor. Increase the k-step (from k_start) by this factor each time. Set to 1 to use a constant step.
q (int, optional) – Number of power iterations.
get_vectors (bool, optional) – Return the right singular vectors found in the pass.
G0 (, optional)
- Returns:
rank (int) – The rank.
VH (array) – The (adjoint) right singular vectors if
get_vectors=True.
- quimb.linalg.rand_linalg.rsvd(A, eps_or_k, compute_uv=True, mode='adapt+block', use_qb=20, q=2, p=0, k_max=None, k_start=2, k_incr=1.4, G0=None, AH=None)[source]¶
Fast, randomized, iterative SVD. Adaptive variant of method due originally to Halko. This scales as
log(k)rather thankso can be more efficient.- Parameters:
eps_or_k (float or int) – Either the relative precision or the number of singular values to target. If precision, this is relative to the largest singular value.
compute_uv (bool, optional) – Whether to return the left and right singular vectors.
mode ({'adapt+block', 'adapt', 'block'}, optional) –
How to perform the randomized SVD. If
eps_or_kis an integer then this is implicitly ‘block’ and ignored. Else:’adapt+block’, perform an initial low quality pass to estimate the rank of
A, then use the subspace and rank from that to perform an accurate fully blocked RSVD.’adapt’, just perform the adaptive randomized SVD.
q (int, optional) – The number of power iterations, increase for accuracy at the expense of runtime.
p (int, optional) – Oversampling factor. Perform projections with this many extra columns and then throw then away.
k_max (int, optional) – Maximum adaptive rank. Default:
min(A.shape).k_start (int, optional) – Initial k when increasing rank adaptively.
k_incr (float, optional) – Adaptive rank increment factor. Increase the k-step (from k_start) by this factor each time. Set to 1 to use a constant step.
G0 (array_like, shape (n, k), optional) – Initial subspace to start iterating on. If not given a random one will be generated.
- Returns:
U, array, shape (m, k) – Left singular vectors, if
compute_uv=True.s, array, shape (k,) – Singular values.
V, array, shape (k, n) – Right singular vectors, if
compute_uv=True.