From 23121b12f86faad1ce8cae2556b2f7f19b30fe18 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Wed, 2 Jun 2021 13:31:15 -0500 Subject: [PATCH] Add test for norm of complex vector --- test/test_arraycontext.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py index 57bc776..aeadb70 100644 --- a/test/test_arraycontext.py +++ b/test/test_arraycontext.py @@ -677,6 +677,17 @@ def test_numpy_conversion(actx_factory): # }}} +@pytest.mark.parametrize("norm_ord", [2, np.inf]) +def test_norm_complex(actx_factory, norm_ord): + actx = actx_factory() + a = np.random.randn(2000) + 1j * np.random.randn(2000) + + norm_a_ref = np.linalg.norm(a, norm_ord) + norm_a = actx.np.linalg.norm(actx.from_numpy(a), norm_ord) + + assert abs(norm_a_ref - norm_a)/norm_a < 1e-13 + + if __name__ == "__main__": import sys if len(sys.argv) > 1: -- GitLab