pymor.algorithms.rand_la¶
Module Contents¶
- class pymor.algorithms.rand_la.RandomizedRangeFinder(A, range_product=None, source_product=None, A_adj=None, power_iterations=0, block_size=None, failure_tolerance=1e-15, num_testvecs=20, lambda_min=None, iscomplex=False, qr_method='gram_schmidt', error_estimator='bs18')[source]¶
Bases:
pymor.core.base.BasicObjectAdaptive randomized range approximation of
A.Algorithm 1 in [BS18] is used as the default error estimator.
Given the
OperatorA, the return value of this method is theVectorArrayBwith the property\[\Vert A - P_{span(B)} A \Vert \leq tol\]with a failure probability smaller than
failure_tolerance, where the norm denotes the operator norm. The inner product of the range ofAis given byrange_productand the inner product of the source ofAis given bysource_product.A faster alternative is the leave-one-out error estimator from [ET24] which can be activated by setting
error_estimator='loo'. The leave-one-out error estimator estimates the Frobenius norm of the approximation error. Note that while it can be faster and more accurate in practice, this option does only support Euclidian inner products and there are no results on its failure probability so far.- Parameters:
A – The
OperatorA.source_product – Inner product
Operatorof the source of A.range_product – Inner product
Operatorof the range of A.power_iterations – Number of power iterations.
A_adj – Adjoint
Operatorto use for power iterations. IfNonethe adjoint is computed usingA,source_productandrange_product. Set toAfor aselffor a known self-adjoint operator.failure_tolerance – Maximum failure probability. Only needed for error_estimator=’bs18’.
num_testvecs – Number of test vectors. Only needed for error_estimator=’bs18’.
lambda_min – The smallest eigenvalue of source_product. Only needed for error_estimator=’bs18’. If
None, the smallest eigenvalue is computed using scipy.block_size – Number of basis vectors to add per iteration.
iscomplex – If
True, the random vectors are chosen complex.qr_method – QR method used for orthogonalization. Either ‘gram_schmidt’ (default) or ‘shifted_chol_qr’.
error_estimator – The error estimator used. Either ‘bs18’ (default) or ‘loo’.
Methods
Find the range of A.
- pymor.algorithms.rand_la.randomized_ghep(A, E=None, n=6, power_iterations=0, oversampling=20, single_pass=False, return_evecs=False)[source]¶
Approximates a few eigenvalues of a Hermitian linear
Operatorwith randomized methods.Approximates
modeseigenvalueswwith corresponding eigenvectorsvwhich solve the eigenvalue problem\[A v_i = w_i v_i\]or the generalized eigenvalue problem
\[A v_i = w_i E v_i\]if
Eis notNone.This method is an implementation of algorithm 6 and 7 in [SLK16].
- Parameters:
A – The Hermitian linear
Operatorfor which the eigenvalues are to be computed.E – The Hermitian
Operatorwhich defines the generalized eigenvalue problem.n – The number of eigenvalues and eigenvectors which are to be computed. Defaults to 6.
power_iterations – The number of power iterations to increase the relative weight of the larger singular values. Ignored when
single_passisTrue.oversampling – The number of samples that are drawn in addition to the desired basis size in the randomized range approximation process.
single_pass – If
True, computes the GHEP where only one set of matvecs Ax is required, but at the expense of lower numerical accuracy. IfFalse, the methods performs two sets of matvecs Ax (default).return_evecs – If
True, the eigenvectors are computed and returned. Defaults toFalse.
- Returns:
w – A 1D
NumPy arraywhich contains the computed eigenvalues.V – A
VectorArraywhich contains the computed eigenvectors.
- pymor.algorithms.rand_la.randomized_svd(A, n, source_product=None, range_product=None, power_iterations=0, oversampling=20)[source]¶
Randomized SVD of an
Operatorbased on [SHvBW21].Viewing the
Operator\(A\) as an \(m\) by \(n\) matrix, this methods computes and returns the randomized generalized singular value decomposition ofAaccording [SHvBW21]:\[A = U \Sigma V^{-1},\]where the inner product on the range \(\mathbb{R}^m\) is given by
\[(x, y)_R = x^TRy\]and the inner product on the source \(\mathbb{R}^n\) is given by
\[(x, y)_S = x^TSy.\]Note that \(U\) is \(R\)-orthogonal, i.e. \(U^TRU=I\) and \(V\) is \(S\)-orthogonal, i.e. \(V^TSV=I\). In particular,
V^{-1}=V^TS.- Parameters:
A – The
Operatorfor which the randomized SVD is to be computed.n – The number of eigenvalues and eigenvectors which are to be computed.
source_product – Source product
Operator\(S\) w.r.t. which the randomized SVD is computed.range_product – Range product
Operator\(R\) w.r.t. which the randomized SVD is computed.power_iterations – The number of power iterations to increase the relative weight of the larger singular values.
oversampling – The number of samples that are drawn in addition to the desired basis size in the randomized range approximation process.
- Returns:
U –
VectorArraycontaining the approximated left singular vectors.s – One-dimensional
NumPy arrayof the approximated singular values.V –
VectorArraycontaining the approximated right singular vectors.