From cb179a76ce2b367f03180d03847457efeb32abf3 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Sun, 20 Oct 2024 19:20:38 +0200 Subject: [PATCH] chore: moved debug prints to separate function --- code/tests.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/code/tests.py b/code/tests.py index e3defbbd..6e16b4d4 100644 --- a/code/tests.py +++ b/code/tests.py @@ -23,19 +23,20 @@ def calculate_eigenvalues(A): return lambda_min, lambda_max -@pytest.mark.parametrize("n", [2, 3, 4, 5, 10, 20, 50, 100]) -def test_richardson_vs_cg(n: int): - print("matrix size: ", n) - tolerance = 1e-5 - max_iterations=1000 - A, b = MatrixGenerator.generate_random_matrix_and_vector(n) +def numpy_additional_richardson_calculations(): lambda_min, lambda_max = calculate_eigenvalues(A) print("eigenvalues: ", lambda_min, lambda_max, RichardsonMethod.calculate_eigenvalues(A, max_iterations)) omega = 2 / (lambda_min + lambda_max) print("omega: ", omega, RichardsonMethod.calculate_omega(lambda_min, lambda_max)) I = np.eye(n) print("norms: ", calculate_norm_numpy(I, omega, A), RichardsonMethod.convergence_norm(A, omega, I)) - + +@pytest.mark.parametrize("n", [2, 3, 4, 5, 10, 20, 50, 100]) +def test_richardson_vs_cg(n: int): + print("matrix size: ", n) + tolerance = 1e-5 + max_iterations=1000 + A, b = MatrixGenerator.generate_random_matrix_and_vector(n) richardson_solver = RichardsonMethod(A, b, max_iterations, size=n, tol=1e-7) solution_richardson = richardson_solver.solve()