Skip to content

Commit

Permalink
[rand_la] fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artpelling committed Oct 5, 2022
1 parent f8d0ce9 commit 38eec03
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pymortests/rand_la.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import scipy as sp
from numpy.random import uniform

from pymor.algorithms.rand_la import rrf, adaptive_rrf, random_ghep, random_generalized_svd
from pymor.algorithms.rand_la import rrf, adaptive_rrf, randomized_ghep, randomized_svd
from pymor.operators.numpy import NumpyMatrixOperator
from pymor.operators.constructions import VectorArrayOperator
from pymor.tools.random import new_rng
Expand Down Expand Up @@ -72,13 +72,13 @@ def test_rrf():
assert len(Q2) == 8


def test_random_generalized_svd():
def test_randomized_svd():
np.random.seed(4)
E = uniform(low=-1.0, high=1.0, size=(5, 5))
E_op = NumpyMatrixOperator(E)

modes = 3
U, s, Vh = random_generalized_svd(E_op, n=modes, oversampling=1)
U, s, Vh = randomized_svd(E_op, n=modes, oversampling=1)
U_real, s_real, Vh_real = sp.linalg.svd(E)

assert abs(np.linalg.norm(s-s_real[:modes])) <= 1e-2
Expand All @@ -89,15 +89,15 @@ def test_random_generalized_svd():
assert Vh in E_op.source


def test_random_ghep():
def test_randomized_ghep():
np.random.seed(5)
D = uniform(low=-1.0, high=1.0, size=(5, 5))
D = D @ D.T
D_op = NumpyMatrixOperator(D)

modes = 3
w1, V1 = random_ghep(D_op, n=modes, p=1, single_pass=False)
w2, V2 = random_ghep(D_op, n=modes, p=1, single_pass=True)
w1, V1 = randomized_ghep(D_op, n=modes, p=1, single_pass=False)
w2, V2 = randomized_ghep(D_op, n=modes, p=1, single_pass=True)
w_real, V_real = sp.linalg.eigh(D)
w_real = w_real[::-1]
V_real = V_real[:, ::-1]
Expand Down

0 comments on commit 38eec03

Please sign in to comment.