Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add random_state and seed arguments to rrf and adaptive_rrf #1564

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/pymor/algorithms/randrangefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def mvinv(v):


@defaults('q', 'l')
def rrf(A, source_product=None, range_product=None, q=2, l=8, iscomplex=False):
def rrf(A, source_product=None, range_product=None, q=2, l=8, iscomplex=False, seed=None):
"""Randomized range approximation of `A`.

This is an implementation of Algorithm 4.4 in :cite:`HMT11`.
Expand All @@ -116,6 +116,8 @@ def rrf(A, source_product=None, range_product=None, q=2, l=8, iscomplex=False):
The block size of the normalized power iterations.
iscomplex
If `True`, the random vectors are chosen complex.
seed
The seed to use for the random samples, defaults to `None`.
artpelling marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
Expand All @@ -126,9 +128,11 @@ def rrf(A, source_product=None, range_product=None, q=2, l=8, iscomplex=False):
assert range_product is None or isinstance(range_product, Operator)
assert isinstance(A, Operator)

R = A.source.random(l, distribution='normal')
if iscomplex:
R += 1j*A.source.random(l, distribution='normal')
R = A.source.random(2*l, distribution='normal', seed=seed)
R = R[:l] + 1j * R[l:]
else:
R = A.source.random(l, distribution='normal', seed=seed)
Q = A.apply(R)
gram_schmidt(Q, range_product, atol=0, rtol=0, copy=False)

Expand Down