diff --git a/nifty/field.py b/nifty/field.py index f3311e91029ae39ce3ea971683796c2fade7a7ab..67e092d0acd3dc886ae65e0e5409f1186df8f6db 100644 --- a/nifty/field.py +++ b/nifty/field.py @@ -1073,7 +1073,7 @@ class Field(Loggable, Versionable, object): if spaces is None: x_val = x.get_val(copy=False) y_val = y.get_val(copy=False) - result = (x_val.conjugate() * y_val).sum() + result = (y_val.conjugate() * x_val).sum() return result else: # create a diagonal operator which is capable of taking care of the diff --git a/test/test_field.py b/test/test_field.py index 98249ec2e6c439ff07e4dc315ea23f925979dcd8..c0730910eb89b59561af3ebe4771604de1dbd0d2 100644 --- a/test/test_field.py +++ b/test/test_field.py @@ -119,3 +119,12 @@ class Test_Functionality(unittest.TestCase): assert_allclose(ps2.val.get_full_data()/samples, fp2.val.get_full_data(), rtol=0.1) + + def test_vdot(self): + s=RGSpace((10,)) + f1=Field.from_random("normal",domain=s,dtype=np.complex128) + f2=Field.from_random("normal",domain=s,dtype=np.complex128) + assert_allclose(f1.vdot(f2),f1.vdot(f2,spaces=0)) + assert_allclose(f1.vdot(f2),np.conj(f2.vdot(f1))) + +